aboutsummaryrefslogtreecommitdiffstats
path: root/bridge-port-to-default
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2018-10-04 13:56:09 +0200
committerGravatar Christian Hesse <mail@eworm.de>2018-10-04 13:56:09 +0200
commit17f64b48af7515ec9ed219e25fc900969169fee6 (patch)
treec9db7e846e11e2dc8455a43e7c2d59f8eff1c548 /bridge-port-to-default
parentea4b739d008437d82f4176db4706b13e31f5dfa2 (diff)
bridge-port-to-default: support different configurations
Just add something like this to your bridge ports: comment="default:br-ext,alt:br-intern"
Diffstat (limited to 'bridge-port-to-default')
-rw-r--r--bridge-port-to-default28
1 files changed, 18 insertions, 10 deletions
diff --git a/bridge-port-to-default b/bridge-port-to-default
index fc86aae..3a62a57 100644
--- a/bridge-port-to-default
+++ b/bridge-port-to-default
@@ -4,15 +4,23 @@
#
# reset bridge ports to default bridge
-:foreach interface in=[ / interface bridge port find where comment~"^default:" ] do={
- :local comment [ / interface bridge port get $interface comment ];
- :local "interface-name" [ / interface bridge port get $interface interface ];
- :local "bridge-default" [ :pick $comment 8 [ :len $comment ] ];
- :local "bridge-current" [ / interface bridge port get $interface bridge ];
- :if ($"bridge-default" != $"bridge-current") do={
- :log info ("Reverting interface " . $"interface-name" . " to default bridge " . $"bridge-default");
- / interface bridge port set bridge=$"bridge-default" $interface;
- } else={
- :log debug ("Interface " . $"interface-name" . " already connected to default bridge " . $"bridge-default");
+:global "bridge-port-to";
+
+:local "len" ([ :len $"bridge-port-to" ] + 1);
+
+:foreach interface in=[ / interface bridge port find where comment!="" ] do={
+ :foreach comment in=[ :toarray [ / interface bridge port get $interface comment ] ] do={
+ :if ([ :pick $comment 0 $len ] = ($"bridge-port-to" . ":")) do={
+ :local "interface-name" [ / interface bridge port get $interface interface ];
+ :local "bridge-default" [ :pick $comment $len [ :len $comment ] ];
+ :local "bridge-current" [ / interface bridge port get $interface bridge ];
+ :if ($"bridge-default" != $"bridge-current") do={
+ :log info ("Changing interface " . $"interface-name" . " to " . $"bridge-port-to" . " bridge " . $"bridge-default");
+ / interface bridge port set bridge=$"bridge-default" $interface;
+ / ip dhcp-client renew [ find where interface=$"bridge-default" ];
+ } else={
+ :log debug ("Interface " . $"interface-name" . " already connected to " . $"bridge-port-to" . " bridge " . $"bridge-default");
+ }
+ }
}
}