From 9d1a59fd646b867ab30712056682f8c643b2cfd9 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 25 Jun 2019 23:06:51 +0200 Subject: bridge-port-to-default: get bridge port values into array --- bridge-port-to-default | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/bridge-port-to-default b/bridge-port-to-default index 1117c1d..4d25513 100644 --- a/bridge-port-to-default +++ b/bridge-port-to-default @@ -13,18 +13,17 @@ :set Len ([ :len $BridgePortTo ] + 1); } -:foreach Interface in=[ / interface bridge port find where comment!="" ] do={ - :foreach Comment in=[ :toarray [ / interface bridge port get $Interface comment ] ] do={ +: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 InterfaceName [ / interface bridge port get $Interface interface ]; :local BridgeDefault [ :pick $Comment $Len [ :len $Comment ] ]; - :local BridgeCurrent [ / interface bridge port get $Interface bridge ]; - :if ($BridgeDefault != $BridgeCurrent) do={ - :log info ("Changing interface " . $InterfaceName . " to " . $BridgePortTo . " bridge " . $BridgeDefault); - / interface bridge port set bridge=$BridgeDefault $Interface; + :if ($BridgeDefault != $BridgePortVal->"bridge") do={ + :log info ("Changing interface " . $BridgePortVal->"interface" . " to " . $BridgePortTo . " bridge " . $BridgeDefault); + / interface bridge port set bridge=$BridgeDefault $BridgePort; / ip dhcp-client renew [ find where interface=$BridgeDefault ]; } else={ - :log debug ("Interface " . $InterfaceName . " already connected to " . $BridgePortTo . " bridge " . $BridgeDefault); + :log debug ("Interface " . $BridgePortVal->"interface" . " already connected to " . $BridgePortTo . " bridge " . $BridgeDefault); } } } -- cgit v1.2.3-70-g09d2