bridge-port-to-default: support different configurations

Just add something like this to your bridge ports:

comment="default:br-ext,alt:br-intern"
This commit is contained in:
Christian Hesse 2018-10-04 13:56:09 +02:00
parent ea4b739d00
commit 17f64b48af
2 changed files with 21 additions and 10 deletions

View file

@ -4,15 +4,23 @@
# #
# reset bridge ports to default bridge # reset bridge ports to default bridge
:foreach interface in=[ / interface bridge port find where comment~"^default:" ] do={ :global "bridge-port-to";
:local comment [ / interface bridge port get $interface comment ];
:local "interface-name" [ / interface bridge port get $interface interface ]; :local "len" ([ :len $"bridge-port-to" ] + 1);
:local "bridge-default" [ :pick $comment 8 [ :len $comment ] ];
:local "bridge-current" [ / interface bridge port get $interface bridge ]; :foreach interface in=[ / interface bridge port find where comment!="" ] do={
:if ($"bridge-default" != $"bridge-current") do={ :foreach comment in=[ :toarray [ / interface bridge port get $interface comment ] ] do={
:log info ("Reverting interface " . $"interface-name" . " to default bridge " . $"bridge-default"); :if ([ :pick $comment 0 $len ] = ($"bridge-port-to" . ":")) do={
/ interface bridge port set bridge=$"bridge-default" $interface; :local "interface-name" [ / interface bridge port get $interface interface ];
} else={ :local "bridge-default" [ :pick $comment $len [ :len $comment ] ];
:log debug ("Interface " . $"interface-name" . " already connected to default bridge " . $"bridge-default"); :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");
}
}
} }
} }

View file

@ -26,6 +26,9 @@
:global "safe-update-url" ""; :global "safe-update-url" "";
#:global "safe-update-url" "https://example.com/ros/safe-update/"; #:global "safe-update-url" "https://example.com/ros/safe-update/";
# This controls what configuration is activated by bridge-port-to-default.
:global "bridge-port-to" "default";
# This is used to update AAAA records and firewall address-list. # This is used to update AAAA records and firewall address-list.
:global "ipv6-interface" "br-local"; :global "ipv6-interface" "br-local";
:global "ipv6-pool" "telekom"; :global "ipv6-pool" "telekom";