mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-10 10:04:28 +02:00
mod/bridge-port-vlan: RouterOS v7 path syntax
This commit is contained in:
parent
158aea4756
commit
9bd9f4b4ba
1 changed files with 9 additions and 9 deletions
|
@ -16,29 +16,29 @@
|
||||||
:global LogPrintExit2;
|
:global LogPrintExit2;
|
||||||
:global ParseKeyValueStore;
|
:global ParseKeyValueStore;
|
||||||
|
|
||||||
:foreach BridgePort in=[ / interface bridge port find where !(comment=[]) ] do={
|
:foreach BridgePort in=[ /interface/bridge/port/find where !(comment=[]) ] do={
|
||||||
:local BridgePortVal [ / interface bridge port get $BridgePort ];
|
:local BridgePortVal [ /interface/bridge/port/get $BridgePort ];
|
||||||
:foreach Config,Vlan in=[ $ParseKeyValueStore ($BridgePortVal->"comment") ] do={
|
:foreach Config,Vlan in=[ $ParseKeyValueStore ($BridgePortVal->"comment") ] do={
|
||||||
:if ($Config = $ConfigTo) do={
|
:if ($Config = $ConfigTo) do={
|
||||||
:local DHCPClient [ / ip dhcp-client find where interface=$BridgePortVal->"interface" comment="toggle with bridge port" ];
|
:local DHCPClient [ /ip/dhcp-client/find where interface=$BridgePortVal->"interface" comment="toggle with bridge port" ];
|
||||||
|
|
||||||
:if ($Vlan = "dhcp-client") do={
|
:if ($Vlan = "dhcp-client") do={
|
||||||
:if ([ :len $DHCPClient ] != 1) do={
|
:if ([ :len $DHCPClient ] != 1) do={
|
||||||
$LogPrintExit2 warning $0 ([ $IfThenElse ([ :len $DHCPClient ] = 0) "Missing" "Duplicate" ] . \
|
$LogPrintExit2 warning $0 ([ $IfThenElse ([ :len $DHCPClient ] = 0) "Missing" "Duplicate" ] . \
|
||||||
" dhcp client configuration for interface " . $BridgePortVal->"interface" . "!") true;
|
" dhcp client configuration for interface " . $BridgePortVal->"interface" . "!") true;
|
||||||
}
|
}
|
||||||
:local DHCPClientDisabled [ / ip dhcp-client get $DHCPClient disabled ];
|
:local DHCPClientDisabled [ /ip/dhcp-client/get $DHCPClient disabled ];
|
||||||
|
|
||||||
:if ($BridgePortVal->"disabled" = false || $DHCPClientDisabled = true) do={
|
:if ($BridgePortVal->"disabled" = false || $DHCPClientDisabled = true) do={
|
||||||
$LogPrintExit2 info $0 ("Disabling bridge port for interface " . $BridgePortVal->"interface" . ", enabling dhcp client.") false;
|
$LogPrintExit2 info $0 ("Disabling bridge port for interface " . $BridgePortVal->"interface" . ", enabling dhcp client.") false;
|
||||||
/ interface bridge port disable $BridgePort;
|
/interface/bridge/port/disable $BridgePort;
|
||||||
:delay 200ms;
|
:delay 200ms;
|
||||||
/ ip dhcp-client enable $DHCPClient;
|
/ip/dhcp-client/enable $DHCPClient;
|
||||||
}
|
}
|
||||||
} else={
|
} else={
|
||||||
:if ($Vlan != [ :tostr [ :tonum $Vlan ] ]) do={
|
:if ($Vlan != [ :tostr [ :tonum $Vlan ] ]) do={
|
||||||
:do {
|
:do {
|
||||||
:set $Vlan ([ / interface bridge vlan get [ find where comment=$Vlan ] vlan-ids ]->0);
|
:set $Vlan ([ /interface/bridge/vlan/get [ find where comment=$Vlan ] vlan-ids ]->0);
|
||||||
} on-error={
|
} on-error={
|
||||||
$LogPrintExit2 warning $0 ("Could not find VLAN '" . $Vlan . "' for interface " . $BridgePortVal->"interface" . "!") true;
|
$LogPrintExit2 warning $0 ("Could not find VLAN '" . $Vlan . "' for interface " . $BridgePortVal->"interface" . "!") true;
|
||||||
}
|
}
|
||||||
|
@ -47,10 +47,10 @@
|
||||||
$LogPrintExit2 info $0 ("Enabling bridge port for interface " . $BridgePortVal->"interface" . ", changing to " . $ConfigTo . \
|
$LogPrintExit2 info $0 ("Enabling bridge port for interface " . $BridgePortVal->"interface" . ", changing to " . $ConfigTo . \
|
||||||
" vlan " . $Vlan . ", disabling dhcp client.") false;
|
" vlan " . $Vlan . ", disabling dhcp client.") false;
|
||||||
:if ([ :len $DHCPClient ] = 1) do={
|
:if ([ :len $DHCPClient ] = 1) do={
|
||||||
/ ip dhcp-client disable $DHCPClient;
|
/ip/dhcp-client/disable $DHCPClient;
|
||||||
:delay 200ms;
|
:delay 200ms;
|
||||||
}
|
}
|
||||||
/ interface bridge port set disabled=no pvid=$Vlan $BridgePort;
|
/interface/bridge/port/set disabled=no pvid=$Vlan $BridgePort;
|
||||||
} else={
|
} else={
|
||||||
$LogPrintExit2 debug $0 ("Interface " . $BridgePortVal->"interface" . " already connected to " . $ConfigTo . \
|
$LogPrintExit2 debug $0 ("Interface " . $BridgePortVal->"interface" . " already connected to " . $ConfigTo . \
|
||||||
" vlan " . $Vlan . ".") false;
|
" vlan " . $Vlan . ".") false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue