diff options
author | Christian Hesse <mail@eworm.de> | 2019-06-25 23:06:51 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2019-06-25 23:06:51 +0200 |
commit | 9d1a59fd646b867ab30712056682f8c643b2cfd9 (patch) | |
tree | f6cb9aa71f52c9b695f170c9dc1455520aab4186 /bridge-port-to-default | |
parent | 2f22e06b9b944d5df903f0943d1ea7a87a24493e (diff) |
bridge-port-to-default: get bridge port values into array
Diffstat (limited to 'bridge-port-to-default')
-rw-r--r-- | bridge-port-to-default | 15 |
1 files 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); } } } |