mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
69352c90d5
Now that we expect the scheduler to have a delay and script-updates warning about it...
35 lines
1.7 KiB
Text
35 lines
1.7 KiB
Text
#!rsc
|
|
# RouterOS script: bridge-port-to-default
|
|
# Copyright (c) 2013-2020 Christian Hesse <mail@eworm.de>
|
|
#
|
|
# reset bridge ports to default bridge
|
|
|
|
:global BridgePortTo;
|
|
|
|
:foreach BridgePort in=[ / interface bridge port find where comment!="" ] do={
|
|
:local BridgePortVal [ / interface bridge port get $BridgePort ];
|
|
:foreach Comment in=[ :toarray ($BridgePortVal->"comment") ] do={
|
|
:if ([ :pick $Comment 0 $Len ] = ($BridgePortTo . ":")) do={
|
|
:local BridgeDefault [ :pick $Comment $Len [ :len $Comment ] ];
|
|
:if ($BridgeDefault = "dhcp-client") do={
|
|
:if ($BridgePortVal->"disabled" = false) do={
|
|
:log info ("Disabling bridge port for interface " . $BridgePortVal->"interface" . ", enabling dhcp client.");
|
|
/ interface bridge port disable $BridgePort;
|
|
/ ip dhcp-client enable [ find where interface=$BridgePortVal->"interface" comment="toggle with bridge port" disabled=yes ];
|
|
}
|
|
} else={
|
|
:if ($BridgePortVal->"disabled" = true) do={
|
|
:log info ("Enabling bridge port for interface " . $BridgePortVal->"interface" . ", disabling dhcp client.");
|
|
/ ip dhcp-client disable [ find where interface=$BridgePortVal->"interface" comment="toggle with bridge port" disabled=no ];
|
|
/ interface bridge port enable $BridgePort;
|
|
}
|
|
:if ($BridgeDefault != $BridgePortVal->"bridge") do={
|
|
:log info ("Changing interface " . $BridgePortVal->"interface" . " to " . $BridgePortTo . " bridge " . $BridgeDefault);
|
|
/ interface bridge port set bridge=$BridgeDefault $BridgePort;
|
|
} else={
|
|
:log debug ("Interface " . $BridgePortVal->"interface" . " already connected to " . $BridgePortTo . " bridge " . $BridgeDefault);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|