aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2022-05-12 11:03:06 +0200
committerGravatar Christian Hesse <mail@eworm.de>2022-05-12 11:03:06 +0200
commit48f0a2d21118a7bff7d598e84d9f606fb30bf07a (patch)
treefb9746502335552880823e9445cd4201414bb8eb /mod
parent93ec9afe558ef6eba5d513fab359bb5f6618666d (diff)
parenta71a3d5466548d05d27d31c446c62afdf2412070 (diff)
Merge branch 'scripts' into ros-v7-path-syntax
Diffstat (limited to 'mod')
-rw-r--r--mod/bridge-port-to16
-rw-r--r--mod/bridge-port-vlan18
-rw-r--r--mod/notification-matrix16
-rw-r--r--mod/notification-telegram16
-rw-r--r--mod/scriptrunonce2
5 files changed, 34 insertions, 34 deletions
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;
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;
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 . "<br/>" . $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;");
}
}
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;");
}
}
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;
}