aboutsummaryrefslogblamecommitdiffstats
path: root/manage-umts
blob: 0cd3e8f2d0b86670cba84ec650d4ec26f107339f (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                 
                              
                                                         
                                                             

                                                             

                            
 
                                                                 
 
                                                    
                                                         

                                                                            
                                         
   
        
                                                        

                                                                         
                                        
   
#!rsc by RouterOS
# RouterOS script: manage-umts
# Copyright (c) 2013-2022 Christian Hesse <mail@eworm.de>
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
#
# manage UMTS interface based on ethernet and wireless status

:local EtherInt "en1";
:local WlanInt "wl-station";
:local UmtsInt "t-mobile";

:local EtherStatus [ /interface/ethernet/get $EtherInt running ];
:local WlanStatus [ /interface/wireless/get $WlanInt running ];

:if ($EtherStatus = true || $WlanStatus = true) do={
  :if ([ /interface/get $UmtsInt disabled ] = false) do={
    :log info ("Ethernet (" . $EtherInt . " / " . $EtherStatus . ") or " . \
      "wireless (" . $WlanInt . " / " . $WlanStatus . ") is running, " . \
      "UMTS interface " . $UmtsInt . " is enabled. Disabling...");
    /interface/set disabled=yes $UmtsInt;
  }
} else={
  :if ([ /interface/get $UmtsInt disabled ] = true) do={
    :log info ("Neither ethernet (" . $EtherInt . ") nor wireless (" . \
      $WlanInt . ") interface is running, UMTS interface " . $UmtsInt . \
      " is disabled. Enabling...");
    /interface/set disabled=no $UmtsInt;
  }
}