From 158aea4756edf1d013a910d3fb06fccd8ac2142f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 10 May 2022 16:09:42 +0200 Subject: mod/bridge-port-to: RouterOS v7 path syntax --- mod/bridge-port-to | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'mod') diff --git a/mod/bridge-port-to b/mod/bridge-port-to index d88b1cd..c2ab55b 100644 --- a/mod/bridge-port-to +++ b/mod/bridge-port-to @@ -15,34 +15,34 @@ :global LogPrintExit2; :global ParseKeyValueStore; - :foreach BridgePort in=[ / interface bridge port find where !(comment=[]) ] do={ - :local BridgePortVal [ / interface bridge port get $BridgePort ]; + :foreach BridgePort in=[ /interface/bridge/port/find where !(comment=[]) ] do={ + :local BridgePortVal [ /interface/bridge/port/get $BridgePort ]; :foreach Config,BridgeDefault in=[ $ParseKeyValueStore ($BridgePortVal->"comment") ] do={ :if ($Config = $BridgePortTo) 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 ($BridgeDefault = "dhcp-client") do={ :if ([ :len $DHCPClient ] != 1) do={ $LogPrintExit2 warning $0 ([ $IfThenElse ([ :len $DHCPClient ] = 0) "Missing" "Duplicate" ] . \ " 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={ $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; - / ip dhcp-client enable $DHCPClient; + /ip/dhcp-client/enable $DHCPClient; } } else={ :if ($BridgePortVal->"disabled" = true || $BridgeDefault != $BridgePortVal->"bridge") do={ $LogPrintExit2 info $0 ("Enabling bridge port for interface " . $BridgePortVal->"interface" . ", changing to " . $BridgePortTo . \ " bridge " . $BridgeDefault . ", disabling dhcp client.") false; :if ([ :len $DHCPClient ] = 1) do={ - / ip dhcp-client disable $DHCPClient; + /ip/dhcp-client/disable $DHCPClient; :delay 200ms; } - / interface bridge port set disabled=no bridge=$BridgeDefault $BridgePort; + /interface/bridge/port/set disabled=no bridge=$BridgeDefault $BridgePort; } else={ $LogPrintExit2 debug $0 ("Interface " . $BridgePortVal->"interface" . " already connected to " . $BridgePortTo . \ " bridge " . $BridgeDefault . ".") false; -- cgit v1.2.3-70-g09d2 From 9bd9f4b4bac56ad1a8278e634d3e64e5fd10102b Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 10 May 2022 16:09:50 +0200 Subject: mod/bridge-port-vlan: RouterOS v7 path syntax --- mod/bridge-port-vlan | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'mod') diff --git a/mod/bridge-port-vlan b/mod/bridge-port-vlan index db9cbfd..6255dff 100644 --- a/mod/bridge-port-vlan +++ b/mod/bridge-port-vlan @@ -16,29 +16,29 @@ :global LogPrintExit2; :global ParseKeyValueStore; - :foreach BridgePort in=[ / interface bridge port find where !(comment=[]) ] do={ - :local BridgePortVal [ / interface bridge port get $BridgePort ]; + :foreach BridgePort in=[ /interface/bridge/port/find where !(comment=[]) ] do={ + :local BridgePortVal [ /interface/bridge/port/get $BridgePort ]; :foreach Config,Vlan in=[ $ParseKeyValueStore ($BridgePortVal->"comment") ] 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 ([ :len $DHCPClient ] != 1) do={ $LogPrintExit2 warning $0 ([ $IfThenElse ([ :len $DHCPClient ] = 0) "Missing" "Duplicate" ] . \ " 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={ $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; - / ip dhcp-client enable $DHCPClient; + /ip/dhcp-client/enable $DHCPClient; } } else={ :if ($Vlan != [ :tostr [ :tonum $Vlan ] ]) 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={ $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 . \ " vlan " . $Vlan . ", disabling dhcp client.") false; :if ([ :len $DHCPClient ] = 1) do={ - / ip dhcp-client disable $DHCPClient; + /ip/dhcp-client/disable $DHCPClient; :delay 200ms; } - / interface bridge port set disabled=no pvid=$Vlan $BridgePort; + /interface/bridge/port/set disabled=no pvid=$Vlan $BridgePort; } else={ $LogPrintExit2 debug $0 ("Interface " . $BridgePortVal->"interface" . " already connected to " . $ConfigTo . \ " vlan " . $Vlan . ".") false; -- cgit v1.2.3-70-g09d2 From 50a139248ff4e9e026d2330c41781f915d39a115 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 10 May 2022 16:11:53 +0200 Subject: mod/notification-matrix: RouterOS v7 path syntax --- mod/notification-matrix | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'mod') diff --git a/mod/notification-matrix b/mod/notification-matrix index 4ec5f6c..c3cf24f 100644 --- a/mod/notification-matrix +++ b/mod/notification-matrix @@ -18,14 +18,14 @@ :local AllDone true; :local QueueLen [ :len $MatrixQueue ]; - :if ([ :len [ / system scheduler find where name="FlushMatrixQueue" ] ] > 0 && $QueueLen = 0) do={ + :if ([ :len [ /system/scheduler/find where name="FlushMatrixQueue" ] ] > 0 && $QueueLen = 0) do={ $LogPrintExit2 warning $0 ("Flushing Matrix messages from scheduler, but queue is empty.") false; } :foreach Id,Message in=$MatrixQueue do={ :if ([ :typeof $Message ] = "array" ) do={ :do { - / tool fetch check-certificate=yes-without-crl output=none http-method=post \ + /tool/fetch check-certificate=yes-without-crl output=none http-method=post \ ("https://" . $Message->"homeserver" . "/_matrix/client/r0/rooms/" . $Message->"room" . \ "/send/m.room.message?access_token=" . $Message->"accesstoken") \ http-data=("{ \"msgtype\": \"m.text\", \"body\": \"" . $Message->"plain" . "\"," . \ @@ -40,7 +40,7 @@ } :if ($AllDone = true && $QueueLen = [ :len $MatrixQueue ]) do={ - / system scheduler remove [ find where name="FlushMatrixQueue" ]; + /system/scheduler/remove [ find where name="FlushMatrixQueue" ]; :set MatrixQueue; } } @@ -113,7 +113,7 @@ } :do { - / tool fetch check-certificate=yes-without-crl output=none http-method=post \ + /tool/fetch check-certificate=yes-without-crl output=none http-method=post \ ("https://" . $HomeServer . "/_matrix/client/r0/rooms/" . $Room . \ "/send/m.room.message?access_token=" . $AccessToken) \ http-data=("{ \"msgtype\": \"m.text\", \"body\": \"" . $Plain . "\"," . \ @@ -126,15 +126,15 @@ :set MatrixQueue [ :toarray "" ]; } :local Text ([ $SymbolForNotification "alarm-clock" ] . \ - "This message was queued since " . [ / system clock get date ] . \ - " " . [ / system clock get time ] . " and may be obsolete."); + "This message was queued since " . [ /system/clock/get date ] . \ + " " . [ /system/clock/get time ] . " and may be obsolete."); :set Plain ($Plain . "\\n" . $Text); :set Formatted ($Formatted . "
" . $Text); :set ($MatrixQueue->[ :len $MatrixQueue ]) { room=$Room; \ accesstoken=$AccessToken; homeserver=$HomeServer; \ plain=$Plain; formatted=$Formatted }; - :if ([ :len [ / system scheduler find where name="FlushMatrixQueue" ] ] = 0) do={ - / system scheduler add name=FlushMatrixQueue interval=1m start-time=startup \ + :if ([ :len [ /system/scheduler/find where name="FlushMatrixQueue" ] ] = 0) do={ + /system/scheduler/add name=FlushMatrixQueue interval=1m start-time=startup \ on-event=(":global FlushMatrixQueue; \$FlushMatrixQueue;"); } } -- cgit v1.2.3-70-g09d2 From 20b5ca4918b8e087c500f44c5d243feb3674e9ae Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 10 May 2022 16:13:34 +0200 Subject: mod/notification-telegram: RouterOS v7 path syntax --- mod/notification-telegram | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'mod') diff --git a/mod/notification-telegram b/mod/notification-telegram index d42d459..230dd57 100644 --- a/mod/notification-telegram +++ b/mod/notification-telegram @@ -17,14 +17,14 @@ :local AllDone true; :local QueueLen [ :len $TelegramQueue ]; - :if ([ :len [ / system scheduler find where name="FlushTelegramQueue" ] ] > 0 && $QueueLen = 0) do={ + :if ([ :len [ /system/scheduler/find where name="FlushTelegramQueue" ] ] > 0 && $QueueLen = 0) do={ $LogPrintExit2 warning $0 ("Flushing Telegram messages from scheduler, but queue is empty.") false; } :foreach Id,Message in=$TelegramQueue do={ :if ([ :typeof $Message ] = "array" ) do={ :do { - / tool fetch check-certificate=yes-without-crl output=none http-method=post \ + /tool/fetch check-certificate=yes-without-crl output=none http-method=post \ ("https://api.telegram.org/bot" . ($Message->"tokenid") . "/sendMessage") \ http-data=("chat_id=" . ($Message->"chatid") . \ "&disable_notification=" . ($Message->"silent") . \ @@ -39,7 +39,7 @@ } :if ($AllDone = true && $QueueLen = [ :len $TelegramQueue ]) do={ - / system scheduler remove [ find where name="FlushTelegramQueue" ]; + /system/scheduler/remove [ find where name="FlushTelegramQueue" ]; :set TelegramQueue; } } @@ -125,7 +125,7 @@ :if ([ $CertificateAvailable "Go Daddy Secure Certificate Authority - G2" ] = false) do={ $LogPrintExit2 warning $0 ("Downloading required certificate failed.") true; } - / tool fetch check-certificate=yes-without-crl output=none http-method=post \ + /tool/fetch check-certificate=yes-without-crl output=none http-method=post \ ("https://api.telegram.org/bot" . $TokenId . "/sendMessage") \ http-data=("chat_id=" . $ChatId . "&disable_notification=" . ($Notification->"silent") . \ "&disable_web_page_preview=true&parse_mode=" . $ParseMode . "&text=" . $Text) as-value; @@ -136,12 +136,12 @@ :set TelegramQueue [ :toarray "" ]; } :set Text ($Text . [ $UrlEncode ("\n" . [ $SymbolForNotification "alarm-clock" ] . \ - [ $EscapeMD ("This message was queued since " . [ / system clock get date ] . \ - " " . [ / system clock get time ] . " and may be obsolete.") "plain" ]) ]); + [ $EscapeMD ("This message was queued since " . [ /system/clock/get date ] . \ + " " . [ /system/clock/get time ] . " and may be obsolete.") "plain" ]) ]); :set ($TelegramQueue->[ :len $TelegramQueue ]) { chatid=$ChatId; tokenid=$TokenId; parsemode=$ParseMode; text=$Text; silent=($Notification->"silent") }; - :if ([ :len [ / system scheduler find where name="FlushTelegramQueue" ] ] = 0) do={ - / system scheduler add name=FlushTelegramQueue interval=1m start-time=startup \ + :if ([ :len [ /system/scheduler/find where name="FlushTelegramQueue" ] ] = 0) do={ + /system/scheduler/add name=FlushTelegramQueue interval=1m start-time=startup \ on-event=(":global FlushTelegramQueue; \$FlushTelegramQueue;"); } } -- cgit v1.2.3-70-g09d2 From 2f46495be164e3ec8785ed7e25d2e4fe39c33d64 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 10 May 2022 16:14:02 +0200 Subject: mod/scriptrunonce: RouterOS v7 path syntax --- mod/scriptrunonce | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/scriptrunonce b/mod/scriptrunonce index 3e02236..6cca175 100644 --- a/mod/scriptrunonce +++ b/mod/scriptrunonce @@ -25,7 +25,7 @@ :local Source; :do { - :set Source ([ / tool fetch check-certificate=yes-without-crl $Script output=user as-value ]->"data"); + :set Source ([ /tool/fetch check-certificate=yes-without-crl $Script output=user as-value ]->"data"); } on-error={ $LogPrintExit2 warning $0 ("Failed fetching script '" . $Script . "'!") false; } -- cgit v1.2.3-70-g09d2