diff options
author | Christian Hesse <mail@eworm.de> | 2021-11-12 14:10:13 +0100 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2021-11-15 22:18:10 +0100 |
commit | f484e45b6a1fe5284462da19c90219d0716d916a (patch) | |
tree | 5fae733f782467e6dd912dd1b40efeeafe9d6c88 /bridge-port-to-default | |
parent | b6215ba95899328bd13fabbf6488b602763b9352 (diff) |
bridge-port-to-default -> global-functions.d/bridge-port-tochange-66
Diffstat (limited to 'bridge-port-to-default')
-rw-r--r-- | bridge-port-to-default | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/bridge-port-to-default b/bridge-port-to-default deleted file mode 100644 index b8503df..0000000 --- a/bridge-port-to-default +++ /dev/null @@ -1,53 +0,0 @@ -#!rsc by RouterOS -# RouterOS script: bridge-port-to-default -# Copyright (c) 2013-2021 Christian Hesse <mail@eworm.de> -# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md -# -# reset bridge ports to default bridge -# https://git.eworm.de/cgit/routeros-scripts/about/doc/bridge-port.md - -:local 0 "bridge-port-to-default"; -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - -:global BridgePortTo; - -:global IfThenElse; -:global LogPrintExit2; -:global ParseKeyValueStore; - -:foreach BridgePort in=[ / interface bridge port find where !(comment=[]) ] do={ - :local BridgePortVal [ / interface bridge port get $BridgePort ]; - :foreach Config,BridgeDefault in=[ $ParseKeyValueStore ($BridgePortVal->"comment") ] do={ - :if ($Config = $BridgePortTo) do={ - :local DHCPClient [ / ip dhcp-client find where interface=$BridgePortVal->"interface" comment="toggle with bridge port" ]; - - :if ($BridgeDefault = "dhcp-client") do={ - :if ([ :len $DHCPClient ] != 1) do={ - $LogPrintExit2 warning $0 ([ $IfThenElse ([ :len $DHCPClient ] = 0) "Missing" "Duplicate" ] . \ - " dhcp client configuration for interface " . $BridgePortVal->"interface" . "!") true; - } - :local DHCPClientDisabled [ / ip dhcp-client get $DHCPClient disabled ]; - - :if ($BridgePortVal->"disabled" = false || $DHCPClientDisabled = true) do={ - $LogPrintExit2 info $0 ("Disabling bridge port for interface " . $BridgePortVal->"interface" . ", enabling dhcp client.") false; - / interface bridge port disable $BridgePort; - / ip dhcp-client enable $DHCPClient; - } - } else={ - :if ($BridgePortVal->"disabled" = true || $BridgeDefault != $BridgePortVal->"bridge") do={ - $LogPrintExit2 info $0 ("Enabling bridge port for interface " . $BridgePortVal->"interface" . ", changing to " . $BridgePortTo . \ - " bridge " . $BridgeDefault . ", disabling dhcp client.") false; - :if ([ :len $DHCPClient ] = 1) do={ - / ip dhcp-client disable $DHCPClient; - :delay 200ms; - } - / interface bridge port set disabled=no bridge=$BridgeDefault $BridgePort; - } else={ - $LogPrintExit2 debug $0 ("Interface " . $BridgePortVal->"interface" . " already connected to " . $BridgePortTo . \ - " bridge " . $BridgeDefault . ".") false; - } - } - } - } -} |