aboutsummaryrefslogtreecommitdiffstats
path: root/manage-umts
blob: b13049a198eaf9af94d6867e57a591875f24e95a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!rsc
# RouterOS script: manage-umts
# Copyright (c) 2013-2019 Christian Hesse <mail@eworm.de>
#
# 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;
  };
};