From c33eb41c9cfb73e7e5b5ec7a3c37aa9e92ebc9cb Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 18 Dec 2024 17:50:56 +0100 Subject: [PATCH 001/291] global-functions: $DeviceInfo: add license level, re-order --- global-functions.rsc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index 42782bc..b3166dc 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -309,16 +309,19 @@ ([ $FormatLine "Location" ($Snmp->"location") ] . "\n") ] . \ [ $IfThenElse ([ :len ($Snmp->"contact") ] > 0) \ ([ $FormatLine "Contact" ($Snmp->"contact") ] . "\n") ] . \ - [ $FormatLine "Board name" ($Resource->"board-name") ] . "\n" . \ - [ $FormatLine "Architecture" ($Resource->"architecture-name") ] . "\n" . \ + "Hardware:\n" . \ + [ $FormatLine " Board" ($Resource->"board-name") ] . "\n" . \ + [ $FormatLine " Arch" ($Resource->"architecture-name") ] . "\n" . \ [ $IfThenElse ($RouterBoard->"routerboard" = true) \ - ([ $FormatLine "Model" ($RouterBoard->"model") ] . \ + ([ $FormatLine " Model" ($RouterBoard->"model") ] . \ [ $IfThenElse ([ :len ($RouterBoard->"revision") ] > 0) \ (" " . $RouterBoard->"revision") ] . "\n" . \ - [ $FormatLine "Serial number" ($RouterBoard->"serial-number") ] . "\n") ] . \ - [ $IfThenElse ([ :len ($License->"level") ] > 0) \ - ([ $FormatLine "License" ($License->"level") ] . "\n") ] . \ + [ $FormatLine " Serial" ($RouterBoard->"serial-number") ] . "\n") ] . \ + [ $IfThenElse ([ :len ($License->"nlevel") ] > 0) \ + ([ $FormatLine " License" ("level " . ($License->"nlevel")) ] . "\n") ] . \ "RouterOS:\n" . \ + [ $IfThenElse ([ :len ($License->"level") ] > 0) \ + ([ $FormatLine " License" ("level " . ($License->"level")) ] . "\n") ] . \ [ $FormatLine " Channel" ($Update->"channel") ] . "\n" . \ [ $FormatLine " Installed" ($Update->"installed-version") ] . "\n" . \ [ $IfThenElse ([ :typeof ($Update->"latest-version") ] != "nothing" && \ From 4eafcaa3ace2be0f17618c90c0d320647dfd8e38 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 25 Feb 2025 21:26:52 +0100 Subject: [PATCH 002/291] telegram-chat: say hello when awaiting commands --- telegram-chat.rsc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/telegram-chat.rsc b/telegram-chat.rsc index 07e3816..5db4860 100644 --- a/telegram-chat.rsc +++ b/telegram-chat.rsc @@ -119,7 +119,8 @@ $SendTelegram2 ({ origin=$ScriptName; chatid=($Chat->"id"); silent=true; \ replyto=($Message->"message_id"); threadid=$ThreadId; \ subject=([ $SymbolForNotification "speech-balloon" ] . "Telegram Chat"); \ - message=("Online" . [ $IfThenElse $TelegramChatActive " (and active!)" ] . ", awaiting your commands!") }); + message=([ $IfThenElse ([ :len ($From->"first_name") ] > 0) ("Hello " . ($From->"first_name") . "!\n\n") ] . \ + "Online" . [ $IfThenElse $TelegramChatActive " (and active!)" ] . ", awaiting your commands!") }); :set Done true; } :if ($Done = false && [ :pick $Command 0 1 ] = "!") do={ From 53b13b295af835658dc4ef6192624b2ae898bab1 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 25 Feb 2025 21:33:08 +0100 Subject: [PATCH 003/291] mod/notification-telegram: introduce $GetTelegramChatId --- .../notification-telegram.d/getchatid.avif | Bin 0 -> 3896 bytes doc/mod/notification-telegram.md | 24 ++++++++----- global-functions.rsc | 2 +- mod/notification-telegram.rsc | 34 ++++++++++++++++++ news-and-changes.rsc | 1 + 5 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 doc/mod/notification-telegram.d/getchatid.avif diff --git a/doc/mod/notification-telegram.d/getchatid.avif b/doc/mod/notification-telegram.d/getchatid.avif new file mode 100644 index 0000000000000000000000000000000000000000..779296915de91a9b21e2f05685e34a1539d9c73e GIT binary patch literal 3896 zcmbVJc|4Tw7Jp|9Gh>OdZ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@ -54,9 +61,10 @@ reload the configuration. ### Notifications to a group -Sending notifications to a group is possible as well. Add your bot and the -*GetIDs Bot* to a group, then use the group's id (which starts with a dash) -for `TelegramChatId`. Then remove *GetIDs Bot* from group. +Sending notifications to a group is possible as well. Add your bot to a group +and make it an admin (required for read access!) and send a message and run +`$GetTelegramChatId` again. Then use that chat id (which starts with a dash) +for `TelegramChatId`. Groups can enable the `Topics` feature. Use `TelegramThreadId` to send to a specific topic in a group. diff --git a/global-functions.rsc b/global-functions.rsc index b3166dc..43cd7f0 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -15,7 +15,7 @@ # Git commit id & info, expected configuration version :global CommitId "unknown"; :global CommitInfo "unknown"; -:global ExpectedConfigVersion 134; +:global ExpectedConfigVersion 135; # global variables not to be changed by user :global GlobalFunctionsReady false; diff --git a/mod/notification-telegram.rsc b/mod/notification-telegram.rsc index d04893f..7782fcf 100644 --- a/mod/notification-telegram.rsc +++ b/mod/notification-telegram.rsc @@ -10,6 +10,7 @@ # https://rsc.eworm.de/doc/mod/notification-telegram.md :global FlushTelegramQueue; +:global GetTelegramChatId; :global NotificationFunctions; :global PurgeTelegramQueue; :global SendTelegram; @@ -58,6 +59,39 @@ :global ExitError; $ExitError false $0; } } +# get the chat id +:set GetTelegramChatId do={ :do { + :global TelegramTokenId; + + :global CertificateAvailable; + :global LogPrint; + + :if ([ $CertificateAvailable "Go Daddy Root Certificate Authority - G2" ] = false) do={ + $LogPrint warning $0 ("Downloading required certificate failed."); + :return false; + } + + :local Data; + :do { + :set Data ([ /tool/fetch check-certificate=yes-without-crl output=user \ + ("https://api.telegram.org/bot" . $TelegramTokenId . "/getUpdates?offset=0" . \ + "&allowed_updates=%5B%22message%22%5D") as-value ]->"data"); + } on-error={ + $LogPrint warning $0 ("Fetching data failed!"); + :return false; + } + + :local JSON [ :deserialize from=json value=$Data ]; + :foreach Update in=($JSON->"result") do={ + $LogPrint info $0 ("The chat id is: " . ($Update->"message"->"chat"->"id")); + :return true; + } + + $LogPrint info $0 ("No message received."); +} on-error={ + :global ExitError; $ExitError false $0; +} } + # send notification via telegram - expects one array argument :set ($NotificationFunctions->"telegram") do={ :local Notification $1; diff --git a/news-and-changes.rsc b/news-and-changes.rsc index a735ff7..459326f 100644 --- a/news-and-changes.rsc +++ b/news-and-changes.rsc @@ -59,6 +59,7 @@ 132="Split off plugins from 'check-health', so the script works on all devices to monitor CPU and RAM. The supported plugins for sensors in hardware are installed automatically."; 133="Updated the default configuration for 'fw-addr-lists', deprecated lists were removed, a collective list was added."; 134="Enhanced 'mod/notification-telegram' and 'telegram-chat' to support topics in groups."; + 135="Introduced helper function '\$GetTelegramChatId' for 'mod/notification-telegram' which helps retrieve information."; }; # Migration steps to be applied on script updates From f6c2225f68fae8494d620dca0fc41b50a0450977 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 26 Feb 2025 13:37:57 +0100 Subject: [PATCH 004/291] check-certificates: catch and ignore import error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hmm... 🤨 When was that runtime error introduced? I *think* it worked before. --- check-certificates.rsc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/check-certificates.rsc b/check-certificates.rsc index 0907395..94f23a7 100644 --- a/check-certificates.rsc +++ b/check-certificates.rsc @@ -59,10 +59,12 @@ :local DecryptionFailed true; :foreach PassPhrase in=$CertRenewPass do={ - :local Result [ /certificate/import file-name=$CertFileName passphrase=$PassPhrase as-value ]; - :if ($Result->"decryption-failures" = 0) do={ - :set DecryptionFailed false; - } + :do { + :local Result [ /certificate/import file-name=$CertFileName passphrase=$PassPhrase as-value ]; + :if ($Result->"decryption-failures" = 0) do={ + :set DecryptionFailed false; + } + } on-error={ } } $RmFile $CertFileName; From a6d4e7e82cc9870c6cfd1e0ee9724eb6129ce5ab Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 26 Feb 2025 18:03:17 +0100 Subject: [PATCH 005/291] check-certificates: drop dot from type... ... and add it in file name. --- check-certificates.rsc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/check-certificates.rsc b/check-certificates.rsc index 94f23a7..20ac2e2 100644 --- a/check-certificates.rsc +++ b/check-certificates.rsc @@ -50,8 +50,8 @@ :local Return false; - :foreach Type in={ ".pem"; ".p12" } do={ - :local CertFileName ([ $UrlEncode $FetchName ] . $Type); + :foreach Type in={ "pem"; "p12" } do={ + :local CertFileName ([ $UrlEncode $FetchName ] . "." . $Type); :do { /tool/fetch check-certificate=yes-without-crl http-header-field=({ [ $FetchUserAgentStr $ScriptName ] }) \ ($CertRenewUrl . $CertFileName) dst-path=$CertFileName as-value; From 3d40b4419d47f41edf5059c00c1ab575f49c6da1 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 26 Feb 2025 13:40:12 +0100 Subject: [PATCH 006/291] check-certificates: add more debug output --- check-certificates.rsc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/check-certificates.rsc b/check-certificates.rsc index 20ac2e2..6862015 100644 --- a/check-certificates.rsc +++ b/check-certificates.rsc @@ -58,10 +58,12 @@ $WaitForFile $CertFileName; :local DecryptionFailed true; - :foreach PassPhrase in=$CertRenewPass do={ + :foreach I,PassPhrase in=$CertRenewPass do={ :do { + $LogPrint debug $ScriptName ("Trying " . $I . ". passphrase... "); :local Result [ /certificate/import file-name=$CertFileName passphrase=$PassPhrase as-value ]; :if ($Result->"decryption-failures" = 0) do={ + $LogPrint debug $ScriptName ("Success!"); :set DecryptionFailed false; } } on-error={ } From 512c54bd590503af27e754c5c65c34b5307cf9c9 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 26 Feb 2025 13:55:09 +0100 Subject: [PATCH 007/291] check-certificates: ... and even more --- check-certificates.rsc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/check-certificates.rsc b/check-certificates.rsc index 6862015..6dff9ba 100644 --- a/check-certificates.rsc +++ b/check-certificates.rsc @@ -52,6 +52,9 @@ :foreach Type in={ "pem"; "p12" } do={ :local CertFileName ([ $UrlEncode $FetchName ] . "." . $Type); + $LogPrint debug $ScriptName ("Trying type '" . $Type . "' for '" . $CertName . \ + "' (file '" . $CertFileName . "')..."); + :do { /tool/fetch check-certificate=yes-without-crl http-header-field=({ [ $FetchUserAgentStr $ScriptName ] }) \ ($CertRenewUrl . $CertFileName) dst-path=$CertFileName as-value; From e833dfcf25175fb1d5c652dcf898c6332ce70404 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 26 Feb 2025 13:51:25 +0100 Subject: [PATCH 008/291] check-certificates: simplify return from function... ... and also break earch on success. --- check-certificates.rsc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/check-certificates.rsc b/check-certificates.rsc index 6dff9ba..5065c33 100644 --- a/check-certificates.rsc +++ b/check-certificates.rsc @@ -48,8 +48,6 @@ :global UrlEncode; :global WaitForFile; - :local Return false; - :foreach Type in={ "pem"; "p12" } do={ :local CertFileName ([ $UrlEncode $FetchName ] . "." . $Type); $LogPrint debug $ScriptName ("Trying type '" . $Type . "' for '" . $CertName . \ @@ -84,13 +82,13 @@ $CertificateNameByCN [ /certificate/get $CertInChain common-name ]; } - :set Return true; + :return true; } on-error={ $LogPrint debug $ScriptName ("Could not download certificate file '" . $CertFileName . "'."); } } - :return $Return; + :return false; } :local FormatInfo do={ From 14195c51ca381063789ca58c760d70037328e600 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 26 Feb 2025 18:25:58 +0100 Subject: [PATCH 009/291] check-certificates: try PKCS#12 before PEM... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... as that is more likely to have a private key. Is that true? 🤨 --- check-certificates.rsc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check-certificates.rsc b/check-certificates.rsc index 5065c33..be8e4df 100644 --- a/check-certificates.rsc +++ b/check-certificates.rsc @@ -48,7 +48,7 @@ :global UrlEncode; :global WaitForFile; - :foreach Type in={ "pem"; "p12" } do={ + :foreach Type in={ "p12"; "pem" } do={ :local CertFileName ([ $UrlEncode $FetchName ] . "." . $Type); $LogPrint debug $ScriptName ("Trying type '" . $Type . "' for '" . $CertName . \ "' (file '" . $CertFileName . "')..."); From b11be59b0824efac6df128fde46a529ced14a2d0 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 27 Feb 2025 10:44:53 +0100 Subject: [PATCH 010/291] README: quote the certificate file name --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a76d50f..fae6986 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ file to your MikroTik device. Then we import the certificate. - /certificate/import file-name=isrg-root-x2.pem passphrase=""; + /certificate/import file-name="isrg-root-x2.pem" passphrase=""; Do not worry that the command is not shown - that happens because it contains a sensitive property, the passphrase. From e2fe653035ca2217dc56235de780f72dbb790e1d Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 26 Feb 2025 20:16:12 +0100 Subject: [PATCH 011/291] mod/notification-telegram: $GetTelegramChatId: use last message --- mod/notification-telegram.rsc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mod/notification-telegram.rsc b/mod/notification-telegram.rsc index 7782fcf..4528615 100644 --- a/mod/notification-telegram.rsc +++ b/mod/notification-telegram.rsc @@ -82,12 +82,15 @@ } :local JSON [ :deserialize from=json value=$Data ]; - :foreach Update in=($JSON->"result") do={ - $LogPrint info $0 ("The chat id is: " . ($Update->"message"->"chat"->"id")); - :return true; + :local Count [ :len ($JSON->"result") ]; + + :if ($Count = 0) do={ + $LogPrint info $0 ("No message received."); + :return false; } - $LogPrint info $0 ("No message received."); + :local Message ($JSON->"result"->($Count - 1)->"message"); + $LogPrint info $0 ("The chat id is: " . ($Message->"chat"->"id")); } on-error={ :global ExitError; $ExitError false $0; } } From f5189b8bd7ca01fb6e26414960764960a03066c4 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 27 Feb 2025 10:45:30 +0100 Subject: [PATCH 012/291] INITIAL-COMMANDS: quote the certificate file name --- INITIAL-COMMANDS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INITIAL-COMMANDS.md b/INITIAL-COMMANDS.md index 424ef32..8b64d28 100644 --- a/INITIAL-COMMANDS.md +++ b/INITIAL-COMMANDS.md @@ -19,7 +19,7 @@ Run the complete base installation: { /tool/fetch "https://git.eworm.de/cgit/routeros-scripts/plain/certs/ISRG-Root-X2.pem" dst-path="isrg-root-x2.pem" as-value; :delay 1s; - /certificate/import file-name=isrg-root-x2.pem passphrase=""; + /certificate/import file-name="isrg-root-x2.pem" passphrase=""; :if ([ :len [ /certificate/find where fingerprint="69729b8e15a86efc177a57afb7171dfc64add28c2fca8cf1507e34453ccb1470" ] ] != 1) do={ :error "Something is wrong with your certificates!"; }; From 0c4fb42616f8015dd128ec7df1d1afce590d26ed Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 26 Feb 2025 20:18:12 +0100 Subject: [PATCH 013/291] mod/notification-telegram: $GetTelegramChatId: give thead id... ... if message was sent to group's topic. --- mod/notification-telegram.rsc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mod/notification-telegram.rsc b/mod/notification-telegram.rsc index 4528615..68e913f 100644 --- a/mod/notification-telegram.rsc +++ b/mod/notification-telegram.rsc @@ -91,6 +91,9 @@ :local Message ($JSON->"result"->($Count - 1)->"message"); $LogPrint info $0 ("The chat id is: " . ($Message->"chat"->"id")); + :if (($Message->"is_topic_message") = true) do={ + $LogPrint info $0 ("The thread id is: " . ($Message->"message_thread_id")); + } } on-error={ :global ExitError; $ExitError false $0; } } From 33c02e06092eded4b3344a6eb22742c9be531fb2 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 3 Mar 2025 09:10:54 +0100 Subject: [PATCH 014/291] ipv6-update: ignore if prefix is no longer valid --- ipv6-update.rsc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ipv6-update.rsc b/ipv6-update.rsc index c6e3d65..beccde0 100644 --- a/ipv6-update.rsc +++ b/ipv6-update.rsc @@ -20,7 +20,9 @@ :global ScriptLock; :local NaAddress $"na-address"; + :local NaValid $"na-valid"; :local PdPrefix $"pd-prefix"; + :local PdValid $"pd-valid"; :if ([ $ScriptLock $ScriptName ] = false) do={ :set ExitOK true; @@ -39,6 +41,12 @@ :error false; } + :if ($PdValid != 1) do={ + $LogPrint info $ScriptName ("The prefix " . $PdPrefix . " is no longer valid. Ignoring."); + :set ExitOK true; + :error false; + } + :local Pool [ /ipv6/pool/get [ find where prefix=$PdPrefix ] name ]; :if ([ :len [ /ipv6/firewall/address-list/find where comment=("ipv6-pool-" . $Pool) ] ] = 0) do={ /ipv6/firewall/address-list/add list=("ipv6-pool-" . $Pool) address=:: comment=("ipv6-pool-" . $Pool) dynamic=yes; From 469f783a92c8e67088d70572157ff4cd7d47fcd8 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 3 Mar 2025 09:12:43 +0100 Subject: [PATCH 015/291] ipv6-update: check for availability of both variables --- ipv6-update.rsc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipv6-update.rsc b/ipv6-update.rsc index beccde0..94bd1bc 100644 --- a/ipv6-update.rsc +++ b/ipv6-update.rsc @@ -35,7 +35,7 @@ :error false; } - :if ([ :typeof $PdPrefix ] = "nothing") do={ + :if ([ :typeof $PdPrefix ] = "nothing" || [ :typeof $PdValid ] = "nothing") do={ $LogPrint error $ScriptName ("This script is supposed to run from ipv6 dhcp-client."); :set ExitOK true; :error false; From 3ccaafd1b38f4335aa28361778aa37db2ca22d5f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 5 Mar 2025 00:28:01 +0100 Subject: [PATCH 016/291] global-functions: $ScriptInstallUpdate: move code into block --- global-functions.rsc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index 43cd7f0..8fcd56d 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -1163,7 +1163,12 @@ } } - :if (!($ScriptInfo->"ignore" = true)) do={ + :do { + :if ($ScriptInfo->"ignore" = true) do={ + $LogPrint debug $0 ("Ignoring script '" . $ScriptVal->"name" . "', as requested."); + :error true; + } + :do { :local BaseUrl [ $EitherOr ($ScriptInfo->"base-url") $ScriptUpdatesBaseUrl ]; :local UrlSuffix [ $EitherOr ($ScriptInfo->"url-suffix") $ScriptUpdatesUrlSuffix ]; @@ -1182,10 +1187,9 @@ } else={ $LogPrint warning $0 ("Failed fetching script '" . $ScriptVal->"name" . "'!"); } + :error false; } - } - :do { :if ([ :len $SourceNew ] = 0) do={ $LogPrint debug $0 ("No update for script '" . $ScriptVal->"name" . "'."); :error false; From 0c1d96f89dfb4d209b0848d5ac2d81a640e0f056 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 5 Mar 2025 00:18:43 +0100 Subject: [PATCH 017/291] global-functions: $ScriptInstallUpdate: get and compare checksums MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The file 'checksums.json' is generated when deploying to my web server... This should speed up the update a lot as it reduces downloads to a minimum. 🎉😁 --- global-functions.rsc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/global-functions.rsc b/global-functions.rsc index 8fcd56d..8405c92 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -1150,6 +1150,14 @@ :local ReloadGlobalConfig false; :local DeviceMode [ /system/device-mode/get ]; + :local CheckSums ({}); + :do { + :local Url ($ScriptUpdatesBaseUrl . "checksums.json" . $ScriptUpdatesUrlSuffix); + $LogPrint debug $0 ("Fetching checksums from url: " . $Url); + :set CheckSums [ :deserialize from=json ([ /tool/fetch check-certificate=yes-without-crl \ + http-header-field=({ [ $FetchUserAgentStr $0 ] }) $Url output=user as-value ]->"data") ]; + } on-error={ } + :foreach Script in=[ /system/script/find where source~"^#!rsc by RouterOS\r?\n" ] do={ :local ScriptVal [ /system/script/get $Script ]; :local ScriptInfo [ $ParseKeyValueStore ($ScriptVal->"comment") ]; @@ -1169,6 +1177,11 @@ :error true; } + :if ([ :convert transform=md5 to=hex ($ScriptVal->"source") ] = ($CheckSums->($ScriptVal->"name"))) do={ + $LogPrint debug $0 ("Checksum for script '" . $ScriptVal->"name" . "' matches, ignoring."); + :error true; + } + :do { :local BaseUrl [ $EitherOr ($ScriptInfo->"base-url") $ScriptUpdatesBaseUrl ]; :local UrlSuffix [ $EitherOr ($ScriptInfo->"url-suffix") $ScriptUpdatesUrlSuffix ]; From 10374afc182cd8b08e07a3d45890518e8b6be73c Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 5 Mar 2025 01:37:42 +0100 Subject: [PATCH 018/291] global-functions: $ScriptInstallUpdate: support checksums for CRLF scripts --- global-functions.rsc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/global-functions.rsc b/global-functions.rsc index 8405c92..d883aa0 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -1177,7 +1177,8 @@ :error true; } - :if ([ :convert transform=md5 to=hex ($ScriptVal->"source") ] = ($CheckSums->($ScriptVal->"name"))) do={ + :if ([ :convert transform=md5 to=hex ($ScriptVal->"source") ] = ($CheckSums->($ScriptVal->"name")) || \ + [ :convert transform=md5 to=hex [ :tolf ($ScriptVal->"source") ] ] = ($CheckSums->($ScriptVal->"name"))) do={ $LogPrint debug $0 ("Checksum for script '" . $ScriptVal->"name" . "' matches, ignoring."); :error true; } From c9de6d85790897a945910316a14db16b0435c41e Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 5 Mar 2025 01:39:59 +0100 Subject: [PATCH 019/291] global-functions: $ScriptInstallUpdate: put checksum into variable --- global-functions.rsc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index d883aa0..a9fa938 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -1177,8 +1177,9 @@ :error true; } - :if ([ :convert transform=md5 to=hex ($ScriptVal->"source") ] = ($CheckSums->($ScriptVal->"name")) || \ - [ :convert transform=md5 to=hex [ :tolf ($ScriptVal->"source") ] ] = ($CheckSums->($ScriptVal->"name"))) do={ + :local CheckSum ($CheckSums->($ScriptVal->"name")); + :if ([ :convert transform=md5 to=hex ($ScriptVal->"source") ] = $CheckSum || \ + [ :convert transform=md5 to=hex [ :tolf ($ScriptVal->"source") ] ] = $CheckSum) do={ $LogPrint debug $0 ("Checksum for script '" . $ScriptVal->"name" . "' matches, ignoring."); :error true; } From b13360e4b86838d95cd8c9a1a4e2ea8d757dbb0f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 5 Mar 2025 01:53:04 +0100 Subject: [PATCH 020/291] global-functions: $ScriptInstallUpdate: simplify check This one should suffice... --- global-functions.rsc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index a9fa938..4c777a1 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -1178,8 +1178,7 @@ } :local CheckSum ($CheckSums->($ScriptVal->"name")); - :if ([ :convert transform=md5 to=hex ($ScriptVal->"source") ] = $CheckSum || \ - [ :convert transform=md5 to=hex [ :tolf ($ScriptVal->"source") ] ] = $CheckSum) do={ + :if ([ :convert transform=md5 to=hex [ :tolf ($ScriptVal->"source") ] ] = $CheckSum) do={ $LogPrint debug $0 ("Checksum for script '" . $ScriptVal->"name" . "' matches, ignoring."); :error true; } From 1b46a5fd9bc69f4d609b28e7ff8d36717a3b9a8f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 5 Mar 2025 08:55:06 +0100 Subject: [PATCH 021/291] global-functions: $ScriptInstallUpdate: checksum only for same source So ignore if script is fetched from different base or with different suffix. --- global-functions.rsc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/global-functions.rsc b/global-functions.rsc index 4c777a1..da31165 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -1178,7 +1178,8 @@ } :local CheckSum ($CheckSums->($ScriptVal->"name")); - :if ([ :convert transform=md5 to=hex [ :tolf ($ScriptVal->"source") ] ] = $CheckSum) do={ + :if ([ :len ($ScriptInfo->"base-url") ] = 0 && [ :len ($ScriptInfo->"url-suffix") ] = 0 && \ + [ :convert transform=md5 to=hex [ :tolf ($ScriptVal->"source") ] ] = $CheckSum) do={ $LogPrint debug $0 ("Checksum for script '" . $ScriptVal->"name" . "' matches, ignoring."); :error true; } From e341e1c30ca4ff8b87bc757cc5c0effbc50a7ea6 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 6 Mar 2025 15:02:31 +0100 Subject: [PATCH 022/291] global-functions: introduce $LogPrintVerbose ... ... which is a declared function, but has no code, intentionally. It can be called as a no-op by default. If you want this output set the function to be the same as $LogPrint: :set LogPrintVerbose $LogPrint; --- global-functions.rsc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/global-functions.rsc b/global-functions.rsc index da31165..911ff6a 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -55,6 +55,7 @@ :global IsTimeSync; :global LogPrint; :global LogPrintOnce; +:global LogPrintVerbose; :global MAX; :global MIN; :global MkDir; @@ -848,6 +849,8 @@ :return true; } +# The function $LogPrintVerbose is declared, but has no code, intentionally. + # get max value :set MAX do={ :if ($1 > $2) do={ :return $1; } From 6d718ec9877c3ecfc10681e85d050d15ed4d4b80 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 6 Mar 2025 14:38:35 +0100 Subject: [PATCH 023/291] fw-addr-lists: use $LogPrintVerbose ... ... to reduce debug output and speed up execution. --- fw-addr-lists.rsc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fw-addr-lists.rsc b/fw-addr-lists.rsc index d41dc04..af8c65d 100644 --- a/fw-addr-lists.rsc +++ b/fw-addr-lists.rsc @@ -24,6 +24,7 @@ :global HumanReadableNum; :global LogPrint; :global LogPrintOnce; + :global LogPrintVerbose; :global ScriptLock; :global WaitFullyConnected; @@ -120,14 +121,14 @@ list=$FwListName comment=$ListComment ] do={ :local Address [ /ip/firewall/address-list/get $Entry address ]; :if ([ :typeof ($IPv4Addresses->$Address) ] = "time") do={ - $LogPrint debug $ScriptName ("Renewing IPv4 address in list '" . $FwListName . \ + $LogPrintVerbose debug $ScriptName ("Renewing IPv4 address in list '" . $FwListName . \ "' with " . ($IPv4Addresses->$Address) . ": " . $Address); /ip/firewall/address-list/set $Entry timeout=($IPv4Addresses->$Address); :set ($IPv4Addresses->$Address); :set CntRenew ($CntRenew + 1); } else={ :if ($Failure = false) do={ - $LogPrint debug $ScriptName ("Removing IPv4 address from list '" . $FwListName . \ + $LogPrintVerbose debug $ScriptName ("Removing IPv4 address from list '" . $FwListName . \ "': " . $Address); /ip/firewall/address-list/remove $Entry; :set CntRemove ($CntRemove + 1); @@ -139,14 +140,14 @@ list=$FwListName comment=$ListComment ] do={ :local Address [ /ipv6/firewall/address-list/get $Entry address ]; :if ([ :typeof ($IPv6Addresses->$Address) ] = "time") do={ - $LogPrint debug $ScriptName ("Renewing IPv6 address in list '" . $FwListName . \ + $LogPrintVerbose debug $ScriptName ("Renewing IPv6 address in list '" . $FwListName . \ "' with " . ($IPv6Addresses->$Address) . ": " . $Address); /ipv6/firewall/address-list/set $Entry timeout=($IPv6Addresses->$Address); :set ($IPv6Addresses->$Address); :set CntRenew ($CntRenew + 1); } else={ :if ($Failure = false) do={ - $LogPrint debug $ScriptName ("Removing IPv6 address from list '" . $FwListName . \ + $LogPrintVerbose debug $ScriptName ("Removing IPv6 address from list '" . $FwListName . \ "': " . $Address); /ipv6/firewall/address-list/remove $Entry; :set CntRemove ($CntRemove + 1); @@ -155,7 +156,7 @@ } :foreach Address,Timeout in=$IPv4Addresses do={ - $LogPrint debug $ScriptName ("Adding IPv4 address to list '" . $FwListName . \ + $LogPrintVerbose debug $ScriptName ("Adding IPv4 address to list '" . $FwListName . \ "' with " . $Timeout . ": " . $Address); :do { /ip/firewall/address-list/add list=$FwListName comment=$ListComment \ @@ -169,7 +170,7 @@ } :foreach Address,Timeout in=$IPv6Addresses do={ - $LogPrint debug $ScriptName ("Adding IPv6 address to list '" . $FwListName . \ + $LogPrintVerbose debug $ScriptName ("Adding IPv6 address to list '" . $FwListName . \ "' with " . $Timeout . ": " . $Address); :do { /ipv6/firewall/address-list/add list=$FwListName comment=$ListComment \ From 7be26a07125b9c946859560bd59323f84feb9494 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 6 Mar 2025 14:54:38 +0100 Subject: [PATCH 024/291] DEBUG: add info on $LogPrintVerbose --- DEBUG.md | 14 ++++++++++++++ global-functions.rsc | 1 + 2 files changed, 15 insertions(+) diff --git a/DEBUG.md b/DEBUG.md index 3d7f025..d5e9beb 100644 --- a/DEBUG.md +++ b/DEBUG.md @@ -44,6 +44,20 @@ instead. Disable or remote that setting to restore regular logging. +## Verbose output + +Specific scripts can generate huge amount of output. These do use a function +`$LogPrintVerbose`, which is declared, but has no code, intentionally. + +If you *really* want that output set the function to be the same as +`$LogPrint`: + + :set LogPrintVerbose $LogPrint; + +To revert that change just run: + + :set LogPrintVerbose; + --- [âŦ…ī¸ Go back to main README](README.md) [âŦ†ī¸ Go back to top](#top) diff --git a/global-functions.rsc b/global-functions.rsc index 911ff6a..8ae7bb8 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -850,6 +850,7 @@ } # The function $LogPrintVerbose is declared, but has no code, intentionally. +# https://rsc.eworm.de/DEBUG.md#verbose-output # get max value :set MAX do={ From fb343c99e399d679f3e2a22e76c14a5899024319 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 6 Mar 2025 22:59:31 +0100 Subject: [PATCH 025/291] fw-addr-lists: put timeout into variable --- fw-addr-lists.rsc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/fw-addr-lists.rsc b/fw-addr-lists.rsc index af8c65d..331d2c6 100644 --- a/fw-addr-lists.rsc +++ b/fw-addr-lists.rsc @@ -120,10 +120,11 @@ :foreach Entry in=[ /ip/firewall/address-list/find where \ list=$FwListName comment=$ListComment ] do={ :local Address [ /ip/firewall/address-list/get $Entry address ]; - :if ([ :typeof ($IPv4Addresses->$Address) ] = "time") do={ + :local TimeOut ($IPv4Addresses->$Address); + :if ([ :typeof $TimeOut ] = "time") do={ $LogPrintVerbose debug $ScriptName ("Renewing IPv4 address in list '" . $FwListName . \ - "' with " . ($IPv4Addresses->$Address) . ": " . $Address); - /ip/firewall/address-list/set $Entry timeout=($IPv4Addresses->$Address); + "' with " . $TimeOut . ": " . $Address); + /ip/firewall/address-list/set $Entry timeout=$TimeOut; :set ($IPv4Addresses->$Address); :set CntRenew ($CntRenew + 1); } else={ @@ -139,10 +140,11 @@ :foreach Entry in=[ /ipv6/firewall/address-list/find where \ list=$FwListName comment=$ListComment ] do={ :local Address [ /ipv6/firewall/address-list/get $Entry address ]; - :if ([ :typeof ($IPv6Addresses->$Address) ] = "time") do={ + :local TimeOut ($IPv6Addresses->$Address); + :if ([ :typeof $TimeOut ] = "time") do={ $LogPrintVerbose debug $ScriptName ("Renewing IPv6 address in list '" . $FwListName . \ - "' with " . ($IPv6Addresses->$Address) . ": " . $Address); - /ipv6/firewall/address-list/set $Entry timeout=($IPv6Addresses->$Address); + "' with " . $TimeOut . ": " . $Address); + /ipv6/firewall/address-list/set $Entry timeout=$TimeOut; :set ($IPv6Addresses->$Address); :set CntRenew ($CntRenew + 1); } else={ From ea6de35699a5b62dfffcc583c1a7181e1a6a688f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 6 Mar 2025 23:00:50 +0100 Subject: [PATCH 026/291] fw-addr-lists: do not clean up Cleanup is important on renew (so the script does not attempt to re-add), but we do not care here. --- fw-addr-lists.rsc | 2 -- 1 file changed, 2 deletions(-) diff --git a/fw-addr-lists.rsc b/fw-addr-lists.rsc index 331d2c6..70893e3 100644 --- a/fw-addr-lists.rsc +++ b/fw-addr-lists.rsc @@ -163,7 +163,6 @@ :do { /ip/firewall/address-list/add list=$FwListName comment=$ListComment \ address=$Address timeout=$Timeout; - :set ($IPv4Addresses->$Address); :set CntAdd ($CntAdd + 1); } on-error={ $LogPrint warning $ScriptName ("Failed to add IPv4 address to list '" . $FwListName . \ @@ -177,7 +176,6 @@ :do { /ipv6/firewall/address-list/add list=$FwListName comment=$ListComment \ address=$Address timeout=$Timeout; - :set ($IPv6Addresses->$Address); :set CntAdd ($CntAdd + 1); } on-error={ $LogPrint warning $ScriptName ("Failed to add IPv6 address to list '" . $FwListName . \ From 2f55bfaf009d726e1174b50887fdb8f9b4b57573 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 7 Mar 2025 12:21:22 +0100 Subject: [PATCH 027/291] fw-addr-lists: strip cidr for host addresses This makes sure the addresses match later when we read them from address-list for renew. --- fw-addr-lists.rsc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fw-addr-lists.rsc b/fw-addr-lists.rsc index 70893e3..fc53795 100644 --- a/fw-addr-lists.rsc +++ b/fw-addr-lists.rsc @@ -101,10 +101,16 @@ } :do { :if ($Address ~ "^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}(/[0-9]{1,2})?\$") do={ + :if ($Address ~ "/32\$") do={ + :set Address [ :pick $Address 0 ([ :len $Address ] - 3) ]; + } :set ($IPv4Addresses->$Address) $TimeOut; :error true; } :if ($Address ~ "^[0-9a-zA-Z]*:[0-9a-zA-Z:\\.]+(/[0-9]{1,3})?\$") do={ + :if ($Address ~ "/128\$") do={ + :set Address [ :pick $Address 0 ([ :len $Address ] - 4) ]; + } :set ($IPv6Addresses->$Address) $TimeOut; :error true; } From e148df9e573801803e35d8dfaef277f571952fdc Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 6 Mar 2025 23:05:45 +0100 Subject: [PATCH 028/291] fw-addr-lists: put addresses into "branches"... ... effectively adding another layer and some complexity, but: The addresses are sorted inside the array, and sorting less addresses in a branch saves a lot of processing power. So this is a lot faster now... --- fw-addr-lists.rsc | 65 +++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/fw-addr-lists.rsc b/fw-addr-lists.rsc index fc53795..a97f7ed 100644 --- a/fw-addr-lists.rsc +++ b/fw-addr-lists.rsc @@ -100,23 +100,24 @@ :set Address ([ :pick $Line 0 [ $FindDelim $Line ] ] . ($List->"cidr")); } :do { + :local Branch [ :pick $Address 0 1 ]; :if ($Address ~ "^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}(/[0-9]{1,2})?\$") do={ :if ($Address ~ "/32\$") do={ :set Address [ :pick $Address 0 ([ :len $Address ] - 3) ]; } - :set ($IPv4Addresses->$Address) $TimeOut; + :set ($IPv4Addresses->$Branch->$Address) $TimeOut; :error true; } :if ($Address ~ "^[0-9a-zA-Z]*:[0-9a-zA-Z:\\.]+(/[0-9]{1,3})?\$") do={ :if ($Address ~ "/128\$") do={ :set Address [ :pick $Address 0 ([ :len $Address ] - 4) ]; } - :set ($IPv6Addresses->$Address) $TimeOut; + :set ($IPv6Addresses->$Branch->$Address) $TimeOut; :error true; } :if ($Address ~ "^[\\.a-zA-Z0-9-]+\\.[a-zA-Z]{2,}\$") do={ - :set ($IPv4Addresses->$Address) $TimeOut; - :set ($IPv6Addresses->$Address) $TimeOut; + :set ($IPv4Addresses->$Branch->$Address) $TimeOut; + :set ($IPv6Addresses->$Branch->$Address) $TimeOut; :error true; } } on-error={ } @@ -126,12 +127,13 @@ :foreach Entry in=[ /ip/firewall/address-list/find where \ list=$FwListName comment=$ListComment ] do={ :local Address [ /ip/firewall/address-list/get $Entry address ]; - :local TimeOut ($IPv4Addresses->$Address); + :local Branch [ :pick $Address 0 1 ]; + :local TimeOut ($IPv4Addresses->$Branch->$Address); :if ([ :typeof $TimeOut ] = "time") do={ $LogPrintVerbose debug $ScriptName ("Renewing IPv4 address in list '" . $FwListName . \ "' with " . $TimeOut . ": " . $Address); /ip/firewall/address-list/set $Entry timeout=$TimeOut; - :set ($IPv4Addresses->$Address); + :set ($IPv4Addresses->$Branch->$Address); :set CntRenew ($CntRenew + 1); } else={ :if ($Failure = false) do={ @@ -146,12 +148,13 @@ :foreach Entry in=[ /ipv6/firewall/address-list/find where \ list=$FwListName comment=$ListComment ] do={ :local Address [ /ipv6/firewall/address-list/get $Entry address ]; - :local TimeOut ($IPv6Addresses->$Address); + :local Branch [ :pick $Address 0 1 ]; + :local TimeOut ($IPv6Addresses->$Branch->$Address); :if ([ :typeof $TimeOut ] = "time") do={ $LogPrintVerbose debug $ScriptName ("Renewing IPv6 address in list '" . $FwListName . \ "' with " . $TimeOut . ": " . $Address); /ipv6/firewall/address-list/set $Entry timeout=$TimeOut; - :set ($IPv6Addresses->$Address); + :set ($IPv6Addresses->$Branch->$Address); :set CntRenew ($CntRenew + 1); } else={ :if ($Failure = false) do={ @@ -163,29 +166,35 @@ } } - :foreach Address,Timeout in=$IPv4Addresses do={ - $LogPrintVerbose debug $ScriptName ("Adding IPv4 address to list '" . $FwListName . \ - "' with " . $Timeout . ": " . $Address); - :do { - /ip/firewall/address-list/add list=$FwListName comment=$ListComment \ - address=$Address timeout=$Timeout; - :set CntAdd ($CntAdd + 1); - } on-error={ - $LogPrint warning $ScriptName ("Failed to add IPv4 address to list '" . $FwListName . \ - "': " . $Address); + :foreach BranchName,Branch in=$IPv4Addresses do={ + $LogPrintVerbose debug $ScriptName ("Handling branch: " . $BranchName); + :foreach Address,Timeout in=$Branch do={ + $LogPrintVerbose debug $ScriptName ("Adding IPv4 address to list '" . $FwListName . \ + "' with " . $Timeout . ": " . $Address); + :do { + /ip/firewall/address-list/add list=$FwListName comment=$ListComment \ + address=$Address timeout=$Timeout; + :set CntAdd ($CntAdd + 1); + } on-error={ + $LogPrint warning $ScriptName ("Failed to add IPv4 address to list '" . $FwListName . \ + "': " . $Address); + } } } - :foreach Address,Timeout in=$IPv6Addresses do={ - $LogPrintVerbose debug $ScriptName ("Adding IPv6 address to list '" . $FwListName . \ - "' with " . $Timeout . ": " . $Address); - :do { - /ipv6/firewall/address-list/add list=$FwListName comment=$ListComment \ - address=$Address timeout=$Timeout; - :set CntAdd ($CntAdd + 1); - } on-error={ - $LogPrint warning $ScriptName ("Failed to add IPv6 address to list '" . $FwListName . \ - "': " . $Address); + :foreach BranchName,Branch in=$IPv6Addresses do={ + $LogPrintVerbose debug $ScriptName ("Handling branch: " . $BranchName); + :foreach Address,Timeout in=$Branch do={ + $LogPrintVerbose debug $ScriptName ("Adding IPv6 address to list '" . $FwListName . \ + "' with " . $Timeout . ": " . $Address); + :do { + /ipv6/firewall/address-list/add list=$FwListName comment=$ListComment \ + address=$Address timeout=$Timeout; + :set CntAdd ($CntAdd + 1); + } on-error={ + $LogPrint warning $ScriptName ("Failed to add IPv6 address to list '" . $FwListName . \ + "': " . $Address); + } } } From d71ea804b077d35183df318fb305b213fb961d27 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 7 Mar 2025 20:35:36 +0100 Subject: [PATCH 029/291] fw-addr-lists: two characters for branch Using one character for IPv4 is ok (1 to 9), but IPv6 global unicase (2000::/3) results in just two different characters (2 and 3). So let's use first two characters... --- fw-addr-lists.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fw-addr-lists.rsc b/fw-addr-lists.rsc index a97f7ed..9ad5b3a 100644 --- a/fw-addr-lists.rsc +++ b/fw-addr-lists.rsc @@ -100,7 +100,7 @@ :set Address ([ :pick $Line 0 [ $FindDelim $Line ] ] . ($List->"cidr")); } :do { - :local Branch [ :pick $Address 0 1 ]; + :local Branch [ :pick $Address 0 2 ]; :if ($Address ~ "^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}(/[0-9]{1,2})?\$") do={ :if ($Address ~ "/32\$") do={ :set Address [ :pick $Address 0 ([ :len $Address ] - 3) ]; @@ -127,7 +127,7 @@ :foreach Entry in=[ /ip/firewall/address-list/find where \ list=$FwListName comment=$ListComment ] do={ :local Address [ /ip/firewall/address-list/get $Entry address ]; - :local Branch [ :pick $Address 0 1 ]; + :local Branch [ :pick $Address 0 2 ]; :local TimeOut ($IPv4Addresses->$Branch->$Address); :if ([ :typeof $TimeOut ] = "time") do={ $LogPrintVerbose debug $ScriptName ("Renewing IPv4 address in list '" . $FwListName . \ @@ -148,7 +148,7 @@ :foreach Entry in=[ /ipv6/firewall/address-list/find where \ list=$FwListName comment=$ListComment ] do={ :local Address [ /ipv6/firewall/address-list/get $Entry address ]; - :local Branch [ :pick $Address 0 1 ]; + :local Branch [ :pick $Address 0 2 ]; :local TimeOut ($IPv6Addresses->$Branch->$Address); :if ([ :typeof $TimeOut ] = "time") do={ $LogPrintVerbose debug $ScriptName ("Renewing IPv6 address in list '" . $FwListName . \ From f0e6cbcfe1a0be05f30d37cd495d4dbea0888f07 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Sat, 8 Mar 2025 10:09:51 +0100 Subject: [PATCH 030/291] fw-addr-lists: get branch from calculated checksum The addresses were spread very uneven before. Let's calculate a checksum, and take the first two characters of that. The addresses are now spread evenly on 256 branches (0x00 to 0xff). --- fw-addr-lists.rsc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fw-addr-lists.rsc b/fw-addr-lists.rsc index 9ad5b3a..f0940fe 100644 --- a/fw-addr-lists.rsc +++ b/fw-addr-lists.rsc @@ -37,6 +37,11 @@ } } + :local GetBranch do={ + :global EitherOr; + :return [ :pick [ :convert transform=md5 to=hex [ :pick $1 0 [ $EitherOr [ :find $1 "/" ] [ :len $1 ] ] ] ] 0 2 ]; + } + :if ([ $ScriptLock $ScriptName ] = false) do={ :set ExitOK true; :error false; @@ -100,7 +105,7 @@ :set Address ([ :pick $Line 0 [ $FindDelim $Line ] ] . ($List->"cidr")); } :do { - :local Branch [ :pick $Address 0 2 ]; + :local Branch [ $GetBranch $Address ]; :if ($Address ~ "^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}(/[0-9]{1,2})?\$") do={ :if ($Address ~ "/32\$") do={ :set Address [ :pick $Address 0 ([ :len $Address ] - 3) ]; @@ -127,7 +132,7 @@ :foreach Entry in=[ /ip/firewall/address-list/find where \ list=$FwListName comment=$ListComment ] do={ :local Address [ /ip/firewall/address-list/get $Entry address ]; - :local Branch [ :pick $Address 0 2 ]; + :local Branch [ $GetBranch $Address ]; :local TimeOut ($IPv4Addresses->$Branch->$Address); :if ([ :typeof $TimeOut ] = "time") do={ $LogPrintVerbose debug $ScriptName ("Renewing IPv4 address in list '" . $FwListName . \ @@ -148,7 +153,7 @@ :foreach Entry in=[ /ipv6/firewall/address-list/find where \ list=$FwListName comment=$ListComment ] do={ :local Address [ /ipv6/firewall/address-list/get $Entry address ]; - :local Branch [ :pick $Address 0 2 ]; + :local Branch [ $GetBranch $Address ]; :local TimeOut ($IPv6Addresses->$Branch->$Address); :if ([ :typeof $TimeOut ] = "time") do={ $LogPrintVerbose debug $ScriptName ("Renewing IPv6 address in list '" . $FwListName . \ From eb59dd21caf8026748eada3aee137b8e3b6590b7 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 7 Mar 2025 17:33:51 +0100 Subject: [PATCH 031/291] check-routeros-update: check perpetual license... ... as these have to be renewed and can expire. --- check-routeros-update.rsc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/check-routeros-update.rsc b/check-routeros-update.rsc index 361be34..8d200d2 100644 --- a/check-routeros-update.rsc +++ b/check-routeros-update.rsc @@ -66,6 +66,27 @@ :error "A reboot for update is already scheduled."; } + :local License [ /system/license/get ]; + :if ([ :typeof ($License->"deadline-at") ] = "str") do={ + :if ([ :len ($License->"next-renewal-at") ] = 0 && ($License->"limited-upgrades") = true) do={ + $LogPrint warning $ScriptName ("Your license expired on " . ($License->"deadline-at") . "!"); + $SendNotification2 ({ origin=$ScriptName; \ + subject=([ $SymbolForNotification "warning-sign" ] . "License expired!"); \ + message=("Your license expired on " . ($License->"deadline-at") . \ + ", can no longer update RouterOS on " . $Identity . "...") }); + :set ExitOK true; + :error false; + } + + :if ([ :totime ($License->"next-renewal-at") ] + 1w < [ :timestamp ]) do={ + $LogPrint warning $ScriptName ("Your license will expire on " . ($License->"deadline-at") . "!"); + $SendNotification2 ({ origin=$ScriptName; \ + subject=([ $SymbolForNotification "warning-sign" ] . "License about to expire!"); \ + message=("Your license failed to renew and is about to expire on " . \ + ($License->"deadline-at") . " on " . $Identity . "...") }); + } + } + $LogPrint debug $ScriptName ("Checking for updates..."); /system/package/update/check-for-updates without-paging as-value; :local Update [ /system/package/update/get ]; From 788400c4586b6a2e61c6e36acd10ab5d20da00c9 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 10 Mar 2025 16:29:06 +0100 Subject: [PATCH 032/291] fw-addr-lists: raw.githubusercontent.com requires 'USERTrust RSA Certification Authority' now --- certs/Makefile | 2 +- .../USERTrust-RSA-Certification-Authority.pem | 41 +++++++++++++++++++ global-config.rsc | 2 +- 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 certs/USERTrust-RSA-Certification-Authority.pem diff --git a/certs/Makefile b/certs/Makefile index 4e252b4..3ccad6e 100644 --- a/certs/Makefile +++ b/certs/Makefile @@ -15,7 +15,7 @@ DOMAINS_DUAL = \ git.eworm.de/ISRG-Root-X2 \ lists.blocklist.de/Certum-Trusted-Network-CA \ matrix.org/GTS-Root-R4 \ - raw.githubusercontent.com/DigiCert-Global-Root-G2 \ + raw.githubusercontent.com/USERTrust-RSA-Certification-Authority \ rsc.eworm.de/ISRG-Root-X2 \ upgrade.mikrotik.com/ISRG-Root-X1 DOMAINS_IPV4 = \ diff --git a/certs/USERTrust-RSA-Certification-Authority.pem b/certs/USERTrust-RSA-Certification-Authority.pem new file mode 100644 index 0000000..0fbeef6 --- /dev/null +++ b/certs/USERTrust-RSA-Certification-Authority.pem @@ -0,0 +1,41 @@ +# Issuer: CN=USERTrust RSA Certification Authority O=The USERTRUST Network +# Subject: CN=USERTrust RSA Certification Authority O=The USERTRUST Network +# Label: "USERTrust RSA Certification Authority" +# Serial: 2645093764781058787591871645665788717 +# MD5 Fingerprint: 1b:fe:69:d1:91:b7:19:33:a3:72:a8:0f:e1:55:e5:b5 +# SHA1 Fingerprint: 2b:8f:1b:57:33:0d:bb:a2:d0:7a:6c:51:f7:0e:e9:0d:da:b9:ad:8e +# SHA256 Fingerprint: e7:93:c9:b0:2f:d8:aa:13:e2:1c:31:22:8a:cc:b0:81:19:64:3b:74:9c:89:89:64:b1:74:6d:46:c3:d4:cb:d2 +-----BEGIN CERTIFICATE----- +MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCB +iDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0pl +cnNleSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNV +BAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAw +MjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMCVVMxEzARBgNV +BAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU +aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2Vy +dGlmaWNhdGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIK +AoICAQCAEmUXNg7D2wiz0KxXDXbtzSfTTK1Qg2HiqiBNCS1kCdzOiZ/MPans9s/B +3PHTsdZ7NygRK0faOca8Ohm0X6a9fZ2jY0K2dvKpOyuR+OJv0OwWIJAJPuLodMkY +tJHUYmTbf6MG8YgYapAiPLz+E/CHFHv25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gZ +XHlKYC6SQK5MNyosycdiyA5d9zZbyuAlJQG03RoHnHcAP9Dc1ew91Pq7P8yF1m9/ +qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9cJ2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRB +VXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGwsAvgnEzDHNb842m1R0aB +L6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gxQ+6IHdfG +jjxDah2nGN59PRbxYvnKkKj9 +-----END CERTIFICATE----- diff --git a/global-config.rsc b/global-config.rsc index 2524ded..fa32b16 100644 --- a/global-config.rsc +++ b/global-config.rsc @@ -103,7 +103,7 @@ # cert="ISRG Root X2" }; { url="https://raw.githubusercontent.com/stamparm/ipsum/refs/heads/master/levels/4.txt"; # # higher level (decrease the numerical value) for more addresses, and vice versa - cert="DigiCert Global Root G2" }; + cert="USERTrust RSA Certification Authority" }; { url="https://www.dshield.org/block.txt"; cidr="/24"; cert="ISRG Root X1" }; { url="https://lists.blocklist.de/lists/strongips.txt"; From 97b99316b2f96fa9c5d2f539e31aa308e86c99b4 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 12 Mar 2025 10:31:11 +0100 Subject: [PATCH 033/291] netwatch-notify: increase timeout... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... as a timeout of one second expires immediately. 🤨 --- netwatch-notify.rsc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netwatch-notify.rsc b/netwatch-notify.rsc index 8b05c5e..9a4c9d9 100644 --- a/netwatch-notify.rsc +++ b/netwatch-notify.rsc @@ -61,12 +61,12 @@ :global GetRandom20CharAlNum; :local FwAddrList ($ScriptName . "-" . [ $GetRandom20CharAlNum ]); - /ip/firewall/address-list/add address=$Name list=$FwAddrList dynamic=yes timeout=1s; + /ip/firewall/address-list/add address=$Name list=$FwAddrList dynamic=yes timeout=2s; :delay 20ms; :if ([ :len [ /ip/firewall/address-list/find where list=$FwAddrList address=$Expected ] ] > 0) do={ :return true; } - /ipv6/firewall/address-list/add address=$Name list=$FwAddrList dynamic=yes timeout=1s; + /ipv6/firewall/address-list/add address=$Name list=$FwAddrList dynamic=yes timeout=2s; :delay 20ms; :if ([ :len [ /ipv6/firewall/address-list/find where list=$FwAddrList address=$Expected ] ] > 0) do={ :return true; From 155542668719f9feaac45fdb786b2e5fc5fd1e71 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 12 Mar 2025 11:18:18 +0100 Subject: [PATCH 034/291] netwatch-notify: increase the timeout even more MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This interacts with the number of addresses in the address-list. Having a lot of addresses there (for exemple from script 'fw-addr-lists' 😜) makes the 'find' take longer. We have to make sure that 'find' succeeds before the address times out. As this does not hurt... Let's just bump to 10 seconds to be safe. --- netwatch-notify.rsc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netwatch-notify.rsc b/netwatch-notify.rsc index 9a4c9d9..2a5050c 100644 --- a/netwatch-notify.rsc +++ b/netwatch-notify.rsc @@ -61,12 +61,12 @@ :global GetRandom20CharAlNum; :local FwAddrList ($ScriptName . "-" . [ $GetRandom20CharAlNum ]); - /ip/firewall/address-list/add address=$Name list=$FwAddrList dynamic=yes timeout=2s; + /ip/firewall/address-list/add address=$Name list=$FwAddrList dynamic=yes timeout=10s; :delay 20ms; :if ([ :len [ /ip/firewall/address-list/find where list=$FwAddrList address=$Expected ] ] > 0) do={ :return true; } - /ipv6/firewall/address-list/add address=$Name list=$FwAddrList dynamic=yes timeout=2s; + /ipv6/firewall/address-list/add address=$Name list=$FwAddrList dynamic=yes timeout=10s; :delay 20ms; :if ([ :len [ /ipv6/firewall/address-list/find where list=$FwAddrList address=$Expected ] ] > 0) do={ :return true; From b63e0fcb2fc282ac69cbef74b35bd40e8df5a464 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 12 Mar 2025 11:26:22 +0100 Subject: [PATCH 035/291] netwatch-notify: check matching address type only --- netwatch-notify.rsc | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/netwatch-notify.rsc b/netwatch-notify.rsc index 2a5050c..0b8a8dc 100644 --- a/netwatch-notify.rsc +++ b/netwatch-notify.rsc @@ -61,15 +61,19 @@ :global GetRandom20CharAlNum; :local FwAddrList ($ScriptName . "-" . [ $GetRandom20CharAlNum ]); - /ip/firewall/address-list/add address=$Name list=$FwAddrList dynamic=yes timeout=10s; - :delay 20ms; - :if ([ :len [ /ip/firewall/address-list/find where list=$FwAddrList address=$Expected ] ] > 0) do={ - :return true; + :if ([ :typeof [ :toip $Expected ] ] = "ip") do={ + /ip/firewall/address-list/add address=$Name list=$FwAddrList dynamic=yes timeout=10s; + :delay 20ms; + :if ([ :len [ /ip/firewall/address-list/find where list=$FwAddrList address=$Expected ] ] > 0) do={ + :return true; + } } - /ipv6/firewall/address-list/add address=$Name list=$FwAddrList dynamic=yes timeout=10s; - :delay 20ms; - :if ([ :len [ /ipv6/firewall/address-list/find where list=$FwAddrList address=$Expected ] ] > 0) do={ - :return true; + :if ([ :typeof [ :toip6 $Expected ] ] = "ip6") do={ + /ipv6/firewall/address-list/add address=$Name list=$FwAddrList dynamic=yes timeout=10s; + :delay 20ms; + :if ([ :len [ /ipv6/firewall/address-list/find where list=$FwAddrList address=$Expected ] ] > 0) do={ + :return true; + } } :return false; From 20bf609c44c2b4111bb387b36b955b8c3243fbf1 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 13 Mar 2025 10:51:39 +0100 Subject: [PATCH 036/291] check-routeros-update: fix condition for license check Turns out that `next-renewal-at` is moved forward when renewal failed, so it never matches the criteria. Just start complaining three weeks before deadline. --- check-routeros-update.rsc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check-routeros-update.rsc b/check-routeros-update.rsc index 8d200d2..78161e4 100644 --- a/check-routeros-update.rsc +++ b/check-routeros-update.rsc @@ -78,7 +78,7 @@ :error false; } - :if ([ :totime ($License->"next-renewal-at") ] + 1w < [ :timestamp ]) do={ + :if ([ :totime ($License->"deadline-at") ] - 3w < [ :timestamp ]) do={ $LogPrint warning $ScriptName ("Your license will expire on " . ($License->"deadline-at") . "!"); $SendNotification2 ({ origin=$ScriptName; \ subject=([ $SymbolForNotification "warning-sign" ] . "License about to expire!"); \ From ce39b79f69f978a8de521643b07b9c19de02b06f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 13 Mar 2025 11:50:38 +0100 Subject: [PATCH 037/291] capsman-download-packages: fix parameter for $RmFile The function can not handle ids, we have to pass a name instead. --- capsman-download-packages.capsman.rsc | 2 +- capsman-download-packages.template.rsc | 2 +- capsman-download-packages.wifi.rsc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/capsman-download-packages.capsman.rsc b/capsman-download-packages.capsman.rsc index 4387cb1..25c43f5 100644 --- a/capsman-download-packages.capsman.rsc +++ b/capsman-download-packages.capsman.rsc @@ -62,7 +62,7 @@ :if ([ $DownloadPackage ($File->"package-name") $InstalledVersion \ ($File->"package-architecture") $PackagePath ] = true) do={ :set Updated true; - $RmFile $Package; + $RmFile ($File->"name"); } } diff --git a/capsman-download-packages.template.rsc b/capsman-download-packages.template.rsc index 744494e..b269838 100644 --- a/capsman-download-packages.template.rsc +++ b/capsman-download-packages.template.rsc @@ -64,7 +64,7 @@ :if ([ $DownloadPackage ($File->"package-name") $InstalledVersion \ ($File->"package-architecture") $PackagePath ] = true) do={ :set Updated true; - $RmFile $Package; + $RmFile ($File->"name"); } } diff --git a/capsman-download-packages.wifi.rsc b/capsman-download-packages.wifi.rsc index a0c5e12..901bb0a 100644 --- a/capsman-download-packages.wifi.rsc +++ b/capsman-download-packages.wifi.rsc @@ -62,7 +62,7 @@ :if ([ $DownloadPackage ($File->"package-name") $InstalledVersion \ ($File->"package-architecture") $PackagePath ] = true) do={ :set Updated true; - $RmFile $Package; + $RmFile ($File->"name"); } } From f8c3659f6a329498b7aea5ff7f4b67ae1ef727df Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 26 Mar 2025 09:19:02 +0100 Subject: [PATCH 038/291] support creating the checksums file --- .gitignore | 3 +++ Makefile | 7 +++++-- contrib/checksums.sh | 9 +++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100755 contrib/checksums.sh diff --git a/.gitignore b/.gitignore index cf89f87..8abdc28 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,8 @@ # html files (as generated from markdown) *.html +# checksums file as used by $ScriptInstallUpdate +checksums.json + # Mac OS X folder settings file .DS_Store diff --git a/Makefile b/Makefile index d21713c..8951741 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ WIFI = $(wildcard *.wifi.rsc) MARKDOWN = $(wildcard *.md doc/*.md doc/mod/*.md) HTML = $(MARKDOWN:.md=.html) -all: $(CAPSMAN) $(LOCAL) $(WIFI) $(HTML) +all: $(CAPSMAN) $(LOCAL) $(WIFI) $(HTML) checksums.json %.html: %.md Makefile markdown $< | sed 's/href="\([-_\./[:alnum:]]*\)\.md"/href="\1.html"/g' > $@ @@ -32,5 +32,8 @@ all: $(CAPSMAN) $(LOCAL) $(WIFI) $(HTML) -e '/^# !!/,/^# !!/c # !! Do not edit this file, it is generated from template!' \ < $< > $@ +checksums.json: contrib/checksums.sh *.rsc */*.rsc + contrib/checksums.sh + clean: - rm -f $(HTML) + rm -f $(HTML) checksums.json diff --git a/contrib/checksums.sh b/contrib/checksums.sh new file mode 100755 index 0000000..b472b49 --- /dev/null +++ b/contrib/checksums.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# generate a checksums file as used by $ScriptInstallUpdate + +set -e + +md5sum $(find -name '*.rsc' | sort) | \ + sed -e "s| \./||" -e 's|.rsc$||' | \ + jq --raw-input --null-input '[ inputs | split (" ") | { (.[1]): (.[0]) }] | add' > 'checksums.json' From 690951469291ae96ead1f88226be78ec7735d098 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 20 Mar 2025 09:48:01 +0100 Subject: [PATCH 039/291] check-routeros-update: send certificate warning just once... ... and another one once expired. --- check-routeros-update.rsc | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/check-routeros-update.rsc b/check-routeros-update.rsc index 78161e4..51df175 100644 --- a/check-routeros-update.rsc +++ b/check-routeros-update.rsc @@ -22,6 +22,7 @@ :global SafeUpdateNeighborIdentity; :global SafeUpdatePatch; :global SafeUpdateUrl; + :global SentCertificateNotification; :global SentRouterosUpdateNotification; :global DeviceInfo; @@ -70,20 +71,26 @@ :if ([ :typeof ($License->"deadline-at") ] = "str") do={ :if ([ :len ($License->"next-renewal-at") ] = 0 && ($License->"limited-upgrades") = true) do={ $LogPrint warning $ScriptName ("Your license expired on " . ($License->"deadline-at") . "!"); - $SendNotification2 ({ origin=$ScriptName; \ - subject=([ $SymbolForNotification "warning-sign" ] . "License expired!"); \ - message=("Your license expired on " . ($License->"deadline-at") . \ - ", can no longer update RouterOS on " . $Identity . "...") }); + :if ($SentCertificateNotification != "expired") do={ + $SendNotification2 ({ origin=$ScriptName; \ + subject=([ $SymbolForNotification "warning-sign" ] . "License expired!"); \ + message=("Your license expired on " . ($License->"deadline-at") . \ + ", can no longer update RouterOS on " . $Identity . "...") }); + :set SentCertificateNotification "expired"; + } :set ExitOK true; :error false; } :if ([ :totime ($License->"deadline-at") ] - 3w < [ :timestamp ]) do={ $LogPrint warning $ScriptName ("Your license will expire on " . ($License->"deadline-at") . "!"); - $SendNotification2 ({ origin=$ScriptName; \ - subject=([ $SymbolForNotification "warning-sign" ] . "License about to expire!"); \ - message=("Your license failed to renew and is about to expire on " . \ - ($License->"deadline-at") . " on " . $Identity . "...") }); + :if ($SentCertificateNotification != "warning") do={ + $SendNotification2 ({ origin=$ScriptName; \ + subject=([ $SymbolForNotification "warning-sign" ] . "License about to expire!"); \ + message=("Your license failed to renew and is about to expire on " . \ + ($License->"deadline-at") . " on " . $Identity . "...") }); + :set SentCertificateNotification "warning"; + } } } From 16c9ce437ef268780303f627bba08a166e2aef05 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 24 Mar 2025 21:14:12 +0100 Subject: [PATCH 040/291] check-routeros-update: send notification on renewed license... ... when a warning has been sent before. --- check-routeros-update.rsc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/check-routeros-update.rsc b/check-routeros-update.rsc index 51df175..1a5a930 100644 --- a/check-routeros-update.rsc +++ b/check-routeros-update.rsc @@ -92,6 +92,16 @@ :set SentCertificateNotification "warning"; } } + + :if ([ :typeof $SentCertificateNotification ] = "str" && \ + [ :totime ($License->"deadline-at") ] - 4w > [ :timestamp ]) do={ + $LogPrint info $ScriptName ("Your license was successfully renewed."); + $SendNotification2 ({ origin=$ScriptName; \ + subject=([ $SymbolForNotification "white-heavy-check-mark" ] . "License renewed"); \ + message=("Your license was successfully renewed on " . $Identity . \ + ". It is now valid until " . ($License->"deadline-at") . ".") }); + :set SentCertificateNotification; + } } $LogPrint debug $ScriptName ("Checking for updates..."); From 3c30276e235b6c8105f44db49ba6586d296f264c Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 25 Mar 2025 17:54:09 +0100 Subject: [PATCH 041/291] check-routeros-update: split off check-perpetual-license... ... and also add documentation, screenshot, etc. --- README.md | 1 + check-perpetual-license.rsc | 78 ++++++++++++++++++ check-routeros-update.rsc | 38 --------- .../notification.avif | Bin 0 -> 4004 bytes doc/check-perpetual-license.md | 70 ++++++++++++++++ doc/check-routeros-update.md | 1 + global-functions.rsc | 2 +- news-and-changes.rsc | 1 + 8 files changed, 152 insertions(+), 39 deletions(-) create mode 100644 check-perpetual-license.rsc create mode 100644 doc/check-perpetual-license.d/notification.avif create mode 100644 doc/check-perpetual-license.md diff --git a/README.md b/README.md index fae6986..ffbc27e 100644 --- a/README.md +++ b/README.md @@ -225,6 +225,7 @@ Available scripts * [Renew certificates and notify on expiration](doc/check-certificates.md) * [Notify about health state](doc/check-health.md) * [Notify on LTE firmware upgrade](doc/check-lte-firmware-upgrade.md) +* [Check perpetual license on CHR](doc/check-perpetual-license.md) * [Notify on RouterOS update](doc/check-routeros-update.md) * [Collect MAC addresses in wireless access list](doc/collect-wireless-mac.md) * [Use wireless network with daily psk](doc/daily-psk.md) diff --git a/check-perpetual-license.rsc b/check-perpetual-license.rsc new file mode 100644 index 0000000..9a3a3c7 --- /dev/null +++ b/check-perpetual-license.rsc @@ -0,0 +1,78 @@ +#!rsc by RouterOS +# RouterOS script: check-perpetual-license +# Copyright (c) 2025 Christian Hesse +# https://rsc.eworm.de/COPYING.md +# +# requires RouterOS, version=7.15 +# +# check perpetual license on CHR +# https://rsc.eworm.de/doc/check-perpetual-license.md + +:global GlobalFunctionsReady; +:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } + +:local ExitOK false; +:do { + :local ScriptName [ :jobname ]; + + :global Identity; + :global SentCertificateNotification; + + :global LogPrint; + :global ScriptLock; + :global SendNotification2; + :global SymbolForNotification; + :global WaitFullyConnected; + + :if ([ $ScriptLock $ScriptName ] = false) do={ + :set ExitOK true; + :error false; + } + + $WaitFullyConnected; + + :local License [ /system/license/get ]; + :if ([ :typeof ($License->"deadline-at") ] != "str") do={ + $LogPrint info $ScriptName ("This device does not have a perpetual license."); + :set ExitOK true; + :error true; + } + + :if ([ :len ($License->"next-renewal-at") ] = 0 && ($License->"limited-upgrades") = true) do={ + $LogPrint warning $ScriptName ("Your license expired on " . ($License->"deadline-at") . "!"); + :if ($SentCertificateNotification != "expired") do={ + $SendNotification2 ({ origin=$ScriptName; \ + subject=([ $SymbolForNotification "warning-sign" ] . "License expired!"); \ + message=("Your license expired on " . ($License->"deadline-at") . \ + ", can no longer update RouterOS on " . $Identity . "...") }); + :set SentCertificateNotification "expired"; + } + :set ExitOK true; + :error true; + } + + :if ([ :totime ($License->"deadline-at") ] - 3w < [ :timestamp ]) do={ + $LogPrint warning $ScriptName ("Your license will expire on " . ($License->"deadline-at") . "!"); + :if ($SentCertificateNotification != "warning") do={ + $SendNotification2 ({ origin=$ScriptName; \ + subject=([ $SymbolForNotification "warning-sign" ] . "License about to expire!"); \ + message=("Your license failed to renew and is about to expire on " . \ + ($License->"deadline-at") . " on " . $Identity . "...") }); + :set SentCertificateNotification "warning"; + } + :set ExitOK true; + :error true; + } + + :if ([ :typeof $SentCertificateNotification ] = "str" && \ + [ :totime ($License->"deadline-at") ] - 4w > [ :timestamp ]) do={ + $LogPrint info $ScriptName ("Your license was successfully renewed."); + $SendNotification2 ({ origin=$ScriptName; \ + subject=([ $SymbolForNotification "white-heavy-check-mark" ] . "License renewed"); \ + message=("Your license was successfully renewed on " . $Identity . \ + ". It is now valid until " . ($License->"deadline-at") . ".") }); + :set SentCertificateNotification; + } +} on-error={ + :global ExitError; $ExitError $ExitOK [ :jobname ]; +} diff --git a/check-routeros-update.rsc b/check-routeros-update.rsc index 1a5a930..361be34 100644 --- a/check-routeros-update.rsc +++ b/check-routeros-update.rsc @@ -22,7 +22,6 @@ :global SafeUpdateNeighborIdentity; :global SafeUpdatePatch; :global SafeUpdateUrl; - :global SentCertificateNotification; :global SentRouterosUpdateNotification; :global DeviceInfo; @@ -67,43 +66,6 @@ :error "A reboot for update is already scheduled."; } - :local License [ /system/license/get ]; - :if ([ :typeof ($License->"deadline-at") ] = "str") do={ - :if ([ :len ($License->"next-renewal-at") ] = 0 && ($License->"limited-upgrades") = true) do={ - $LogPrint warning $ScriptName ("Your license expired on " . ($License->"deadline-at") . "!"); - :if ($SentCertificateNotification != "expired") do={ - $SendNotification2 ({ origin=$ScriptName; \ - subject=([ $SymbolForNotification "warning-sign" ] . "License expired!"); \ - message=("Your license expired on " . ($License->"deadline-at") . \ - ", can no longer update RouterOS on " . $Identity . "...") }); - :set SentCertificateNotification "expired"; - } - :set ExitOK true; - :error false; - } - - :if ([ :totime ($License->"deadline-at") ] - 3w < [ :timestamp ]) do={ - $LogPrint warning $ScriptName ("Your license will expire on " . ($License->"deadline-at") . "!"); - :if ($SentCertificateNotification != "warning") do={ - $SendNotification2 ({ origin=$ScriptName; \ - subject=([ $SymbolForNotification "warning-sign" ] . "License about to expire!"); \ - message=("Your license failed to renew and is about to expire on " . \ - ($License->"deadline-at") . " on " . $Identity . "...") }); - :set SentCertificateNotification "warning"; - } - } - - :if ([ :typeof $SentCertificateNotification ] = "str" && \ - [ :totime ($License->"deadline-at") ] - 4w > [ :timestamp ]) do={ - $LogPrint info $ScriptName ("Your license was successfully renewed."); - $SendNotification2 ({ origin=$ScriptName; \ - subject=([ $SymbolForNotification "white-heavy-check-mark" ] . "License renewed"); \ - message=("Your license was successfully renewed on " . $Identity . \ - ". It is now valid until " . ($License->"deadline-at") . ".") }); - :set SentCertificateNotification; - } - } - $LogPrint debug $ScriptName ("Checking for updates..."); /system/package/update/check-for-updates without-paging as-value; :local Update [ /system/package/update/get ]; diff --git a/doc/check-perpetual-license.d/notification.avif b/doc/check-perpetual-license.d/notification.avif new file mode 100644 index 0000000000000000000000000000000000000000..70ca603d4488773dd8a476ced8c89506407b95ef GIT binary patch literal 4004 zcmXv|2RIw-_l;3O&5GIDd(WUXW7n!t)U1dVgos(CV(-xsReOFY9agOxwW2mb5u4Ah znyu}x-~ajD_j&F)_nh;*_W}R_4rkvNNT@&D8E{*F5dn9WM8KiW1`tWet+a!1@`e8O zZi~~^(F67W6aYZNVZQ(4|3fMy+!yiRKycgH;2vJEzmo<4Kyds1b^rk#06_KnmJ7h) zp8qZV&tbV8oCyDhZ!=JT2}yM?53m1rxxtYrn{j z9ti)d5RsCS-U0>GUs64cdEfSgR8x9mY82WP>!R2ZwiBO%_i2%bGt{47fuukwgHzx=7AMdpKZnlEZ` z^M}mKpP7W8tpDS2b4Bi7kI}PVaXbutwF7v}HF;7>em+=1mh}2`^PWV69LUV2UpE)% z8pzT`TtjRywZT`UEPkj8_A5uZHp-4Rb-CQ=tgkSyj!$2(fP3mmKY~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#s&21s_PPy8~ zKjZGHz1glF<1saAQCOJTmlF?aUrJ(7(XlXoC|N7zA*v|$?n(H!Fo*Ke*dnjTU>;q_ zXGUTJPP)%jTcb*zGw(Z6 zVLmoyyiq+S+dY5t0{@yZZ9# zB|C?^RrO&aPl@S1q1nBnf2h*VB*1hZzsok6>oCna2G1)Q;}m z%b~mkiy=`+=&lxyth2W<{1mGD%sWGZqn~WUb2eu7MxsML04lCd9JO`f7p=6l~ uFTg~BM)@t;-^nj$GT^KwS2A~)^GONIsT;umQg#QOlZCQm7Z%VRb^IUVQDuMt literal 0 HcmV?d00001 diff --git a/doc/check-perpetual-license.md b/doc/check-perpetual-license.md new file mode 100644 index 0000000..d444004 --- /dev/null +++ b/doc/check-perpetual-license.md @@ -0,0 +1,70 @@ +Check perpetual license on CHR +============================== + +[![GitHub stars](https://img.shields.io/github/stars/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=red)](https://github.com/eworm-de/routeros-scripts/stargazers) +[![GitHub forks](https://img.shields.io/github/forks/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=green)](https://github.com/eworm-de/routeros-scripts/network) +[![GitHub watchers](https://img.shields.io/github/watchers/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=blue)](https://github.com/eworm-de/routeros-scripts/watchers) +[![required RouterOS version](https://img.shields.io/badge/RouterOS-7.15-yellow?style=flat)](https://mikrotik.com/download/changelogs/) +[![Telegram group @routeros_scripts](https://img.shields.io/badge/Telegram-%40routeros__scripts-%2326A5E4?logo=telegram&style=flat)](https://t.me/routeros_scripts) +[![donate with PayPal](https://img.shields.io/badge/Like_it%3F-Donate!-orange?logo=githubsponsors&logoColor=orange&style=flat)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J) + +[âŦ…ī¸ Go back to main README](../README.md) + +> â„šī¸ **Info**: This script can not be used on its own but requires the base +> installation. See [main README](../README.md) for details. + +Description +----------- + +On *Cloud Hosted Router* (*CHR*) the licensing is perpetual: Buy once, use +forever - but it needs regular renewal. This script checks licensing state +and sends a notification to warn before expiration. + +### Sample notification + +![check-perpetual-license notification](check-perpetual-license.d/notification.avif) + +Requirements and installation +----------------------------- + +Just install the script: + + $ScriptInstallUpdate check-perpetual-license; + +And add a scheduler for automatic update notification: + + /system/scheduler/add interval=1d name=check-perpetual-license on-event="/system/script/run check-perpetual-license;" start-time=startup; + +Configuration +------------- + +No extra configuration is required for this script, but notification +settings are required for +[e-mail](mod/notification-email.md), +[matrix](mod/notification-matrix.md), +[ntfy](mod/notification-ntfy.md) and/or +[telegram](mod/notification-telegram.md). + +Usage and invocation +-------------------- + +Be notified when run from scheduler or run it manually: + + /system/script/run check-perpetual-license; + +Tips & Tricks +------------- + +The script checks for full connectivity before acting, so scheduling at +startup is perfectly valid: + + /system/scheduler/add name=check-perpetual-license@startup on-event="/system/script/run check-perpetual-license;" start-time=startup; + +See also +-------- + +* [Notify on RouterOS update](check-routeros-update.md) + +--- +[âŦ…ī¸ Go back to main README](../README.md) +[âŦ†ī¸ Go back to top](#top) diff --git a/doc/check-routeros-update.md b/doc/check-routeros-update.md index 926b4aa..b6c716c 100644 --- a/doc/check-routeros-update.md +++ b/doc/check-routeros-update.md @@ -99,6 +99,7 @@ startup is perfectly valid: See also -------- +* [Check perpetual license on CHR](check-perpetual-license.md) * [Automatically upgrade firmware and reboot](firmware-upgrade-reboot.md) * [Manage system update](packages-update.md) diff --git a/global-functions.rsc b/global-functions.rsc index 8ae7bb8..8ade79b 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -15,7 +15,7 @@ # Git commit id & info, expected configuration version :global CommitId "unknown"; :global CommitInfo "unknown"; -:global ExpectedConfigVersion 135; +:global ExpectedConfigVersion 136; # global variables not to be changed by user :global GlobalFunctionsReady false; diff --git a/news-and-changes.rsc b/news-and-changes.rsc index 459326f..55b4165 100644 --- a/news-and-changes.rsc +++ b/news-and-changes.rsc @@ -60,6 +60,7 @@ 133="Updated the default configuration for 'fw-addr-lists', deprecated lists were removed, a collective list was added."; 134="Enhanced 'mod/notification-telegram' and 'telegram-chat' to support topics in groups."; 135="Introduced helper function '\$GetTelegramChatId' for 'mod/notification-telegram' which helps retrieve information."; + 136="Introduced script 'check-perpetual-license' to check for license state on CHR."; }; # Migration steps to be applied on script updates From cdfb086b490cafd685e947433515e43dc5547a62 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 31 Mar 2025 11:19:23 +0200 Subject: [PATCH 042/291] mod/notification-telegram: fix override quirk IDs for chat and thread can be overridden. Overriding the chat probably makes the thread invalid - so ignore that then. --- mod/notification-telegram.rsc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mod/notification-telegram.rsc b/mod/notification-telegram.rsc index 68e913f..5ef353b 100644 --- a/mod/notification-telegram.rsc +++ b/mod/notification-telegram.rsc @@ -151,7 +151,8 @@ :local ChatId [ $EitherOr ($Notification->"chatid") \ [ $EitherOr ($TelegramChatIdOverride->($Notification->"origin")) $TelegramChatId ] ]; :local ThreadId [ $EitherOr ($Notification->"threadid") \ - [ $EitherOr ($TelegramThreadIdOverride->($Notification->"origin")) $TelegramThreadId ] ]; + [ $EitherOr ($TelegramThreadIdOverride->($Notification->"origin")) \ + [ $IfThenElse ([ :len ($TelegramChatIdOverride->($Notification->"origin")) ] = 0) $TelegramThreadId ] ] ]; :local TokenId [ $EitherOr ($TelegramTokenIdOverride->($Notification->"origin")) $TelegramTokenId ]; :if ([ :len $TokenId ] = 0 || [ :len $ChatId ] = 0) do={ From b560ea4b7d3da75b5f54633eea6a5fb7472d5bd6 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 31 Mar 2025 14:30:56 +0200 Subject: [PATCH 043/291] logo: strip some bytes... ... by just re-compressing/re-encoding. --- logo.avif | Bin 2001 -> 1744 bytes logo.png | Bin 4428 -> 4406 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/logo.avif b/logo.avif index 399a2f5ad184fabd7e8127b1e2f1bd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{T)DW-J%@itZwAb9O^$=uvMIaevq>;J74z^Z;uH- zAH1Wjy`6ip`MXG5)ZfcNrpj@{)!dng@0D{X;ur_11tz~{hP$XZ30i$s;Z!kggN&eI n`TvM#^~|0f20sd{ZG+{%@%@>)@_Tfh00000NkvXXu0mjfd3Z1? From 2cc47f56b95b36eb73ed9bbe3e74f28b4f37dccd Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 2 Apr 2025 11:32:24 +0200 Subject: [PATCH 044/291] README: give the script names --- README.md | 102 +++++++++++++++++++++++++++--------------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index ffbc27e..1f7c8ed 100644 --- a/README.md +++ b/README.md @@ -214,61 +214,61 @@ There's much more to explore... Have fun! Available scripts ----------------- -* [Find and remove access list duplicates](doc/accesslist-duplicates.md) -* [Upload backup to Mikrotik cloud](doc/backup-cloud.md) -* [Send backup via e-mail](doc/backup-email.md) -* [Save configuration to fallback partition](doc/backup-partition.md) -* [Upload backup to server](doc/backup-upload.md) -* [Download packages for CAP upgrade from CAPsMAN](doc/capsman-download-packages.md) -* [Run rolling CAP upgrades from CAPsMAN](doc/capsman-rolling-upgrade.md) -* [Renew locally issued certificates](doc/certificate-renew-issued.md) -* [Renew certificates and notify on expiration](doc/check-certificates.md) -* [Notify about health state](doc/check-health.md) -* [Notify on LTE firmware upgrade](doc/check-lte-firmware-upgrade.md) -* [Check perpetual license on CHR](doc/check-perpetual-license.md) -* [Notify on RouterOS update](doc/check-routeros-update.md) -* [Collect MAC addresses in wireless access list](doc/collect-wireless-mac.md) -* [Use wireless network with daily psk](doc/daily-psk.md) -* [Comment DHCP leases with info from access list](doc/dhcp-lease-comment.md) -* [Create DNS records for DHCP leases](doc/dhcp-to-dns.md) -* [Automatically upgrade firmware and reboot](doc/firmware-upgrade-reboot.md) -* [Download, import and update firewall address-lists](doc/fw-addr-lists.md) -* [Wait for global functions und modules](doc/global-wait.md) -* [Send GPS position to server](doc/gps-track.md) -* [Use WPA network with hotspot credentials](doc/hotspot-to-wpa.md) -* [Create DNS records for IPSec peers](doc/ipsec-to-dns.md) -* [Update configuration on IPv6 prefix change](doc/ipv6-update.md) -* [Manage IP addresses with bridge status](doc/ip-addr-bridge.md) -* [Run other scripts on DHCP lease](doc/lease-script.md) -* [Manage LEDs dark mode](doc/leds-mode.md) -* [Forward log messages via notification](doc/log-forward.md) -* [Mode button with multiple presses](doc/mode-button.md) -* [Manage DNS and DoH servers from netwatch](doc/netwatch-dns.md) -* [Notify on host up and down](doc/netwatch-notify.md) -* [Visualize OSPF state via LEDs](doc/ospf-to-leds.md) -* [Manage system update](doc/packages-update.md) -* [Run scripts on ppp connection](doc/ppp-on-up.md) -* [Act on received SMS](doc/sms-action.md) -* [Forward received SMS](doc/sms-forward.md) -* [Play Super Mario theme](doc/super-mario-theme.md) -* [Chat with your router and send commands via Telegram bot](doc/telegram-chat.md) -* [Install LTE firmware upgrade](doc/unattended-lte-firmware-upgrade.md) -* [Update GRE configuration with dynamic addresses](doc/update-gre-address.md) -* [Update tunnelbroker configuration](doc/update-tunnelbroker.md) +* [Find and remove access list duplicates](doc/accesslist-duplicates.md) (`accesslist-duplicates`) +* [Upload backup to Mikrotik cloud](doc/backup-cloud.md) (`backup-cloud`) +* [Send backup via e-mail](doc/backup-email.md) (`backup-email`) +* [Save configuration to fallback partition](doc/backup-partition.md) (`backup-partition`) +* [Upload backup to server](doc/backup-upload.md) (`backup-upload`) +* [Download packages for CAP upgrade from CAPsMAN](doc/capsman-download-packages.md) (`capsman-download-packages`) +* [Run rolling CAP upgrades from CAPsMAN](doc/capsman-rolling-upgrade.md) (`capsman-rolling-upgrade`) +* [Renew locally issued certificates](doc/certificate-renew-issued.md) (`certificate-renew-issued`) +* [Renew certificates and notify on expiration](doc/check-certificates.md) (`check-certificates`) +* [Notify about health state](doc/check-health.md) (`check-health`) +* [Notify on LTE firmware upgrade](doc/check-lte-firmware-upgrade.md) (`check-lte-firmware-upgrade`) +* [Check perpetual license on CHR](doc/check-perpetual-license.md) (`check-perpetual-license`) +* [Notify on RouterOS update](doc/check-routeros-update.md) (`check-routeros-update`) +* [Collect MAC addresses in wireless access list](doc/collect-wireless-mac.md) (`collect-wireless-mac`) +* [Use wireless network with daily psk](doc/daily-psk.md) (`daily-psk`) +* [Comment DHCP leases with info from access list](doc/dhcp-lease-comment.md) (`dhcp-lease-comment`) +* [Create DNS records for DHCP leases](doc/dhcp-to-dns.md) (`dhcp-to-dns`) +* [Automatically upgrade firmware and reboot](doc/firmware-upgrade-reboot.md) (`firmware-upgrade-reboot`) +* [Download, import and update firewall address-lists](doc/fw-addr-lists.md) (`fw-addr-lists`) +* [Wait for global functions und modules](doc/global-wait.md) (`global-wait`) +* [Send GPS position to server](doc/gps-track.md) (`gps-track`) +* [Use WPA network with hotspot credentials](doc/hotspot-to-wpa.md) (`hotspot-to-wpa` & `hotspot-to-wpa-cleanup`) +* [Create DNS records for IPSec peers](doc/ipsec-to-dns.md) (`ipsec-to-dns`) +* [Update configuration on IPv6 prefix change](doc/ipv6-update.md) (`ipv6-update`) +* [Manage IP addresses with bridge status](doc/ip-addr-bridge.md) (`ip-addr-bridge`) +* [Run other scripts on DHCP lease](doc/lease-script.md) (`lease-script`) +* [Manage LEDs dark mode](doc/leds-mode.md) (`leds-day-mode`, `leds-night-mode` & `leds-toggle-mode`) +* [Forward log messages via notification](doc/log-forward.md) (`log-forward`) +* [Mode button with multiple presses](doc/mode-button.md) (`mode-button`) +* [Manage DNS and DoH servers from netwatch](doc/netwatch-dns.md) (`netwatch-dns`) +* [Notify on host up and down](doc/netwatch-notify.md) (`netwatch-notify`) +* [Visualize OSPF state via LEDs](doc/ospf-to-leds.md) (`ospf-to-leds`) +* [Manage system update](doc/packages-update.md) (`packages-update`) +* [Run scripts on ppp connection](doc/ppp-on-up.md) (`ppp-on-up`) +* [Act on received SMS](doc/sms-action.md) (`sms-action`) +* [Forward received SMS](doc/sms-forward.md) (`sms-forward`) +* [Play Super Mario theme](doc/super-mario-theme.md) (`super-mario-theme`) +* [Chat with your router and send commands via Telegram bot](doc/telegram-chat.md) (`telegram-chat`) +* [Install LTE firmware upgrade](doc/unattended-lte-firmware-upgrade.md) (`unattended-lte-firmware-upgrade`) +* [Update GRE configuration with dynamic addresses](doc/update-gre-address.md) (`update-gre-address`) +* [Update tunnelbroker configuration](doc/update-tunnelbroker.md) (`update-tunnelbroker`) Available modules ----------------- -* [Manage ports in bridge](doc/mod/bridge-port-to.md) -* [Manage VLANs on bridge ports](doc/mod/bridge-port-vlan.md) -* [Inspect variables](doc/mod/inspectvar.md) -* [IP address calculation](doc/mod/ipcalc.md) -* [Send notifications via e-mail](doc/mod/notification-email.md) -* [Send notifications via Matrix](doc/mod/notification-matrix.md) -* [Send notifications via Ntfy](doc/mod/notification-ntfy.md) -* [Send notifications via Telegram](doc/mod/notification-telegram.md) -* [Download script and run it once](doc/mod/scriptrunonce.md) -* [Import ssh keys for public key authentication](doc/mod/ssh-keys-import.md) +* [Manage ports in bridge](doc/mod/bridge-port-to.md) (`mod/bridge-port-to`) +* [Manage VLANs on bridge ports](doc/mod/bridge-port-vlan.md) (`mod/bridge-port-vlan`) +* [Inspect variables](doc/mod/inspectvar.md) (`mod/inspectvar`) +* [IP address calculation](doc/mod/ipcalc.md) (`mod/ipcalc`) +* [Send notifications via e-mail](doc/mod/notification-email.md) (`mod/notification-email`) +* [Send notifications via Matrix](doc/mod/notification-matrix.md) (`mod/notification-matrix`) +* [Send notifications via Ntfy](doc/mod/notification-ntfy.md) (`mod/notification-ntfy`) +* [Send notifications via Telegram](doc/mod/notification-telegram.md) (`mod/notification-telegram`) +* [Download script and run it once](doc/mod/scriptrunonce.md) (`mod/scriptrunonce`) +* [Import ssh keys for public key authentication](doc/mod/ssh-keys-import.md) (`mod/ssh-keys-import`) Installing custom scripts & modules ----------------------------------- From 27987a0d7cf54343aa15ee9dd23f7006b323bf2a Mon Sep 17 00:00:00 2001 From: Ilya Kulakov Date: Mon, 7 Apr 2025 11:27:22 +0200 Subject: [PATCH 045/291] global-functions: $ScriptLock: fix second parameter This broke with 1e8918fdaa5a30393e2004d1f5e4dff458936b67... Fixes: https://github.com/eworm-de/routeros-scripts/issues/95 --- global-functions.rsc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global-functions.rsc b/global-functions.rsc index 8ade79b..d666122 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -1388,7 +1388,7 @@ # lock script against multiple invocation :set ScriptLock do={ :local Script [ :tostr $1 ]; - :local WaitMax ([ :tonum $3 ] * 10); + :local WaitMax ([ :tonum $2 ] * 10); :global GetRandom20CharAlNum; :global IfThenElse; From 67e7b11aa7def03e69ff9135653039eed220c619 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 8 Apr 2025 09:13:20 +0200 Subject: [PATCH 046/291] update list of contributors --- CONTRIBUTIONS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTIONS.md b/CONTRIBUTIONS.md index 0b35c40..55d2205 100644 --- a/CONTRIBUTIONS.md +++ b/CONTRIBUTIONS.md @@ -21,6 +21,7 @@ for details! * [Ben Harris](mailto:mail@bharr.is) (@bharrisau) * [Daniel Ziegenberg](mailto:daniel@ziegenberg.at) (@ziegenberg) * [Ignacio Serrano](mailto:ignic@ignic.com) (@ignic) +* [Ilya Kulakov](mailto:kulakov.ilya@gmail.com) (@Kentzo) * [Michael Gisbers](mailto:michael@gisbers.de) (@mgisbers) * [Miquel Bonastre](mailto:mbonastre@yahoo.com) (@mbonastre) * @netravnen From 314ba5796d05591ec4781b72222b95c9c8590928 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 8 Apr 2025 09:41:25 +0200 Subject: [PATCH 047/291] global-functions: $ScriptLock: increase interval with wait time Inspired by: https://github.com/eworm-de/routeros-scripts/issues/95#issuecomment-2773513467 --- global-functions.rsc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index d666122..d488c0f 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -1387,8 +1387,8 @@ # lock script against multiple invocation :set ScriptLock do={ - :local Script [ :tostr $1 ]; - :local WaitMax ([ :tonum $2 ] * 10); + :local Script [ :tostr $1 ]; + :local WaitMax [ :totime $2 ]; :global GetRandom20CharAlNum; :global IfThenElse; @@ -1477,6 +1477,10 @@ :set ($ScriptLockOrder->$Script) ({}); } + :if ([ :typeof $WaitMax ] = "nil" ) do={ + :set WaitMax 0s; + } + :if ([ :len [ /system/script/find where name=$Script ] ] = 0) do={ $LogPrint error $0 ("A script named '" . $Script . "' does not exist!"); :error false; @@ -1496,12 +1500,13 @@ :local MyTicket [ $GetRandom20CharAlNum 6 ]; $AddTicket $Script $MyTicket; - :local WaitCount 0; - :while ($WaitMax > $WaitCount && \ + :local WaitInterval ($WaitMax / 20); + :local WaitTime $WaitMax; + :while ($WaitTime > 0 && \ ([ $IsFirstTicket $Script $MyTicket ] = false || \ [ $TicketCount $Script ] < [ $JobCount $Script ])) do={ - :set WaitCount ($WaitCount + 1); - :delay 100ms; + :set WaitTime ($WaitTime - $WaitInterval); + :delay $WaitInterval; } :if ([ $IsFirstTicket $Script $MyTicket ] = true && \ @@ -1513,7 +1518,7 @@ $RemoveTicket $Script $MyTicket; $LogPrint debug $0 ("Script '" . $Script . "' started more than once" . \ - [ $IfThenElse ($WaitCount > 0) " and timed out waiting for lock" "" ] . "..."); + [ $IfThenElse ($WaitTime < $WaitMax) " and timed out waiting for lock" "" ] . "..."); :return false; } From 019e10e1903e261ed1629a1db6ff2d64257916aa Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 7 Apr 2025 13:44:53 +0200 Subject: [PATCH 048/291] global-functions: $CertificateDownload: no infinite loop We can not call $CertificateAvailable here, as that will most likely cause an infinite loop. After all that's the certificate mkcert.org is using. And it *is* available in this repository. --- global-functions.rsc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index d488c0f..30374aa 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -167,8 +167,8 @@ $LogPrint warning $0 ("Failed downloading certificate with CommonName '" . $CommonName . \ "' from repository! Trying fallback to mkcert.org..."); :do { - :if ([ $CertificateAvailable "ISRG Root X1" ] = false) do={ - $LogPrint error $0 ("Downloading required certificate failed."); + :if ([ :len [ /certificate/find where common-name="ISRG Root X1" ] ] = 0) do={ + $LogPrint error $0 ("Required certificate is not available."); :return false; } /tool/fetch check-certificate=yes-without-crl http-header-field=({ [ $FetchUserAgentStr $0 ] }) \ From e36613608c18bc4bcbc11e2d8da47f6c8c53c454 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 7 Apr 2025 14:14:00 +0200 Subject: [PATCH 049/291] global-functions: $CertificateNameByCN: support matching by fingerprint and name --- global-functions.rsc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index 30374aa..f73ea14 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -203,11 +203,12 @@ # name a certificate by its common-name :set CertificateNameByCN do={ - :local CommonName [ :tostr $1 ]; + :local Match [ :tostr $1 ]; :global CleanName; - :local Cert [ /certificate/find where common-name=$CommonName ]; + :local Cert [ /certificate/find where (common-name=$Match or fingerprint=$Match or name=$Match) ]; + :local CommonName [ /certificate/get $Cert common-name ]; /certificate/set $Cert name=[ $CleanName $CommonName ]; } From 44fa91f5c47ec739a7f74aa2861ab58cc42bed39 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 7 Apr 2025 15:05:27 +0200 Subject: [PATCH 050/291] global-functions: $CertificateNameByCN: pick the first match only --- global-functions.rsc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global-functions.rsc b/global-functions.rsc index f73ea14..7b1c214 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -207,7 +207,7 @@ :global CleanName; - :local Cert [ /certificate/find where (common-name=$Match or fingerprint=$Match or name=$Match) ]; + :local Cert ([ /certificate/find where (common-name=$Match or fingerprint=$Match or name=$Match) ]->0); :local CommonName [ /certificate/get $Cert common-name ]; /certificate/set $Cert name=[ $CleanName $CommonName ]; } From c823ff87ed32beeea6e0a49d194178db9944693d Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 8 Apr 2025 14:42:51 +0200 Subject: [PATCH 051/291] global-functions: $CertificateNameByCN: return false without match... ... and return true on success. --- global-functions.rsc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/global-functions.rsc b/global-functions.rsc index 7b1c214..d014567 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -208,8 +208,12 @@ :global CleanName; :local Cert ([ /certificate/find where (common-name=$Match or fingerprint=$Match or name=$Match) ]->0); + :if ([ :len $Cert ] = 0) do={ + :return false; + } :local CommonName [ /certificate/get $Cert common-name ]; /certificate/set $Cert name=[ $CleanName $CommonName ]; + :return true; } # multiply given character(s) From d4b5e1f5e7acb59bc365c6598749d1ec15c8cd36 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 10 Apr 2025 11:07:59 +0200 Subject: [PATCH 052/291] global-functions: $CertificateNameByCN: warn with no match --- global-functions.rsc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/global-functions.rsc b/global-functions.rsc index d014567..70269c8 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -206,9 +206,11 @@ :local Match [ :tostr $1 ]; :global CleanName; + :global LogPrint; :local Cert ([ /certificate/find where (common-name=$Match or fingerprint=$Match or name=$Match) ]->0); :if ([ :len $Cert ] = 0) do={ + $LogPrint warning $0 ("No matching certificate found."); :return false; } :local CommonName [ /certificate/get $Cert common-name ]; From 75163f0d3cbd9daf6ff7977f60403beff1b9e76a Mon Sep 17 00:00:00 2001 From: Miquel Bonastre Date: Mon, 7 Apr 2025 13:51:56 +0200 Subject: [PATCH 053/291] INITIAL-COMMANDS: support installation from custom server Closes: https://github.com/eworm-de/routeros-scripts/pull/96 Co-authored-by: Christian Hesse --- INITIAL-COMMANDS.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/INITIAL-COMMANDS.md b/INITIAL-COMMANDS.md index 8b64d28..002e51a 100644 --- a/INITIAL-COMMANDS.md +++ b/INITIAL-COMMANDS.md @@ -17,23 +17,27 @@ Initial commands Run the complete base installation: { - /tool/fetch "https://git.eworm.de/cgit/routeros-scripts/plain/certs/ISRG-Root-X2.pem" dst-path="isrg-root-x2.pem" as-value; + :local BaseUrl "https://git.eworm.de/cgit/routeros-scripts/plain/"; + :local CertFileName "ISRG-Root-X2.pem"; + :local CertFingerprint "69729b8e15a86efc177a57afb7171dfc64add28c2fca8cf1507e34453ccb1470"; + + /tool/fetch ($BaseUrl . "certs/" . $CertFileName) dst-path=$CertFileName as-value; :delay 1s; - /certificate/import file-name="isrg-root-x2.pem" passphrase=""; - :if ([ :len [ /certificate/find where fingerprint="69729b8e15a86efc177a57afb7171dfc64add28c2fca8cf1507e34453ccb1470" ] ] != 1) do={ + /certificate/import file-name=$CertFileName passphrase=""; + :if ([ :len [ /certificate/find where fingerprint=$CertFingerprint ] ] != 1) do={ :error "Something is wrong with your certificates!"; }; :delay 1s; /system/script/set name=("global-config-overlay-" . [ /system/clock/get date ] . "-" . [ /system/clock/get time ]) [ find where name="global-config-overlay" ]; :foreach Script in={ "global-config"; "global-config-overlay"; "global-functions" } do={ /system/script/remove [ find where name=$Script ]; - /system/script/add name=$Script owner=$Script source=([ /tool/fetch check-certificate=yes-without-crl ("https://git.eworm.de/cgit/routeros-scripts/plain/" . $Script . ".rsc") output=user as-value]->"data"); + /system/script/add name=$Script owner=$Script source=([ /tool/fetch check-certificate=yes-without-crl ($BaseUrl . $Script . ".rsc") output=user as-value]->"data"); }; /system/script { run global-config; run global-functions; }; /system/scheduler/remove [ find where name="global-scripts" ]; /system/scheduler/add name="global-scripts" start-time=startup on-event="/system/script { run global-config; run global-functions; }"; :global CertificateNameByCN; - $CertificateNameByCN "ISRG Root X2"; + $CertificateNameByCN $CertFingerprint; }; Then continue setup with From 390e3653d714472f038814194239ad362c24baa9 Mon Sep 17 00:00:00 2001 From: Miquel Bonastre Date: Mon, 7 Apr 2025 16:16:19 +0200 Subject: [PATCH 054/291] INITIAL-COMMANDS: add status output Co-authored-by: Christian Hesse --- INITIAL-COMMANDS.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/INITIAL-COMMANDS.md b/INITIAL-COMMANDS.md index 002e51a..65b313b 100644 --- a/INITIAL-COMMANDS.md +++ b/INITIAL-COMMANDS.md @@ -21,6 +21,7 @@ Run the complete base installation: :local CertFileName "ISRG-Root-X2.pem"; :local CertFingerprint "69729b8e15a86efc177a57afb7171dfc64add28c2fca8cf1507e34453ccb1470"; + :put "Importing certificate..."; /tool/fetch ($BaseUrl . "certs/" . $CertFileName) dst-path=$CertFileName as-value; :delay 1s; /certificate/import file-name=$CertFileName passphrase=""; @@ -28,14 +29,19 @@ Run the complete base installation: :error "Something is wrong with your certificates!"; }; :delay 1s; + :put "Renaming global-config-overlay, if exists..."; /system/script/set name=("global-config-overlay-" . [ /system/clock/get date ] . "-" . [ /system/clock/get time ]) [ find where name="global-config-overlay" ]; :foreach Script in={ "global-config"; "global-config-overlay"; "global-functions" } do={ + :put "Installing $Script..."; /system/script/remove [ find where name=$Script ]; /system/script/add name=$Script owner=$Script source=([ /tool/fetch check-certificate=yes-without-crl ($BaseUrl . $Script . ".rsc") output=user as-value]->"data"); }; + :put "Loading configuration and functions..."; /system/script { run global-config; run global-functions; }; + :put "Scheduling to load configuration and functions..."; /system/scheduler/remove [ find where name="global-scripts" ]; /system/scheduler/add name="global-scripts" start-time=startup on-event="/system/script { run global-config; run global-functions; }"; + :put "Renaming certificate by its common-name..."; :global CertificateNameByCN; $CertificateNameByCN $CertFingerprint; }; From d80f43a1c86760565d0e0a662ceb0de63636c61a Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 11 Apr 2025 08:07:17 +0200 Subject: [PATCH 055/291] INITIAL-COMMANDS: fix typos --- INITIAL-COMMANDS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INITIAL-COMMANDS.md b/INITIAL-COMMANDS.md index 65b313b..79773bd 100644 --- a/INITIAL-COMMANDS.md +++ b/INITIAL-COMMANDS.md @@ -10,7 +10,7 @@ Initial commands [âŦ…ī¸ Go back to main README](README.md) -> âš ī¸ **Warning**: These command are inteneded for initial setup. If you are +> âš ī¸ **Warning**: These commands are intended for initial setup. If you are > not aware of the procedure please follow > [the long way in detail](README.md#the-long-way-in-detail). From 29bcd191ee7b4487cb9c909e6c7778767c6283f8 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 17 Apr 2025 10:44:05 +0200 Subject: [PATCH 056/291] global-functions: $ScriptInstallUpdate: support downloading certificate... ... for individual scripts. Just add it in comment with "certificate=...". This also works on installtion: $ScriptInstallUpdate new-script "base-url=..., certificate=..."; Closes: https://github.com/eworm-de/routeros-scripts/pull/97 --- global-functions.rsc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/global-functions.rsc b/global-functions.rsc index 70269c8..72c36cd 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -1195,6 +1195,12 @@ :error true; } + :if ([ :len ($ScriptInfo->"certificate") ] > 0) do={ + :if ([ $CertificateAvailable ($ScriptInfo->"certificate") ] = false) do={ + $LogPrint warning $0 ("Downloading certificate failed, trying without."); + } + } + :do { :local BaseUrl [ $EitherOr ($ScriptInfo->"base-url") $ScriptUpdatesBaseUrl ]; :local UrlSuffix [ $EitherOr ($ScriptInfo->"url-suffix") $ScriptUpdatesUrlSuffix ]; From b78df91b23a4e108ef0268c3c604191581d104ae Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 17 Apr 2025 22:22:05 +0200 Subject: [PATCH 057/291] README: and another hint on RouterOS version --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 1f7c8ed..e8e1b68 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,9 @@ And finally load configuration and functions and add the scheduler. ![screenshot: run and schedule scripts](README.d/05-run-and-schedule-scripts.avif) +> đŸ’Ąī¸ **Hint**: You see complaints regarding syntax errors? Most likely the +> RouterOS on your device is too old. Check for updates! + ### Scheduled automatic updates The last step is optional: Add this scheduler **only** if you want the From 405c329f39d402911ad5040f893a952df6407813 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 24 Apr 2025 23:07:11 +0200 Subject: [PATCH 058/291] README: mark all external links --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index e8e1b68..dcf9c28 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,9 @@ RouterOS Scripts ![RouterOS Scripts Logo](logo.svg) -[RouterOS](https://mikrotik.com/software) is the operating system developed -by [MikroTik](https://mikrotik.com/aboutus) for networking tasks. This -repository holds a number of [scripts](https://wiki.mikrotik.com/wiki/Manual:Scripting) +[RouterOS â†—ī¸](https://mikrotik.com/software) is the operating system developed +by [MikroTik â†—ī¸](https://mikrotik.com/aboutus) for networking tasks. This +repository holds a number of [scripts â†—ī¸](https://wiki.mikrotik.com/wiki/Manual:Scripting) to manage RouterOS devices or extend their functionality. *Use at your own risk*, pay attention to @@ -35,7 +35,7 @@ Specific scripts may require even newer RouterOS version. > running RouterOS v6 switch to `routeros-v6` branch! Starting with RouterOS 7.17 the -[device-mode](https://help.mikrotik.com/docs/spaces/ROS/pages/93749258/Device-mode) +[device-mode â†—ī¸](https://help.mikrotik.com/docs/spaces/ROS/pages/93749258/Device-mode) has been extended to give more fine-grained control over what features are available. You need to enable `scheduler` and `fetch` at least, specific scripts may require additional features. @@ -61,9 +61,9 @@ First time users should take the long way below. ### Live presentation Want to see it in action? I've had a presentation [Repository based -RouterOS script distribution](https://www.youtube.com/watch?v=B9neG3oAhcY) +RouterOS script distribution â†—ī¸](https://www.youtube.com/watch?v=B9neG3oAhcY) including demonstation recorded live at [MUM Europe -2019](https://mum.mikrotik.com/2019/EU/) in Vienna. +2019 â†—ī¸](https://mum.mikrotik.com/2019/EU/) in Vienna. > âš ī¸ **Warning**: Some details changed. So see the presentation, then follow > the steps below for up-to-date commands. @@ -83,7 +83,7 @@ Note that the commands above do *not* verify server certificate, so if you want to be safe download with your workstations's browser and transfer the file to your MikroTik device. -* [ISRG Root X2](https://letsencrypt.org/certs/isrg-root-x2.pem) +* [ISRG Root X2 â†—ī¸](https://letsencrypt.org/certs/isrg-root-x2.pem) Then we import the certificate. @@ -194,7 +194,7 @@ Scheduler and events -------------------- Most scripts are designed to run regularly from -[scheduler](https://wiki.mikrotik.com/wiki/Manual:System/Scheduler). We just +[scheduler â†—ī¸](https://wiki.mikrotik.com/wiki/Manual:System/Scheduler). We just added `check-routeros-update`, so let's run it daily to make sure not to miss an update. @@ -328,7 +328,7 @@ Possibly a scheduler and other configuration has to be removed as well. Contact ------- -We have a Telegram Group [RouterOS-Scripts](https://t.me/routeros_scripts)! +We have a Telegram Group [RouterOS-Scripts â†—ī¸](https://t.me/routeros_scripts)! [![RouterOS Scripts Telegram Group](README.d/telegram-group.avif)](https://t.me/routeros_scripts) @@ -352,7 +352,7 @@ at github. This project is developed in private spare time and usage is free of charge for you. If you like the scripts and think this is of value for you or your business please consider to -[donate with PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J). +[donate with PayPal â†—ī¸](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J). [![donate with PayPal](https://img.shields.io/badge/Like_it%3F-Donate!-orange?logo=githubsponsors&logoColor=orange&style=for-the-badge)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J) From 158230070fbfae7a83b881b7bcd6f1651de45e54 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 24 Apr 2025 23:14:02 +0200 Subject: [PATCH 059/291] BRANCHES: mark all external links --- BRANCHES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BRANCHES.md b/BRANCHES.md index 8a0bdad..dc4f4ac 100644 --- a/BRANCHES.md +++ b/BRANCHES.md @@ -13,7 +13,7 @@ Installing from branches > âš ī¸ **Warning**: Living on the edge? Great, read on! > If not: Please use the `main` branch and leave this page! -These scripts are developed in a [git](https://git-scm.com/) repository. +These scripts are developed in a [git â†—ī¸](https://git-scm.com/) repository. Development and experimental branches are used to provide early access for specific changes. You can install scripts from these branches for testing. From 8328400e8724006ce68a401d8297cbd8f4f30a7e Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 24 Apr 2025 23:14:53 +0200 Subject: [PATCH 060/291] CERTIFICATES: mark all external links --- CERTIFICATES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CERTIFICATES.md b/CERTIFICATES.md index 5432d78..8ead452 100644 --- a/CERTIFICATES.md +++ b/CERTIFICATES.md @@ -21,7 +21,7 @@ first step of [installation](README.md#the-long-way-in-detail) is importing the certificate. The scripts can install additional certificates when required. This happens -from this repository if available, or from [mkcert.org](https://mkcert.org) +from this repository if available, or from [mkcert.org â†—ī¸](https://mkcert.org) as a fallback. Get the certificate's CommonName @@ -29,7 +29,7 @@ Get the certificate's CommonName But how to determine what certificate may be required? Often easiest way is to use a desktop browser to get that information. This demonstration uses -[Mozilla Firefox](https://www.mozilla.org/firefox/). +[Mozilla Firefox â†—ī¸](https://www.mozilla.org/firefox/). Let's assume we want to make sure the certificate for [git.eworm.de](https://git.eworm.de/) is available. Open that page in the From a1437a4c8315f2640925323cdea7fb620b7bbf5f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 24 Apr 2025 23:13:00 +0200 Subject: [PATCH 061/291] CONTRIBUTIONS: mark all external links --- CONTRIBUTIONS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTIONS.md b/CONTRIBUTIONS.md index 55d2205..0b89453 100644 --- a/CONTRIBUTIONS.md +++ b/CONTRIBUTIONS.md @@ -31,7 +31,7 @@ for details! ## Donations Add yourself to the list, -[donate with PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J)! +[donate with PayPal â†—ī¸](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J)! * Abdul Mannan Abbasi * Andrea Ruffini Perico From b12f8a39745cb54318b5d55bf65a1d8cfff81b02 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 24 Apr 2025 23:17:58 +0200 Subject: [PATCH 062/291] doc/backup-cloud: mark all external links --- doc/backup-cloud.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/backup-cloud.md b/doc/backup-cloud.md index 7286960..740af53 100644 --- a/doc/backup-cloud.md +++ b/doc/backup-cloud.md @@ -17,7 +17,7 @@ Description ----------- This script uploads -[binary backup to Mikrotik cloud](https://wiki.mikrotik.com/wiki/Manual:IP/Cloud#Backup). +[binary backup to Mikrotik cloud â†—ī¸](https://wiki.mikrotik.com/wiki/Manual:IP/Cloud#Backup). > âš ī¸ **Warning**: The used command can hit errors that a script can with > workaround only. A notification *should* be sent anyway. But it can result From 4118f53aae9c87dcc90dff6c800a8baf5d04785d Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 24 Apr 2025 23:18:09 +0200 Subject: [PATCH 063/291] doc/backup-partition: mark all external links --- doc/backup-partition.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/backup-partition.md b/doc/backup-partition.md index 9d615a5..50b8a09 100644 --- a/doc/backup-partition.md +++ b/doc/backup-partition.md @@ -17,7 +17,7 @@ Description ----------- This script saves the current configuration to fallback -[partition](https://wiki.mikrotik.com/wiki/Manual:Partitions). +[partition â†—ī¸](https://wiki.mikrotik.com/wiki/Manual:Partitions). It can also copy-over the RouterOS installation when run interactively or just before a feature update. From 34eac64f3378387f402151d1a017fc00e81b7c61 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 24 Apr 2025 23:18:26 +0200 Subject: [PATCH 064/291] doc/check-routeros-update: mark all external links --- doc/check-routeros-update.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/check-routeros-update.md b/doc/check-routeros-update.md index b6c716c..ea9bcbe 100644 --- a/doc/check-routeros-update.md +++ b/doc/check-routeros-update.md @@ -30,8 +30,8 @@ automatically is supported. > âš ī¸ **Warning**: Installing updates is important from a security point > of view. At the same time it can be source of serve breakage. So test > versions in lab and read -> [changelog](https://mikrotik.com/download/changelogs/) and -> [forum](https://forum.mikrotik.com/viewforum.php?f=21) before deploying +> [changelog â†—ī¸](https://mikrotik.com/download/changelogs/) and +> [forum â†—ī¸](https://forum.mikrotik.com/viewforum.php?f=21) before deploying > to your production environment! Automatic updates should be handled > with care! From 3788a3e2861c7a3f48f221771977c133204a7f32 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 24 Apr 2025 23:18:40 +0200 Subject: [PATCH 065/291] doc/fw-addr-lists: mark all external links --- doc/fw-addr-lists.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/fw-addr-lists.md b/doc/fw-addr-lists.md index cb560d7..d09383b 100644 --- a/doc/fw-addr-lists.md +++ b/doc/fw-addr-lists.md @@ -19,10 +19,10 @@ Description This script downloads, imports and updates firewall address-lists. Its main purpose is to block attacking ip addresses, spam hosts, command-and-control servers and similar malicious entities. The default configuration contains a -[collective list by GitHub user @stamparm](https://github.com/stamparm/ipsum), -lists from [dshield.org](https://dshield.org/) and -[blocklist.de](https://www.blocklist.de/), and lists from -[spamhaus.org](https://spamhaus.org/) are prepared. +[collective list by GitHub user @stamparm â†—ī¸](https://github.com/stamparm/ipsum), +lists from [dshield.org â†—ī¸](https://dshield.org/) and +[blocklist.de â†—ī¸](https://www.blocklist.de/), and lists from +[spamhaus.org â†—ī¸](https://spamhaus.org/) are prepared. The address-lists are updated in place, so after initial import you will not see situation when the lists are not populated. From 2fa044972cc2e38e404b0e76035609c51174c0d3 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 24 Apr 2025 23:18:50 +0200 Subject: [PATCH 066/291] doc/log-forward: mark all external links --- doc/log-forward.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/log-forward.md b/doc/log-forward.md index 3c19569..9ead165 100644 --- a/doc/log-forward.md +++ b/doc/log-forward.md @@ -72,7 +72,7 @@ The configuration goes to `global-config-overlay`, these are the parameters: > your local `global-config-overlay` and modify it to your specific needs. These patterns are matched as -[regular expressions](https://wiki.mikrotik.com/wiki/Manual:Regular_Expressions). +[regular expressions â†—ī¸](https://wiki.mikrotik.com/wiki/Manual:Regular_Expressions). To forward **all** (ignoring severity) log messages with topics `account` (which includes user logins) and `dhcp` you need something like: From 0eaefcdc72ba217990fce4bf17460337697305a9 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 24 Apr 2025 23:23:12 +0200 Subject: [PATCH 067/291] doc/mod/notification-email: mark all external links --- doc/mod/notification-email.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/mod/notification-email.md b/doc/mod/notification-email.md index 34d1c09..dabadf3 100644 --- a/doc/mod/notification-email.md +++ b/doc/mod/notification-email.md @@ -32,7 +32,7 @@ Configuration ------------- Set up your device's -[e-mail settings](https://wiki.mikrotik.com/wiki/Manual:Tools/email). +[e-mail settings â†—ī¸](https://wiki.mikrotik.com/wiki/Manual:Tools/email). Also make sure the device has correct time configured, best is to set up the ntp client. From 183b16d83c1a182ba35d21453687a27106d94883 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 24 Apr 2025 23:23:31 +0200 Subject: [PATCH 068/291] doc/mod/notification-matrix: mark all external links --- doc/mod/notification-matrix.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/mod/notification-matrix.md b/doc/mod/notification-matrix.md index 89c1b01..da725cf 100644 --- a/doc/mod/notification-matrix.md +++ b/doc/mod/notification-matrix.md @@ -17,7 +17,7 @@ Description ----------- This module adds support for sending notifications via -[Matrix](https://matrix.org/) via client server api. A queue is used to +[Matrix â†—ī¸](https://matrix.org/) via client server api. A queue is used to make sure notifications are not lost on failure but sent later. Requirements and installation From c69b13c87961dbfced0002e85b98a32fe6b7fc84 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 24 Apr 2025 23:23:41 +0200 Subject: [PATCH 069/291] doc/mod/notification-notify: mark all external links --- doc/mod/notification-ntfy.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/mod/notification-ntfy.md b/doc/mod/notification-ntfy.md index 51756ac..ef5dd58 100644 --- a/doc/mod/notification-ntfy.md +++ b/doc/mod/notification-ntfy.md @@ -17,7 +17,7 @@ Description ----------- This module adds support for sending notifications via -[Ntfy](https://ntfy.sh/). A queue is used to make sure +[Ntfy â†—ī¸](https://ntfy.sh/). A queue is used to make sure notifications are not lost on failure but sent later. Requirements and installation @@ -28,7 +28,7 @@ Just install the module: $ScriptInstallUpdate mod/notification-ntfy; Also install the Ntfy app on your mobile device or use the -[web app](https://ntfy.sh/app) in a browser of your choice. +[web app â†—ī¸](https://ntfy.sh/app) in a browser of your choice. Configuration ------------- From 3822887ba2d157101caf3529a5234d3974ef472e Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 24 Apr 2025 23:23:49 +0200 Subject: [PATCH 070/291] doc/mod/notification-telegram: mark all external links --- doc/mod/notification-telegram.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/mod/notification-telegram.md b/doc/mod/notification-telegram.md index 2d00116..6b10fed 100644 --- a/doc/mod/notification-telegram.md +++ b/doc/mod/notification-telegram.md @@ -17,7 +17,7 @@ Description ----------- This module adds support for sending notifications via -[Telegram](https://telegram.org/) via bot api. A queue is used to make sure +[Telegram â†—ī¸](https://telegram.org/) via bot api. A queue is used to make sure notifications are not lost on failure but sent later. Requirements and installation @@ -33,7 +33,7 @@ and create an account. Configuration ------------- -Open Telegram, then start a chat with [BotFather](https://t.me/BotFather) and +Open Telegram, then start a chat with [BotFather â†—ī¸](https://t.me/BotFather) and create your own bot: ![create new bot](notification-telegram.d/newbot.avif) @@ -102,7 +102,7 @@ Tips & Tricks ### Set a profile photo You can use a profile photo for your bot to make it recognizable. Open the -chat with [BotFather](https://t.me/BotFather) and set it there. +chat with [BotFather â†—ī¸](https://t.me/BotFather) and set it there. ![set profile photo](notification-telegram.d/setuserpic.avif) From fe649181180986935a049b489322b10327ba0697 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 28 Apr 2025 10:48:36 +0200 Subject: [PATCH 071/291] README: add disclaimer on external links --- README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dcf9c28..1d2d64f 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,8 @@ repository holds a number of [scripts â†—ī¸](https://wiki.mikrotik.com/wiki/Man to manage RouterOS devices or extend their functionality. *Use at your own risk*, pay attention to -[license and warranty](#license-and-warranty)! +[license and warranty](#license-and-warranty), and +[disclaimer on external links](#disclaimer-on-external-links)! Requirements ------------ @@ -371,6 +372,21 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the [GNU General Public License](COPYING.md) for more details. +Disclaimer on external links +---------------------------- + +Our website contains links to the websites of third parties ("external +links"). As the content of these websites is not under our control, we +cannot assume any liability for such external content. In all cases, the +provider of information of the linked websites is liable for the content +and accuracy of the information provided. At the point in time when the +links were placed, no infringements of the law were recognisable to us. +As soon as an infringement of the law becomes known to us, we will +immediately remove the link in question. + +> đŸ’Ąī¸ **Hint**: All external links are marked with an arrow pointing +> diagonally in an up-right (or north-east) direction (â†—ī¸). + Upstream -------- From 0717ebfbd500517231a6da31091a1f4d59bedd00 Mon Sep 17 00:00:00 2001 From: Leonardo David Monteiro Date: Tue, 4 Mar 2025 17:21:00 +0100 Subject: [PATCH 072/291] introduce mod/notification-gotify... ... for sending notifications via Gotify (https://gotify.net). Closes: https://github.com/eworm-de/routeros-scripts/pull/92 Co-authored-by: Christian Hesse --- CERTIFICATES.md | 1 + README.md | 1 + doc/backup-cloud.md | 1 + doc/backup-upload.md | 1 + doc/check-certificates.md | 1 + doc/check-health.md | 1 + doc/check-lte-firmware-upgrade.md | 1 + doc/check-perpetual-license.md | 1 + doc/check-routeros-update.md | 1 + doc/collect-wireless-mac.md | 1 + doc/daily-psk.md | 1 + doc/log-forward.md | 7 +- doc/mod/notification-email.md | 1 + doc/mod/notification-gotify.d/appsetup.avif | Bin 0 -> 18099 bytes doc/mod/notification-gotify.md | 97 ++++++++++++++ doc/mod/notification-matrix.md | 1 + doc/mod/notification-ntfy.md | 1 + doc/mod/notification-telegram.md | 1 + doc/netwatch-notify.md | 1 + doc/sms-forward.md | 1 + global-config.rsc | 6 + global-functions.rsc | 2 +- mod/notification-gotify.rsc | 139 ++++++++++++++++++++ news-and-changes.rsc | 1 + 24 files changed, 265 insertions(+), 4 deletions(-) create mode 100644 doc/mod/notification-gotify.d/appsetup.avif create mode 100644 doc/mod/notification-gotify.md create mode 100644 mod/notification-gotify.rsc diff --git a/CERTIFICATES.md b/CERTIFICATES.md index 8ead452..69d6c18 100644 --- a/CERTIFICATES.md +++ b/CERTIFICATES.md @@ -74,6 +74,7 @@ See also * [Download, import and update firewall address-lists](doc/fw-addr-lists.md) * [Manage DNS and DoH servers from netwatch](doc/netwatch-dns.md) +* [Send notifications via Gotify](doc/mod/notification-gotify.md) * [Send notifications via Matrix](doc/mod/notification-matrix.md) * [Send notifications via Ntfy](doc/mod/notification-ntfy.md) diff --git a/README.md b/README.md index 1d2d64f..2a8b2ce 100644 --- a/README.md +++ b/README.md @@ -268,6 +268,7 @@ Available modules * [Inspect variables](doc/mod/inspectvar.md) (`mod/inspectvar`) * [IP address calculation](doc/mod/ipcalc.md) (`mod/ipcalc`) * [Send notifications via e-mail](doc/mod/notification-email.md) (`mod/notification-email`) +* [Send notifications via Gotify](doc/mod/notification-gotify.md) (`mod/notification-gotify`) * [Send notifications via Matrix](doc/mod/notification-matrix.md) (`mod/notification-matrix`) * [Send notifications via Ntfy](doc/mod/notification-ntfy.md) (`mod/notification-ntfy`) * [Send notifications via Telegram](doc/mod/notification-telegram.md) (`mod/notification-telegram`) diff --git a/doc/backup-cloud.md b/doc/backup-cloud.md index 740af53..7d55d74 100644 --- a/doc/backup-cloud.md +++ b/doc/backup-cloud.md @@ -49,6 +49,7 @@ The configuration goes to `global-config-overlay`, these are the parameters: Also notification settings are required for [e-mail](mod/notification-email.md), +[gotify](mod/notification-gotify.md), [matrix](mod/notification-matrix.md), [ntfy](mod/notification-ntfy.md) and/or [telegram](mod/notification-telegram.md). diff --git a/doc/backup-upload.md b/doc/backup-upload.md index 6a5b0e4..b4012c8 100644 --- a/doc/backup-upload.md +++ b/doc/backup-upload.md @@ -55,6 +55,7 @@ The configuration goes to `global-config-overlay`, these are the parameters: Also notification settings are required for [e-mail](mod/notification-email.md), +[gotify](mod/notification-gotify.md), [matrix](mod/notification-matrix.md), [ntfy](mod/notification-ntfy.md) and/or [telegram](mod/notification-telegram.md). diff --git a/doc/check-certificates.md b/doc/check-certificates.md index 4c144ba..a9426db 100644 --- a/doc/check-certificates.md +++ b/doc/check-certificates.md @@ -51,6 +51,7 @@ subject alternative name (aka *Subject Alt Name* or *SAN*) can be used. Also notification settings are required for [e-mail](mod/notification-email.md), +[gotify](mod/notification-gotify.md), [matrix](mod/notification-matrix.md), [ntfy](mod/notification-ntfy.md) and/or [telegram](mod/notification-telegram.md). diff --git a/doc/check-health.md b/doc/check-health.md index 7cf0c33..33847e3 100644 --- a/doc/check-health.md +++ b/doc/check-health.md @@ -113,6 +113,7 @@ The configuration goes to `global-config-overlay`, these are the parameters: Also notification settings are required for [e-mail](mod/notification-email.md), +[gotify](mod/notification-gotify.md), [matrix](mod/notification-matrix.md), [ntfy](mod/notification-ntfy.md) and/or [telegram](mod/notification-telegram.md). diff --git a/doc/check-lte-firmware-upgrade.md b/doc/check-lte-firmware-upgrade.md index 3693b71..a84e2ac 100644 --- a/doc/check-lte-firmware-upgrade.md +++ b/doc/check-lte-firmware-upgrade.md @@ -44,6 +44,7 @@ Configuration Also notification settings are required for [e-mail](mod/notification-email.md), +[gotify](mod/notification-gotify.md), [matrix](mod/notification-matrix.md) and/or [telegram](mod/notification-telegram.md). diff --git a/doc/check-perpetual-license.md b/doc/check-perpetual-license.md index d444004..0335fb5 100644 --- a/doc/check-perpetual-license.md +++ b/doc/check-perpetual-license.md @@ -41,6 +41,7 @@ Configuration No extra configuration is required for this script, but notification settings are required for [e-mail](mod/notification-email.md), +[gotify](mod/notification-gotify.md), [matrix](mod/notification-matrix.md), [ntfy](mod/notification-ntfy.md) and/or [telegram](mod/notification-telegram.md). diff --git a/doc/check-routeros-update.md b/doc/check-routeros-update.md index ea9bcbe..a45e075 100644 --- a/doc/check-routeros-update.md +++ b/doc/check-routeros-update.md @@ -73,6 +73,7 @@ The configuration goes to `global-config-overlay`, these are the parameters: Also notification settings are required for [e-mail](mod/notification-email.md), +[gotify](mod/notification-gotify.md), [matrix](mod/notification-matrix.md), [ntfy](mod/notification-ntfy.md) and/or [telegram](mod/notification-telegram.md). diff --git a/doc/collect-wireless-mac.md b/doc/collect-wireless-mac.md index 0197522..2378fed 100644 --- a/doc/collect-wireless-mac.md +++ b/doc/collect-wireless-mac.md @@ -54,6 +54,7 @@ entries are to be added. Also notification settings are required for [e-mail](mod/notification-email.md), +[gotify](mod/notification-gotify.md), [matrix](mod/notification-matrix.md), [ntfy](mod/notification-ntfy.md) and/or [telegram](mod/notification-telegram.md). diff --git a/doc/daily-psk.md b/doc/daily-psk.md index 4a3de64..118d768 100644 --- a/doc/daily-psk.md +++ b/doc/daily-psk.md @@ -79,6 +79,7 @@ For legacy local interface: Also notification settings are required for [e-mail](mod/notification-email.md), +[gotify](mod/notification-gotify.md), [trix](mod/notification-matrix.md), [ntfy](mod/notification-ntfy.md) and/or [telegram](mod/notification-telegram.md). diff --git a/doc/log-forward.md b/doc/log-forward.md index 9ead165..f6086c8 100644 --- a/doc/log-forward.md +++ b/doc/log-forward.md @@ -22,15 +22,15 @@ server (see `/system/logging`). This has some limitation, however: * does not work early after boot if network connectivity is not yet established, or breaks intermittently * lots of messages generate a flood of mails -* Matrix, Ntfy and Telegram are not supported +* Gotify, Matrix, Ntfy and Telegram are not supported The script works around the limitations, for example it does: * read from `/log`, including messages from early boot * skip multi-repeated messages * rate-limit itself to mitigate flooding -* forward via notification (which includes *e-mail*, *Matrix*, *Ntfy* and - *Telegram* when installed and configured, see below) +* forward via notification (which includes *e-mail*, *Gotify*, *Matrix*, + *Ntfy* and *Telegram* when installed and configured, see below) It is intended to be run periodically from scheduler, then collects new log messages and forwards them via notification. @@ -80,6 +80,7 @@ To forward **all** (ignoring severity) log messages with topics `account` Also notification settings are required for [e-mail](mod/notification-email.md), +[gotify](mod/notification-gotify.md), [matrix](mod/notification-matrix.md), [ntfy](mod/notification-ntfy.md) and/or [telegram](mod/notification-telegram.md). diff --git a/doc/mod/notification-email.md b/doc/mod/notification-email.md index dabadf3..127bf96 100644 --- a/doc/mod/notification-email.md +++ b/doc/mod/notification-email.md @@ -79,6 +79,7 @@ function available: See also -------- +* [Send notifications via Gotify](notification-gotify.md) * [Send notifications via Matrix](notification-matrix.md) * [Send notifications via Ntfy](notification-ntfy.md) * [Send notifications via Telegram](notification-telegram.md) diff --git a/doc/mod/notification-gotify.d/appsetup.avif b/doc/mod/notification-gotify.d/appsetup.avif new file mode 100644 index 0000000000000000000000000000000000000000..58f57a807cd9c4853bf819336af8dc65f2eddd48 GIT binary patch literal 18099 zcmce+V{~QF(>Hiy+qP}n?%1|%+qP}n?AT5^>^SMz>LhRa|2)q-vu4eQnfWkvSKX@G zRlBNw`|NYixn~^!06=Kw;^|=MW@!farhn4b(u~R0($Gv!h)D!nJ6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2JpvzHD_`OVzNHKiz nwkf&)CSNX+G}Gaa0-Kerzlq%kWO}B^EpJt%Yxe^s0CiYEKREb0 literal 0 HcmV?d00001 diff --git a/doc/mod/notification-gotify.md b/doc/mod/notification-gotify.md new file mode 100644 index 0000000..6fce629 --- /dev/null +++ b/doc/mod/notification-gotify.md @@ -0,0 +1,97 @@ +Send notifications via Gotify +=========================== + +[![GitHub stars](https://img.shields.io/github/stars/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=red)](https://github.com/eworm-de/routeros-scripts/stargazers) +[![GitHub forks](https://img.shields.io/github/forks/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=green)](https://github.com/eworm-de/routeros-scripts/network) +[![GitHub watchers](https://img.shields.io/github/watchers/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=blue)](https://github.com/eworm-de/routeros-scripts/watchers) +[![required RouterOS version](https://img.shields.io/badge/RouterOS-7.15-yellow?style=flat)](https://mikrotik.com/download/changelogs/) +[![Telegram group @routeros_scripts](https://img.shields.io/badge/Telegram-%40routeros__scripts-%2326A5E4?logo=telegram&style=flat)](https://t.me/routeros_scripts) +[![donate with PayPal](https://img.shields.io/badge/Like_it%3F-Donate!-orange?logo=githubsponsors&logoColor=orange&style=flat)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J) + +[âŦ…ī¸ Go back to main README](../../README.md) + +> â„šī¸ī¸ **Info**: This module can not be used on its own but requires the base +> installation. See [main README](../../README.md) for details. + +Description +----------- + +This module adds support for sending notifications via +[Gotify â†—ī¸](https://gotify.net/). A queue is used to make sure +notifications are not lost on failure but sent later. + +Requirements and installation +----------------------------- + +Just install the module: + + $ScriptInstallUpdate mod/notification-gotify; + +Also deploy the [Gotify server â†—ī¸](https://github.com/gotify/server) and +optionally install a Gotify client on your mobile device. + +Configuration +------------- + +Follow the [Installation â†—ī¸](https://gotify.net/docs/install) instructions +and the [First Login â†—ī¸](https://gotify.net/docs/first-login) setup. Once +you have a user and account you can start creating apps. Each app is an +independent notification feed for a device or application. + +![Create new app](notification-gotify.d/appsetup.avif) + +On creation apps are assigned a *Token* for authentification, you will need +that in configuration. + +Edit `global-config-overlay`, add `GotifyServer` with your server address +(just the address, no protocol - `https://` is assumed) and `GotifyToken` +with the *Token* from your configured app on the Gotify server. Then reload +the configuration. + +> â„šī¸ **Info**: Copy relevant configuration from +> [`global-config`](../../global-config.rsc) (the one without `-overlay`) to +> your local `global-config-overlay` and modify it to your specific needs. + +For a custom service installing an additional certificate may be required. +You may want to install that certificate manually, after finding the +[certificate name from browser](../../CERTIFICATES.md). + +Usage and invocation +-------------------- + +There's nothing special to do. Every script or function sending a notification +will now send it to your Gotify application feed. + +But of course you can use the function to send notifications directly. Give +it a try: + + $SendGotify "Subject..." "Body..."; + +Alternatively this sends a notification with all available and configured +methods: + + $SendNotification "Subject..." "Body..."; + +To use the functions in your own scripts you have to declare them first. +Place this before you call them: + + :global SendGotify; + :global SendNotification; + +In case there is a situation when the queue needs to be purged there is a +function available: + + $PurgeGotifyQueue; + +See also +-------- + +* [Certificate name from browser](../../CERTIFICATES.md) +* [Send notifications via e-mail](notification-email.md) +* [Send notifications via Matrix](notification-matrix.md) +* [Send notifications via Ntfy](notification-ntfy.md) +* [Send notifications via Telegram](notification-telegram.md) + +--- +[âŦ…ī¸ Go back to main README](../../README.md) +[âŦ†ī¸ Go back to top](#top) diff --git a/doc/mod/notification-matrix.md b/doc/mod/notification-matrix.md index da725cf..da6d6de 100644 --- a/doc/mod/notification-matrix.md +++ b/doc/mod/notification-matrix.md @@ -131,6 +131,7 @@ See also * [Certificate name from browser](../../CERTIFICATES.md) * [Send notifications via e-mail](notification-email.md) +* [Send notifications via Gotify](notification-gotify.md) * [Send notifications via Ntfy](notification-ntfy.md) * [Send notifications via Telegram](notification-telegram.md) diff --git a/doc/mod/notification-ntfy.md b/doc/mod/notification-ntfy.md index ef5dd58..993501d 100644 --- a/doc/mod/notification-ntfy.md +++ b/doc/mod/notification-ntfy.md @@ -90,6 +90,7 @@ See also * [Certificate name from browser](../../CERTIFICATES.md) * [Send notifications via e-mail](notification-email.md) +* [Send notifications via Gotify](notification-gotify.md) * [Send notifications via Matrix](notification-matrix.md) * [Send notifications via Telegram](notification-telegram.md) diff --git a/doc/mod/notification-telegram.md b/doc/mod/notification-telegram.md index 6b10fed..804104f 100644 --- a/doc/mod/notification-telegram.md +++ b/doc/mod/notification-telegram.md @@ -115,6 +115,7 @@ See also * [Chat with your router and send commands via Telegram bot](../telegram-chat.md) * [Send notifications via e-mail](notification-email.md) +* [Send notifications via Gotify](notification-gotify.md) * [Send notifications via Matrix](notification-matrix.md) * [Send notifications via Ntfy](notification-ntfy.md) diff --git a/doc/netwatch-notify.md b/doc/netwatch-notify.md index 81adfe9..91c568f 100644 --- a/doc/netwatch-notify.md +++ b/doc/netwatch-notify.md @@ -47,6 +47,7 @@ The hosts to be checked have to be added to netwatch with specific comment: Also notification settings are required for [e-mail](mod/notification-email.md), +[gotify](mod/notification-gotify.md), [matrix](mod/notification-matrix.md), [ntfy](mod/notification-ntfy.md) and/or [telegram](mod/notification-telegram.md). diff --git a/doc/sms-forward.md b/doc/sms-forward.md index ccb6482..0c1317d 100644 --- a/doc/sms-forward.md +++ b/doc/sms-forward.md @@ -56,6 +56,7 @@ The configuration goes to `global-config-overlay`, this is the only parameter: Notification settings are required for [e-mail](mod/notification-email.md), +[gotify](mod/notification-gotify.md), [matrix](mod/notification-matrix.md), [ntfy](mod/notification-ntfy.md) and/or [telegram](mod/notification-telegram.md). diff --git a/global-config.rsc b/global-config.rsc index fa32b16..42a457a 100644 --- a/global-config.rsc +++ b/global-config.rsc @@ -63,6 +63,12 @@ :global NtfyServerToken ""; :global NtfyTopic ""; +# You can send Gotify notifications. Configure these settings and +# install the module: +# $ScriptInstallUpdate mod/notification-gotify +:global GotifyServer ""; +:global GotifyToken ""; + # It is possible to override e-mail, Telegram, Matrix and Ntfy setting # for every script. This is done in arrays, where 'Override' is appended # to the variable name, like this: diff --git a/global-functions.rsc b/global-functions.rsc index 72c36cd..71aa7de 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -15,7 +15,7 @@ # Git commit id & info, expected configuration version :global CommitId "unknown"; :global CommitInfo "unknown"; -:global ExpectedConfigVersion 136; +:global ExpectedConfigVersion 137; # global variables not to be changed by user :global GlobalFunctionsReady false; diff --git a/mod/notification-gotify.rsc b/mod/notification-gotify.rsc new file mode 100644 index 0000000..7070918 --- /dev/null +++ b/mod/notification-gotify.rsc @@ -0,0 +1,139 @@ +#!rsc by RouterOS +# RouterOS script: mod/notification-gotify +# Copyright (c) 2013-2025 Christian Hesse +# Leonardo David Monteiro +# https://rsc.eworm.de/COPYING.md +# +# requires RouterOS, version=7.15 +# requires device-mode, fetch, scheduler +# +# send notifications via Gotify (gotify.net) +# https://rsc.eworm.de/doc/mod/notification-gotify.md + +:global FlushGotifyQueue; +:global NotificationFunctions; +:global PurgeGotifyQueue; +:global SendGotify; +:global SendGotify2; + +# flush Gotify queue +:set FlushGotifyQueue do={ :do { + :global GotifyQueue; + + :global IsFullyConnected; + :global LogPrint; + + :if ([ $IsFullyConnected ] = false) do={ + $LogPrint debug $0 ("System is not fully connected, not flushing."); + :return false; + } + + :local AllDone true; + :local QueueLen [ :len $GotifyQueue ]; + + :if ([ :len [ /system/scheduler/find where name="_FlushGotifyQueue" ] ] > 0 && $QueueLen = 0) do={ + $LogPrint warning $0 ("Flushing Gotify messages from scheduler, but queue is empty."); + } + + :foreach Id,Message in=$GotifyQueue do={ + :if ([ :typeof $Message ] = "array" ) do={ + :do { + /tool/fetch check-certificate=yes-without-crl output=none http-method=post \ + http-header-field=($Message->"headers") http-data=[ :serialize to=json ($Message->"message") ] \ + ($Message->"url") as-value; + :set ($GotifyQueue->$Id); + } on-error={ + $LogPrint debug $0 ("Sending queued Gotify message failed."); + :set AllDone false; + } + } + } + + :if ($AllDone = true && $QueueLen = [ :len $GotifyQueue ]) do={ + /system/scheduler/remove [ find where name="_FlushGotifyQueue" ]; + :set GotifyQueue; + } +} on-error={ + :global ExitError; $ExitError false $0; +} } + +# send notification via Gotify - expects one array argument +:set ($NotificationFunctions->"gotify") do={ + :local Notification $1; + + :global Identity; + :global IdentityExtra; + :global GotifyQueue; + :global GotifyServer; + :global GotifyServerOverride; + :global GotifyToken; + :global GotifyTokenOverride; + + :global EitherOr; + :global FetchUserAgentStr; + :global IfThenElse; + :global LogPrint; + :global SymbolForNotification; + + :local Server [ $EitherOr ($GotifyServerOverride->($Notification->"origin")) $GotifyServer ]; + :local Token [ $EitherOr ($GotifyTokenOverride->($Notification->"origin")) $GotifyToken ]; + + :if ([ :len $Token ] = 0) do={ + :return false; + } + + :local Url ("https://" . $Server . "/message"); + :local Headers ({ [ $FetchUserAgentStr ($Notification->"origin") ]; \ + ("X-Gotify-Key: " . $Token); "Content-Type: application/json" }); + :local Message ({ + "title"=("[" . $IdentityExtra . $Identity . "] " . ($Notification->"subject")); \ + "message"=(($Notification->"message") . "\n" . [ $IfThenElse ([ :len ($Notification->"link") ] > 0) \ + ("\n" . [ $SymbolForNotification "link" ] . ($Notification->"link")) ]); \ + "priority"=[ :tonum [ $IfThenElse ($Notification->"silent") 2 5 ] ] }); + + :do { + /tool/fetch check-certificate=yes-without-crl output=none http-method=post \ + http-header-field=$Headers http-data=[ :serialize to=json $Message ] $Url as-value; + } on-error={ + $LogPrint info $0 ("Failed sending Gotify notification! Queuing..."); + + :if ([ :typeof $GotifyQueue ] = "nothing") do={ + :set GotifyQueue ({}); + } + :set ($Message->"message") (($Notification->"message") . "\n" . \ + [ $SymbolForNotification "alarm-clock" ] . "This message was queued since " . \ + [ /system/clock/get date ] . " " . [ /system/clock/get time ] . " and may be obsolete."); + :set ($GotifyQueue->[ :len $GotifyQueue ]) \ + { url=$Url; headers=$Headers; message=$Message }; + :if ([ :len [ /system/scheduler/find where name="_FlushGotifyQueue" ] ] = 0) do={ + /system/scheduler/add name="_FlushGotifyQueue" interval=1m start-time=startup \ + on-event=(":global FlushGotifyQueue; \$FlushGotifyQueue;"); + } + } +} + +# purge the Gotify queue +:set PurgeGotifyQueue do={ + :global GotifyQueue; + + /system/scheduler/remove [ find where name="_FlushGotifyQueue" ]; + :set GotifyQueue; +} + +# send notification via Gotify - expects at least two string arguments +:set SendGotify do={ :do { + :global SendGotify2; + + $SendGotify2 ({ origin=$0; subject=$1; message=$2; link=$3; silent=$4 }); +} on-error={ + :global ExitError; $ExitError false $0; +} } + +# send notification via Gotify - expects one array argument +:set SendGotify2 do={ + :local Notification $1; + + :global NotificationFunctions; + + ($NotificationFunctions->"gotify") ("\$NotificationFunctions->\"gotify\"") $Notification; +} diff --git a/news-and-changes.rsc b/news-and-changes.rsc index 55b4165..a9a2904 100644 --- a/news-and-changes.rsc +++ b/news-and-changes.rsc @@ -61,6 +61,7 @@ 134="Enhanced 'mod/notification-telegram' and 'telegram-chat' to support topics in groups."; 135="Introduced helper function '\$GetTelegramChatId' for 'mod/notification-telegram' which helps retrieve information."; 136="Introduced script 'check-perpetual-license' to check for license state on CHR."; + 137="Added support to send notifications via Gotify (gotify.net)."; }; # Migration steps to be applied on script updates From 07541a3cbcacdc53c7108fabb17deb73e5c93bef Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Sat, 26 Apr 2025 01:18:40 +0200 Subject: [PATCH 073/291] update list of contributors --- CONTRIBUTIONS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTIONS.md b/CONTRIBUTIONS.md index 0b89453..5bf5d08 100644 --- a/CONTRIBUTIONS.md +++ b/CONTRIBUTIONS.md @@ -22,6 +22,7 @@ for details! * [Daniel Ziegenberg](mailto:daniel@ziegenberg.at) (@ziegenberg) * [Ignacio Serrano](mailto:ignic@ignic.com) (@ignic) * [Ilya Kulakov](mailto:kulakov.ilya@gmail.com) (@Kentzo) +* [Leonardo David Monteiro](mailto:leo@cub3.xyz) (@leosfsm) * [Michael Gisbers](mailto:michael@gisbers.de) (@mgisbers) * [Miquel Bonastre](mailto:mbonastre@yahoo.com) (@mbonastre) * @netravnen From fa83c76be17c6a6bb1472c7e1e7dacf20178397f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Sat, 26 Apr 2025 00:54:46 +0200 Subject: [PATCH 074/291] doc/check-lte-firmware-upgrade: add missing reference for ntfy --- doc/check-lte-firmware-upgrade.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/check-lte-firmware-upgrade.md b/doc/check-lte-firmware-upgrade.md index a84e2ac..a0c441e 100644 --- a/doc/check-lte-firmware-upgrade.md +++ b/doc/check-lte-firmware-upgrade.md @@ -45,7 +45,8 @@ Configuration Also notification settings are required for [e-mail](mod/notification-email.md), [gotify](mod/notification-gotify.md), -[matrix](mod/notification-matrix.md) and/or +[matrix](mod/notification-matrix.md), +[ntfy](mod/notification-ntfy.md) and/or [telegram](mod/notification-telegram.md). See also From 154fb438002c0103eef88a207f0f86b417a86dda Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Sat, 3 May 2025 22:01:47 +0200 Subject: [PATCH 075/291] mod/notification-ntfy: drop unused variable --- mod/notification-ntfy.rsc | 1 - 1 file changed, 1 deletion(-) diff --git a/mod/notification-ntfy.rsc b/mod/notification-ntfy.rsc index aac6d6c..2748c5b 100644 --- a/mod/notification-ntfy.rsc +++ b/mod/notification-ntfy.rsc @@ -18,7 +18,6 @@ # flush ntfy queue :set FlushNtfyQueue do={ :do { :global NtfyQueue; - :global NtfyMessageIDs; :global IsFullyConnected; :global LogPrint; From ccfe1a781edc2990575cca57d49582e7e046d960 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:25:28 +0200 Subject: [PATCH 076/291] check-routeros-update: log and print info with scheduler --- check-routeros-update.rsc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/check-routeros-update.rsc b/check-routeros-update.rsc index 361be34..1b68d5a 100644 --- a/check-routeros-update.rsc +++ b/check-routeros-update.rsc @@ -62,8 +62,9 @@ $WaitFullyConnected; :if ([ :len [ /system/scheduler/find where name="_RebootForUpdate" ] ] > 0) do={ + $LogPrint info $ScriptName ("A reboot for update is already scheduled."); :set ExitOK true; - :error "A reboot for update is already scheduled."; + :error false; } $LogPrint debug $ScriptName ("Checking for updates..."); From 90f61d3d75bccb8f8892dc7190ec325ccc7d940f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:17:26 +0200 Subject: [PATCH 077/291] global-functions: $ExitError: support to pass in error message --- global-functions.rsc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/global-functions.rsc b/global-functions.rsc index 71aa7de..17b3674 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -452,13 +452,15 @@ :set ExitError do={ :local ExitOK [ :tostr $1 ]; :local Name [ :tostr $2 ]; + :local Error [ :tostr $3 ]; :global IfThenElse; :global LogPrint; :if ($ExitOK = "false") do={ $LogPrint error $Name ([ $IfThenElse ([ :pick $Name 0 1 ] = "\$") \ - "Function" "Script" ] . " '" . $Name . "' exited with error."); + "Function" "Script" ] . " '" . $Name . "' exited with error" . \ + [ $IfThenElse (!($Error ~ "^(|true|false)\$")) (": " . $Error) "." ]); } } From 41bf9677db821c1d2c2479dc4f6f8b8740f3bdbe Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:49:49 +0200 Subject: [PATCH 078/291] global-functions: use :onerror for outer block --- global-functions.rsc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index 17b3674..29e6d06 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -1119,7 +1119,7 @@ } # install new scripts, update existing scripts -:set ScriptInstallUpdate do={ :do { +:set ScriptInstallUpdate do={ :onerror Err { :local Scripts [ :toarray $1 ]; :local NewComment [ :tostr $2 ]; @@ -1396,8 +1396,8 @@ :set GlobalConfigChanges; :set GlobalConfigMigration; } -} on-error={ - :global ExitError; $ExitError false $0; +} do={ + :global ExitError; $ExitError false $0 $Err; } } # lock script against multiple invocation @@ -1538,12 +1538,12 @@ } # send notification via NotificationFunctions - expects at least two string arguments -:set SendNotification do={ :do { +:set SendNotification do={ :onerror Err { :global SendNotification2; $SendNotification2 ({ origin=$0; subject=$1; message=$2; link=$3; silent=$4 }); -} on-error={ - :global ExitError; $ExitError false $0; +} do={ + :global ExitError; $ExitError false $0 $Err; } } # send notification via NotificationFunctions - expects one array argument From b9faeb86b98cc1667f0591dfd34ca43dbd6a718b Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 079/291] accesslist-duplicates: use :onerror for outer block --- accesslist-duplicates.capsman.rsc | 6 +++--- accesslist-duplicates.local.rsc | 6 +++--- accesslist-duplicates.template.rsc | 6 +++--- accesslist-duplicates.wifi.rsc | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/accesslist-duplicates.capsman.rsc b/accesslist-duplicates.capsman.rsc index 27546c8..c096754 100644 --- a/accesslist-duplicates.capsman.rsc +++ b/accesslist-duplicates.capsman.rsc @@ -14,7 +14,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :local Seen ({}); @@ -32,6 +32,6 @@ } :set ($Seen->$Mac) 1; } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/accesslist-duplicates.local.rsc b/accesslist-duplicates.local.rsc index 589815d..6f2d120 100644 --- a/accesslist-duplicates.local.rsc +++ b/accesslist-duplicates.local.rsc @@ -14,7 +14,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :local Seen ({}); @@ -32,6 +32,6 @@ } :set ($Seen->$Mac) 1; } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/accesslist-duplicates.template.rsc b/accesslist-duplicates.template.rsc index ccbca3d..b08f2ad 100644 --- a/accesslist-duplicates.template.rsc +++ b/accesslist-duplicates.template.rsc @@ -15,7 +15,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :local Seen ({}); @@ -41,6 +41,6 @@ } :set ($Seen->$Mac) 1; } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/accesslist-duplicates.wifi.rsc b/accesslist-duplicates.wifi.rsc index 527ebb4..ccd04f5 100644 --- a/accesslist-duplicates.wifi.rsc +++ b/accesslist-duplicates.wifi.rsc @@ -14,7 +14,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :local Seen ({}); @@ -32,6 +32,6 @@ } :set ($Seen->$Mac) 1; } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From 02a205b14ecec27f535b0453c012e27a03c2a6ed Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 080/291] backup-cloud: use :onerror for outer block --- backup-cloud.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backup-cloud.rsc b/backup-cloud.rsc index c4e23b2..bc09aac 100644 --- a/backup-cloud.rsc +++ b/backup-cloud.rsc @@ -13,7 +13,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global BackupRandomDelay; @@ -99,6 +99,6 @@ :set PackagesUpdateBackupFailure true; } $RmDir "tmpfs/backup-cloud"; -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From 953daca8ac06c01050057f1e14e2020a58116f50 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 081/291] backup-email: use :onerror for outer block --- backup-email.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backup-email.rsc b/backup-email.rsc index d097301..95f2510 100644 --- a/backup-email.rsc +++ b/backup-email.rsc @@ -13,7 +13,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global BackupPassword; @@ -135,6 +135,6 @@ :delay 1s; :set I ($I + 1); } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From 34c052c5f14da6d9a68861f26b383594ee61bcb4 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 082/291] backup-partition: use :onerror for outer block --- backup-partition.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backup-partition.rsc b/backup-partition.rsc index 1f0cf2e..42f7790 100644 --- a/backup-partition.rsc +++ b/backup-partition.rsc @@ -14,7 +14,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global BackupPartitionCopyBeforeFeatureUpdate; @@ -121,6 +121,6 @@ :set ExitOK true; :error false; } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From 0a9acab0405fc5ec5081e6f423c04e26c1847cac Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 083/291] backup-upload: use :onerror for outer block --- backup-upload.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backup-upload.rsc b/backup-upload.rsc index 14c3914..945659a 100644 --- a/backup-upload.rsc +++ b/backup-upload.rsc @@ -14,7 +14,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global BackupPassword; @@ -173,6 +173,6 @@ :set PackagesUpdateBackupFailure true; } $RmDir $DirName; -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From e0ba2c8282be0af1a1f43a5ebd51fb5848c955b9 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 084/291] capsman-download-packages: use :onerror for outer block --- capsman-download-packages.capsman.rsc | 6 +++--- capsman-download-packages.template.rsc | 6 +++--- capsman-download-packages.wifi.rsc | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/capsman-download-packages.capsman.rsc b/capsman-download-packages.capsman.rsc index 25c43f5..688f704 100644 --- a/capsman-download-packages.capsman.rsc +++ b/capsman-download-packages.capsman.rsc @@ -15,7 +15,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global CleanFilePath; @@ -87,6 +87,6 @@ /caps-man/remote-cap/upgrade [ find where version!=$InstalledVersion ]; } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/capsman-download-packages.template.rsc b/capsman-download-packages.template.rsc index b269838..12506ea 100644 --- a/capsman-download-packages.template.rsc +++ b/capsman-download-packages.template.rsc @@ -16,7 +16,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global CleanFilePath; @@ -98,6 +98,6 @@ /interface/wifi/capsman/remote-cap/upgrade [ find where version!=$InstalledVersion ]; } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/capsman-download-packages.wifi.rsc b/capsman-download-packages.wifi.rsc index 901bb0a..78238ef 100644 --- a/capsman-download-packages.wifi.rsc +++ b/capsman-download-packages.wifi.rsc @@ -15,7 +15,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global CleanFilePath; @@ -89,6 +89,6 @@ /interface/wifi/capsman/remote-cap/upgrade [ find where version!=$InstalledVersion ]; } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From 54a3012e89a4b377a1f5f1ac9435b7d3a8912ec1 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 085/291] capsman-rolling-upgrade: use :onerror for outer block --- capsman-rolling-upgrade.capsman.rsc | 6 +++--- capsman-rolling-upgrade.template.rsc | 6 +++--- capsman-rolling-upgrade.wifi.rsc | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/capsman-rolling-upgrade.capsman.rsc b/capsman-rolling-upgrade.capsman.rsc index 791b3db..813b8e5 100644 --- a/capsman-rolling-upgrade.capsman.rsc +++ b/capsman-rolling-upgrade.capsman.rsc @@ -16,7 +16,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global LogPrint; @@ -45,6 +45,6 @@ :delay ($Delay . "s"); } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/capsman-rolling-upgrade.template.rsc b/capsman-rolling-upgrade.template.rsc index 0b1cc2b..355926d 100644 --- a/capsman-rolling-upgrade.template.rsc +++ b/capsman-rolling-upgrade.template.rsc @@ -17,7 +17,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global LogPrint; @@ -53,6 +53,6 @@ :delay ($Delay . "s"); } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/capsman-rolling-upgrade.wifi.rsc b/capsman-rolling-upgrade.wifi.rsc index 4afdee2..3d5c801 100644 --- a/capsman-rolling-upgrade.wifi.rsc +++ b/capsman-rolling-upgrade.wifi.rsc @@ -16,7 +16,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global LogPrint; @@ -46,6 +46,6 @@ :delay ($Delay . "s"); } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From 009516dbd4525126d688b26e189fa7f3be893f93 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 086/291] certificate-renew-issued: use :onerror for outer block --- certificate-renew-issued.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/certificate-renew-issued.rsc b/certificate-renew-issued.rsc index 91a48de..dc724b0 100644 --- a/certificate-renew-issued.rsc +++ b/certificate-renew-issued.rsc @@ -12,7 +12,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global CertIssuedExportPass; @@ -47,6 +47,6 @@ $LogPrint info $ScriptName ("Issued a new certificate for '" . $CertVal->"common-name" . "'."); } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From e44a5384b7e21e0013746a1d06762d969d5b45d7 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 087/291] check-certificates: use :onerror for outer block --- check-certificates.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/check-certificates.rsc b/check-certificates.rsc index be8e4df..75a006e 100644 --- a/check-certificates.rsc +++ b/check-certificates.rsc @@ -13,7 +13,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global CertRenewTime; @@ -237,6 +237,6 @@ ", it is invalid after " . ($CertVal->"invalid-after") . "."); } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From 051a1d95e5e1f5e90e79d505ef4bf542344cd64d Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 088/291] check-health: use :onerror for outer block --- check-health.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/check-health.rsc b/check-health.rsc index f02a249..75710a0 100644 --- a/check-health.rsc +++ b/check-health.rsc @@ -12,7 +12,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global CheckHealthCPUUtilization; @@ -105,6 +105,6 @@ } :set CheckHealthPlugins; -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From b959f2d941a87bd24e3495ca3d30a765200f8698 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 089/291] check-lte-firmware-upgrade: use :onerror for outer block --- check-lte-firmware-upgrade.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/check-lte-firmware-upgrade.rsc b/check-lte-firmware-upgrade.rsc index c5b6cb5..f0b173f 100644 --- a/check-lte-firmware-upgrade.rsc +++ b/check-lte-firmware-upgrade.rsc @@ -12,7 +12,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global SentLteFirmwareUpgradeNotification; @@ -102,6 +102,6 @@ :foreach Interface in=[ /interface/lte/find ] do={ $CheckInterface $ScriptName $Interface; } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From f5c33a9cfb367cf80b2bf34a924f95d6e124c454 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 090/291] check-perpetual-license: use :onerror for outer block --- check-perpetual-license.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/check-perpetual-license.rsc b/check-perpetual-license.rsc index 9a3a3c7..7caa69a 100644 --- a/check-perpetual-license.rsc +++ b/check-perpetual-license.rsc @@ -12,7 +12,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global Identity; @@ -73,6 +73,6 @@ ". It is now valid until " . ($License->"deadline-at") . ".") }); :set SentCertificateNotification; } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From 472dc9289dd1bf9309c17341bd996149ef0837d8 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 091/291] check-routeros-update: use :onerror for outer block --- check-routeros-update.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/check-routeros-update.rsc b/check-routeros-update.rsc index 1b68d5a..ee7e5da 100644 --- a/check-routeros-update.rsc +++ b/check-routeros-update.rsc @@ -13,7 +13,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global Identity; @@ -214,6 +214,6 @@ " is available for downgrade."); :set SentRouterosUpdateNotification ($Update->"latest-version"); } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From 7d8e9fda29f219471d8d68e1feb70e01e8d7e8dc Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 092/291] collect-wireless-mac: use :onerror for outer block --- collect-wireless-mac.capsman.rsc | 6 +++--- collect-wireless-mac.local.rsc | 6 +++--- collect-wireless-mac.template.rsc | 6 +++--- collect-wireless-mac.wifi.rsc | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/collect-wireless-mac.capsman.rsc b/collect-wireless-mac.capsman.rsc index 17e09e3..5cec9b9 100644 --- a/collect-wireless-mac.capsman.rsc +++ b/collect-wireless-mac.capsman.rsc @@ -15,7 +15,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global Identity; @@ -95,6 +95,6 @@ $LogPrint debug $ScriptName ("No mac address available... Ignoring."); } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/collect-wireless-mac.local.rsc b/collect-wireless-mac.local.rsc index 4a38bfa..db75d69 100644 --- a/collect-wireless-mac.local.rsc +++ b/collect-wireless-mac.local.rsc @@ -15,7 +15,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global Identity; @@ -96,6 +96,6 @@ $LogPrint debug $ScriptName ("No mac address available... Ignoring."); } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/collect-wireless-mac.template.rsc b/collect-wireless-mac.template.rsc index da901be..144a8be 100644 --- a/collect-wireless-mac.template.rsc +++ b/collect-wireless-mac.template.rsc @@ -16,7 +16,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global Identity; @@ -113,6 +113,6 @@ $LogPrint debug $ScriptName ("No mac address available... Ignoring."); } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/collect-wireless-mac.wifi.rsc b/collect-wireless-mac.wifi.rsc index cb217ce..74f3ec6 100644 --- a/collect-wireless-mac.wifi.rsc +++ b/collect-wireless-mac.wifi.rsc @@ -15,7 +15,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global Identity; @@ -95,6 +95,6 @@ $LogPrint debug $ScriptName ("No mac address available... Ignoring."); } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From 55e07a8a4223850c94e24706fcf929c2328415d2 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 093/291] daily-psk: use :onerror for outer block --- daily-psk.capsman.rsc | 6 +++--- daily-psk.local.rsc | 6 +++--- daily-psk.template.rsc | 6 +++--- daily-psk.wifi.rsc | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/daily-psk.capsman.rsc b/daily-psk.capsman.rsc index 5672931..e4e7b8b 100644 --- a/daily-psk.capsman.rsc +++ b/daily-psk.capsman.rsc @@ -15,7 +15,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global DailyPskMatchComment; @@ -91,6 +91,6 @@ } } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/daily-psk.local.rsc b/daily-psk.local.rsc index 9dea469..efea9b5 100644 --- a/daily-psk.local.rsc +++ b/daily-psk.local.rsc @@ -15,7 +15,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global DailyPskMatchComment; @@ -90,6 +90,6 @@ } } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/daily-psk.template.rsc b/daily-psk.template.rsc index 8202eeb..5944c74 100644 --- a/daily-psk.template.rsc +++ b/daily-psk.template.rsc @@ -16,7 +16,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global DailyPskMatchComment; @@ -106,6 +106,6 @@ } } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/daily-psk.wifi.rsc b/daily-psk.wifi.rsc index 3de3c5b..050e9c2 100644 --- a/daily-psk.wifi.rsc +++ b/daily-psk.wifi.rsc @@ -15,7 +15,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global DailyPskMatchComment; @@ -91,6 +91,6 @@ } } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From 5dc6b712e187af1e84b75d7e497ad7f50ca1bad7 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 094/291] dhcp-lease-comment: use :onerror for outer block --- dhcp-lease-comment.capsman.rsc | 6 +++--- dhcp-lease-comment.local.rsc | 6 +++--- dhcp-lease-comment.template.rsc | 6 +++--- dhcp-lease-comment.wifi.rsc | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/dhcp-lease-comment.capsman.rsc b/dhcp-lease-comment.capsman.rsc index 36b31c8..92495c9 100644 --- a/dhcp-lease-comment.capsman.rsc +++ b/dhcp-lease-comment.capsman.rsc @@ -15,7 +15,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global LogPrint; @@ -38,6 +38,6 @@ /ip/dhcp-server/lease/set comment=$NewComment $Lease; } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/dhcp-lease-comment.local.rsc b/dhcp-lease-comment.local.rsc index 35dc6f6..07802bc 100644 --- a/dhcp-lease-comment.local.rsc +++ b/dhcp-lease-comment.local.rsc @@ -15,7 +15,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global LogPrint; @@ -38,6 +38,6 @@ /ip/dhcp-server/lease/set comment=$NewComment $Lease; } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/dhcp-lease-comment.template.rsc b/dhcp-lease-comment.template.rsc index 47a8554..814e1d7 100644 --- a/dhcp-lease-comment.template.rsc +++ b/dhcp-lease-comment.template.rsc @@ -16,7 +16,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global LogPrint; @@ -43,6 +43,6 @@ /ip/dhcp-server/lease/set comment=$NewComment $Lease; } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/dhcp-lease-comment.wifi.rsc b/dhcp-lease-comment.wifi.rsc index e0f9785..92fb6b0 100644 --- a/dhcp-lease-comment.wifi.rsc +++ b/dhcp-lease-comment.wifi.rsc @@ -15,7 +15,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global LogPrint; @@ -38,6 +38,6 @@ /ip/dhcp-server/lease/set comment=$NewComment $Lease; } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From 8ed83a311d3b9140b01c2dd5064f59ad4bcc3955 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 095/291] dhcp-to-dns: use :onerror for outer block --- dhcp-to-dns.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dhcp-to-dns.rsc b/dhcp-to-dns.rsc index 9b94098..b032071 100644 --- a/dhcp-to-dns.rsc +++ b/dhcp-to-dns.rsc @@ -13,7 +13,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global Domain; @@ -125,6 +125,6 @@ $LogPrint debug $ScriptName ("No address available... Ignoring."); } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From d99380443b1607389d107bf0fbc4182168a4d8b0 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 096/291] firmware-upgrade-reboot: use :onerror for outer block --- firmware-upgrade-reboot.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/firmware-upgrade-reboot.rsc b/firmware-upgrade-reboot.rsc index 86a9a8c..9c3ba76 100644 --- a/firmware-upgrade-reboot.rsc +++ b/firmware-upgrade-reboot.rsc @@ -12,7 +12,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global LogPrint; @@ -55,6 +55,6 @@ $LogPrint info $ScriptName ("Firmware upgrade successful, rebooting."); /system/reboot; -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From 0e93d8ca665100a0db14b4191c494af51a238a35 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 097/291] fw-addr-lists: use :onerror for outer block --- fw-addr-lists.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fw-addr-lists.rsc b/fw-addr-lists.rsc index f0940fe..0fd79c1 100644 --- a/fw-addr-lists.rsc +++ b/fw-addr-lists.rsc @@ -12,7 +12,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global FwAddrLists; @@ -209,6 +209,6 @@ " - renewed: " . [ $HumanReadableNum $CntRenew 1000 ] . \ " - removed: " . [ $HumanReadableNum $CntRemove 1000 ]); } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From d609da00416f95eb74e9742dbc0a981a5b9a41b5 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 098/291] gps-track: use :onerror for outer block --- gps-track.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gps-track.rsc b/gps-track.rsc index dea56d2..bd280c9 100644 --- a/gps-track.rsc +++ b/gps-track.rsc @@ -13,7 +13,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global GpsTrackUrl; @@ -48,6 +48,6 @@ } else={ $LogPrint debug $ScriptName ("GPS data not valid."); } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From 143b8a8ddc2b30940333b95e09d23574076e48cb Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 099/291] hotspot-to-wpa-cleanup: use :onerror for outer block --- hotspot-to-wpa-cleanup.capsman.rsc | 6 +++--- hotspot-to-wpa-cleanup.template.rsc | 6 +++--- hotspot-to-wpa-cleanup.wifi.rsc | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hotspot-to-wpa-cleanup.capsman.rsc b/hotspot-to-wpa-cleanup.capsman.rsc index 033d0e7..6cd1bfb 100644 --- a/hotspot-to-wpa-cleanup.capsman.rsc +++ b/hotspot-to-wpa-cleanup.capsman.rsc @@ -16,7 +16,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global EitherOr; @@ -75,6 +75,6 @@ /ip/dhcp-server/lease/remove $Lease; } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/hotspot-to-wpa-cleanup.template.rsc b/hotspot-to-wpa-cleanup.template.rsc index 0f8c490..18d6bea 100644 --- a/hotspot-to-wpa-cleanup.template.rsc +++ b/hotspot-to-wpa-cleanup.template.rsc @@ -17,7 +17,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global EitherOr; @@ -82,6 +82,6 @@ /ip/dhcp-server/lease/remove $Lease; } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/hotspot-to-wpa-cleanup.wifi.rsc b/hotspot-to-wpa-cleanup.wifi.rsc index dfec697..6348f74 100644 --- a/hotspot-to-wpa-cleanup.wifi.rsc +++ b/hotspot-to-wpa-cleanup.wifi.rsc @@ -16,7 +16,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global EitherOr; @@ -75,6 +75,6 @@ /ip/dhcp-server/lease/remove $Lease; } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From 9ae733a1678577a96ba00a79de347a18c8cec319 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 100/291] hotspot-to-wpa: use :onerror for outer block --- hotspot-to-wpa.capsman.rsc | 6 +++--- hotspot-to-wpa.template.rsc | 6 +++--- hotspot-to-wpa.wifi.rsc | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hotspot-to-wpa.capsman.rsc b/hotspot-to-wpa.capsman.rsc index 3f51475..54724cf 100644 --- a/hotspot-to-wpa.capsman.rsc +++ b/hotspot-to-wpa.capsman.rsc @@ -15,7 +15,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global EitherOr; @@ -100,6 +100,6 @@ :delay 2s; /caps-man/access-list/set $Entry action=accept; -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/hotspot-to-wpa.template.rsc b/hotspot-to-wpa.template.rsc index 068241d..6764af9 100644 --- a/hotspot-to-wpa.template.rsc +++ b/hotspot-to-wpa.template.rsc @@ -16,7 +16,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global EitherOr; @@ -120,6 +120,6 @@ :delay 2s; /caps-man/access-list/set $Entry action=accept; /interface/wifi/access-list/set $Entry action=accept; -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/hotspot-to-wpa.wifi.rsc b/hotspot-to-wpa.wifi.rsc index cc5e2fc..e74081a 100644 --- a/hotspot-to-wpa.wifi.rsc +++ b/hotspot-to-wpa.wifi.rsc @@ -15,7 +15,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global EitherOr; @@ -97,6 +97,6 @@ :delay 2s; /interface/wifi/access-list/set $Entry action=accept; -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From 1075b6b24e8875ced9da78f0a9c112283e345f21 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 101/291] ipsec-to-dns: use :onerror for outer block --- ipsec-to-dns.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ipsec-to-dns.rsc b/ipsec-to-dns.rsc index 26dab0a..a273932 100644 --- a/ipsec-to-dns.rsc +++ b/ipsec-to-dns.rsc @@ -13,7 +13,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global Domain; @@ -79,6 +79,6 @@ /ip/dns/static/add name=$Fqdn address=($PeerVal->"dynamic-address") ttl=$Ttl comment=$Comment place-before=$PlaceBefore; } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From 39ab19b272160f85df034a5f71d4d5dd5748e962 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 102/291] ipv6-update: use :onerror for outer block --- ipv6-update.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ipv6-update.rsc b/ipv6-update.rsc index 94bd1bc..633919d 100644 --- a/ipv6-update.rsc +++ b/ipv6-update.rsc @@ -12,7 +12,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global LogPrint; @@ -102,6 +102,6 @@ } } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From da9313801774c2f5d7c02d1b5bd3ac001e0be20f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 103/291] lease-script: use :onerror for outer block --- lease-script.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lease-script.rsc b/lease-script.rsc index bf27fda..309337c 100644 --- a/lease-script.rsc +++ b/lease-script.rsc @@ -12,7 +12,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global Grep; @@ -60,6 +60,6 @@ $LogPrint warning $ScriptName ("Running script '" . $Script . "' failed!"); } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From c643069b3e77cca143f3f58ad10fe69c9eda69e2 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 104/291] log-forward: use :onerror for outer block --- log-forward.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/log-forward.rsc b/log-forward.rsc index afeb3f2..0ce420f 100644 --- a/log-forward.rsc +++ b/log-forward.rsc @@ -12,7 +12,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global Identity; @@ -108,6 +108,6 @@ :local LogAll [ /log/find ]; :set LogForwardLast ($LogAll->([ :len $LogAll ] - 1) ); -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From 9acf9781cbe85c23b76bd82d1843b7fc9fa16913 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 105/291] accesslist-duplicates: fail if global functions do not become ready --- accesslist-duplicates.capsman.rsc | 6 +++--- accesslist-duplicates.local.rsc | 6 +++--- accesslist-duplicates.template.rsc | 6 +++--- accesslist-duplicates.wifi.rsc | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/accesslist-duplicates.capsman.rsc b/accesslist-duplicates.capsman.rsc index c096754..545b24e 100644 --- a/accesslist-duplicates.capsman.rsc +++ b/accesslist-duplicates.capsman.rsc @@ -10,11 +10,11 @@ # # !! Do not edit this file, it is generated from template! -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :local Seen ({}); diff --git a/accesslist-duplicates.local.rsc b/accesslist-duplicates.local.rsc index 6f2d120..ac2c7fe 100644 --- a/accesslist-duplicates.local.rsc +++ b/accesslist-duplicates.local.rsc @@ -10,11 +10,11 @@ # # !! Do not edit this file, it is generated from template! -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :local Seen ({}); diff --git a/accesslist-duplicates.template.rsc b/accesslist-duplicates.template.rsc index b08f2ad..8955991 100644 --- a/accesslist-duplicates.template.rsc +++ b/accesslist-duplicates.template.rsc @@ -11,11 +11,11 @@ # !! This is just a template to generate the real script! # !! Pattern '%TEMPL%' is replaced, paths are filtered. -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :local Seen ({}); diff --git a/accesslist-duplicates.wifi.rsc b/accesslist-duplicates.wifi.rsc index ccd04f5..331de75 100644 --- a/accesslist-duplicates.wifi.rsc +++ b/accesslist-duplicates.wifi.rsc @@ -10,11 +10,11 @@ # # !! Do not edit this file, it is generated from template! -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :local Seen ({}); From 7d4e4ec273342ce0738102ce123deb673b199d3f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 106/291] backup-cloud: fail if global functions do not become ready --- backup-cloud.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backup-cloud.rsc b/backup-cloud.rsc index bc09aac..f0861f0 100644 --- a/backup-cloud.rsc +++ b/backup-cloud.rsc @@ -9,11 +9,11 @@ # upload backup to MikroTik cloud # https://rsc.eworm.de/doc/backup-cloud.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global BackupRandomDelay; From 64ec962bb6de5cef73a2c0da378f4e49a73e6e8e Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 107/291] backup-email: fail if global functions do not become ready --- backup-email.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backup-email.rsc b/backup-email.rsc index 95f2510..da2ee02 100644 --- a/backup-email.rsc +++ b/backup-email.rsc @@ -9,11 +9,11 @@ # create and email backup and config file # https://rsc.eworm.de/doc/backup-email.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global BackupPassword; From bf1b3e3c5e7943309fbb1b036babd628b827dc63 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 108/291] backup-partition: fail if global functions do not become ready --- backup-partition.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backup-partition.rsc b/backup-partition.rsc index 42f7790..f99a66c 100644 --- a/backup-partition.rsc +++ b/backup-partition.rsc @@ -10,11 +10,11 @@ # save configuration to fallback partition # https://rsc.eworm.de/doc/backup-partition.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global BackupPartitionCopyBeforeFeatureUpdate; From 9423d8019a5aa7a78f9fea16b228af112848f1f3 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 109/291] backup-upload: fail if global functions do not become ready --- backup-upload.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backup-upload.rsc b/backup-upload.rsc index 945659a..9373b4c 100644 --- a/backup-upload.rsc +++ b/backup-upload.rsc @@ -10,11 +10,11 @@ # create and upload backup and config file # https://rsc.eworm.de/doc/backup-upload.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global BackupPassword; From 33393798b1a7eb5756b1da6b89d72daff05eea96 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 110/291] capsman-download-packages: fail if global functions do not become ready --- capsman-download-packages.capsman.rsc | 6 +++--- capsman-download-packages.template.rsc | 6 +++--- capsman-download-packages.wifi.rsc | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/capsman-download-packages.capsman.rsc b/capsman-download-packages.capsman.rsc index 688f704..ee82638 100644 --- a/capsman-download-packages.capsman.rsc +++ b/capsman-download-packages.capsman.rsc @@ -11,11 +11,11 @@ # # !! Do not edit this file, it is generated from template! -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global CleanFilePath; diff --git a/capsman-download-packages.template.rsc b/capsman-download-packages.template.rsc index 12506ea..91a9167 100644 --- a/capsman-download-packages.template.rsc +++ b/capsman-download-packages.template.rsc @@ -12,11 +12,11 @@ # !! This is just a template to generate the real script! # !! Pattern '%TEMPL%' is replaced, paths are filtered. -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global CleanFilePath; diff --git a/capsman-download-packages.wifi.rsc b/capsman-download-packages.wifi.rsc index 78238ef..cb6cb6f 100644 --- a/capsman-download-packages.wifi.rsc +++ b/capsman-download-packages.wifi.rsc @@ -11,11 +11,11 @@ # # !! Do not edit this file, it is generated from template! -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global CleanFilePath; From de5aab12ae2e3d8db965925941746d202813650a Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 111/291] capsman-rolling-upgrade: fail if global functions do not become ready --- capsman-rolling-upgrade.capsman.rsc | 6 +++--- capsman-rolling-upgrade.template.rsc | 6 +++--- capsman-rolling-upgrade.wifi.rsc | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/capsman-rolling-upgrade.capsman.rsc b/capsman-rolling-upgrade.capsman.rsc index 813b8e5..2097880 100644 --- a/capsman-rolling-upgrade.capsman.rsc +++ b/capsman-rolling-upgrade.capsman.rsc @@ -12,11 +12,11 @@ # # !! Do not edit this file, it is generated from template! -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global LogPrint; diff --git a/capsman-rolling-upgrade.template.rsc b/capsman-rolling-upgrade.template.rsc index 355926d..75de088 100644 --- a/capsman-rolling-upgrade.template.rsc +++ b/capsman-rolling-upgrade.template.rsc @@ -13,11 +13,11 @@ # !! This is just a template to generate the real script! # !! Pattern '%TEMPL%' is replaced, paths are filtered. -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global LogPrint; diff --git a/capsman-rolling-upgrade.wifi.rsc b/capsman-rolling-upgrade.wifi.rsc index 3d5c801..e6c6fac 100644 --- a/capsman-rolling-upgrade.wifi.rsc +++ b/capsman-rolling-upgrade.wifi.rsc @@ -12,11 +12,11 @@ # # !! Do not edit this file, it is generated from template! -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global LogPrint; From b4188ab1a2356c0ce5f70f449a185900decc86ea Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 112/291] certificate-renew-issued: fail if global functions do not become ready --- certificate-renew-issued.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/certificate-renew-issued.rsc b/certificate-renew-issued.rsc index dc724b0..3fd6020 100644 --- a/certificate-renew-issued.rsc +++ b/certificate-renew-issued.rsc @@ -8,11 +8,11 @@ # renew locally issued certificates # https://rsc.eworm.de/doc/certificate-renew-issued.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global CertIssuedExportPass; From 9b811e1ed25c9fc6c47eb4ef4d31036e3b7e3d0a Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 113/291] check-certificates: fail if global functions do not become ready --- check-certificates.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/check-certificates.rsc b/check-certificates.rsc index 75a006e..505ec4b 100644 --- a/check-certificates.rsc +++ b/check-certificates.rsc @@ -9,11 +9,11 @@ # check for certificate validity # https://rsc.eworm.de/doc/check-certificates.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global CertRenewTime; From 96cbb32a4f073e11f264e4a641cb304de49fb435 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 114/291] check-health: fail if global functions do not become ready --- check-health.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/check-health.rsc b/check-health.rsc index 75710a0..40ce101 100644 --- a/check-health.rsc +++ b/check-health.rsc @@ -8,11 +8,11 @@ # check for RouterOS health state # https://rsc.eworm.de/doc/check-health.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global CheckHealthCPUUtilization; From 8f1ac6fa17afd96afb82de31f0e997b73f40d883 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 115/291] check-lte-firmware-upgrade: fail if global functions do not become ready --- check-lte-firmware-upgrade.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/check-lte-firmware-upgrade.rsc b/check-lte-firmware-upgrade.rsc index f0b173f..6030e4d 100644 --- a/check-lte-firmware-upgrade.rsc +++ b/check-lte-firmware-upgrade.rsc @@ -8,11 +8,11 @@ # check for LTE firmware upgrade, send notification # https://rsc.eworm.de/doc/check-lte-firmware-upgrade.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global SentLteFirmwareUpgradeNotification; From 08d78224a000751409cd715c4219aae3e2ac9eba Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 116/291] check-perpetual-license: fail if global functions do not become ready --- check-perpetual-license.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/check-perpetual-license.rsc b/check-perpetual-license.rsc index 7caa69a..d46f0b4 100644 --- a/check-perpetual-license.rsc +++ b/check-perpetual-license.rsc @@ -8,11 +8,11 @@ # check perpetual license on CHR # https://rsc.eworm.de/doc/check-perpetual-license.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global Identity; From 69b2af4bd7ac5f63860532c36d762953adf87d90 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 10:46:44 +0200 Subject: [PATCH 117/291] check-routeros-update: fail if global functions do not become ready --- check-routeros-update.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/check-routeros-update.rsc b/check-routeros-update.rsc index ee7e5da..932256a 100644 --- a/check-routeros-update.rsc +++ b/check-routeros-update.rsc @@ -9,11 +9,11 @@ # check for RouterOS update, send notification and/or install # https://rsc.eworm.de/doc/check-routeros-update.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global Identity; From 2712bcb44db3e323faf2ddc18ddd228fcdbf215a Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 118/291] collect-wireless-mac: fail if global functions do not become ready --- collect-wireless-mac.capsman.rsc | 6 +++--- collect-wireless-mac.local.rsc | 6 +++--- collect-wireless-mac.template.rsc | 6 +++--- collect-wireless-mac.wifi.rsc | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/collect-wireless-mac.capsman.rsc b/collect-wireless-mac.capsman.rsc index 5cec9b9..fa6198a 100644 --- a/collect-wireless-mac.capsman.rsc +++ b/collect-wireless-mac.capsman.rsc @@ -11,11 +11,11 @@ # # !! Do not edit this file, it is generated from template! -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global Identity; diff --git a/collect-wireless-mac.local.rsc b/collect-wireless-mac.local.rsc index db75d69..4082bbb 100644 --- a/collect-wireless-mac.local.rsc +++ b/collect-wireless-mac.local.rsc @@ -11,11 +11,11 @@ # # !! Do not edit this file, it is generated from template! -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global Identity; diff --git a/collect-wireless-mac.template.rsc b/collect-wireless-mac.template.rsc index 144a8be..5167156 100644 --- a/collect-wireless-mac.template.rsc +++ b/collect-wireless-mac.template.rsc @@ -12,11 +12,11 @@ # !! This is just a template to generate the real script! # !! Pattern '%TEMPL%' is replaced, paths are filtered. -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global Identity; diff --git a/collect-wireless-mac.wifi.rsc b/collect-wireless-mac.wifi.rsc index 74f3ec6..af0dd8b 100644 --- a/collect-wireless-mac.wifi.rsc +++ b/collect-wireless-mac.wifi.rsc @@ -11,11 +11,11 @@ # # !! Do not edit this file, it is generated from template! -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global Identity; From 8418d58ff0703d18db0e513bd71484dc93c9e821 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 119/291] daily-psk: fail if global functions do not become ready --- daily-psk.capsman.rsc | 6 +++--- daily-psk.local.rsc | 6 +++--- daily-psk.template.rsc | 6 +++--- daily-psk.wifi.rsc | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/daily-psk.capsman.rsc b/daily-psk.capsman.rsc index e4e7b8b..a1b01fc 100644 --- a/daily-psk.capsman.rsc +++ b/daily-psk.capsman.rsc @@ -11,11 +11,11 @@ # # !! Do not edit this file, it is generated from template! -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global DailyPskMatchComment; diff --git a/daily-psk.local.rsc b/daily-psk.local.rsc index efea9b5..6ba6ce2 100644 --- a/daily-psk.local.rsc +++ b/daily-psk.local.rsc @@ -11,11 +11,11 @@ # # !! Do not edit this file, it is generated from template! -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global DailyPskMatchComment; diff --git a/daily-psk.template.rsc b/daily-psk.template.rsc index 5944c74..43ce333 100644 --- a/daily-psk.template.rsc +++ b/daily-psk.template.rsc @@ -12,11 +12,11 @@ # !! This is just a template to generate the real script! # !! Pattern '%TEMPL%' is replaced, paths are filtered. -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global DailyPskMatchComment; diff --git a/daily-psk.wifi.rsc b/daily-psk.wifi.rsc index 050e9c2..7e1714d 100644 --- a/daily-psk.wifi.rsc +++ b/daily-psk.wifi.rsc @@ -11,11 +11,11 @@ # # !! Do not edit this file, it is generated from template! -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global DailyPskMatchComment; From ff03f49724cdcba8774de481779b5f7e7993dc36 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 120/291] mode-button: use :onerror for outer block --- mode-button.rsc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mode-button.rsc b/mode-button.rsc index edc5f40..83897ba 100644 --- a/mode-button.rsc +++ b/mode-button.rsc @@ -13,7 +13,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global ModeButton; @@ -26,7 +26,7 @@ :if ([ :len $Scheduler ] = 0) do={ $LogPrint info $ScriptName ("Creating scheduler _ModeButtonScheduler, counting presses..."); - :global ModeButtonScheduler do={ :do { + :global ModeButtonScheduler do={ :onerror Err { :local FuncName $0; :global ModeButton; @@ -82,8 +82,8 @@ } else={ $LogPrint info $FuncName ("No action defined for " . $Count . " mode-button presses."); } - } on-error={ - :global ExitError; $ExitError false $0; + } do={ + :global ExitError; $ExitError false $0 $Err; } } /system/scheduler/add name="_ModeButtonScheduler" \ on-event=":global ModeButtonScheduler; \$ModeButtonScheduler;" interval=3s; @@ -91,6 +91,6 @@ $LogPrint debug $ScriptName ("Updating scheduler _ModeButtonScheduler..."); /system/scheduler/set $Scheduler start-time=[ /system/clock/get time ]; } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From a556f4c39858223e75e60228f9618aaaf0cc0af7 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 121/291] dhcp-lease-comment: fail if global functions do not become ready --- dhcp-lease-comment.capsman.rsc | 6 +++--- dhcp-lease-comment.local.rsc | 6 +++--- dhcp-lease-comment.template.rsc | 6 +++--- dhcp-lease-comment.wifi.rsc | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/dhcp-lease-comment.capsman.rsc b/dhcp-lease-comment.capsman.rsc index 92495c9..724682b 100644 --- a/dhcp-lease-comment.capsman.rsc +++ b/dhcp-lease-comment.capsman.rsc @@ -11,11 +11,11 @@ # # !! Do not edit this file, it is generated from template! -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global LogPrint; diff --git a/dhcp-lease-comment.local.rsc b/dhcp-lease-comment.local.rsc index 07802bc..0a5f3b5 100644 --- a/dhcp-lease-comment.local.rsc +++ b/dhcp-lease-comment.local.rsc @@ -11,11 +11,11 @@ # # !! Do not edit this file, it is generated from template! -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global LogPrint; diff --git a/dhcp-lease-comment.template.rsc b/dhcp-lease-comment.template.rsc index 814e1d7..71307b7 100644 --- a/dhcp-lease-comment.template.rsc +++ b/dhcp-lease-comment.template.rsc @@ -12,11 +12,11 @@ # !! This is just a template to generate the real script! # !! Pattern '%TEMPL%' is replaced, paths are filtered. -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global LogPrint; diff --git a/dhcp-lease-comment.wifi.rsc b/dhcp-lease-comment.wifi.rsc index 92fb6b0..1f29f0b 100644 --- a/dhcp-lease-comment.wifi.rsc +++ b/dhcp-lease-comment.wifi.rsc @@ -11,11 +11,11 @@ # # !! Do not edit this file, it is generated from template! -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global LogPrint; From 2d41ad718d785545c165ef4bcf4603abdbeec020 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 122/291] netwatch-dns: use :onerror for outer block --- netwatch-dns.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/netwatch-dns.rsc b/netwatch-dns.rsc index 467d636..1d2d86b 100644 --- a/netwatch-dns.rsc +++ b/netwatch-dns.rsc @@ -13,7 +13,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global CertificateAvailable; @@ -145,6 +145,6 @@ } } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From a308d4269e5d20f3787c524a427e8acf55e7a1d2 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 123/291] dhcp-to-dns: fail if global functions do not become ready --- dhcp-to-dns.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dhcp-to-dns.rsc b/dhcp-to-dns.rsc index b032071..e66704b 100644 --- a/dhcp-to-dns.rsc +++ b/dhcp-to-dns.rsc @@ -9,11 +9,11 @@ # check DHCP leases and add/remove/update DNS entries # https://rsc.eworm.de/doc/dhcp-to-dns.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global Domain; From 0df4170a2e634591327088988f685f0c35d82569 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 124/291] netwatch-notify: use :onerror for outer block --- netwatch-notify.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/netwatch-notify.rsc b/netwatch-notify.rsc index 0b8a8dc..d256689 100644 --- a/netwatch-notify.rsc +++ b/netwatch-notify.rsc @@ -12,7 +12,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global NetwatchNotify; @@ -224,6 +224,6 @@ "since"=($Metric->"since") }; } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From 4d1349125da065caaa0f3a572629c875eeb01d96 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 125/291] firmware-upgrade-reboot: fail if global functions do not become ready --- firmware-upgrade-reboot.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/firmware-upgrade-reboot.rsc b/firmware-upgrade-reboot.rsc index 9c3ba76..d5774db 100644 --- a/firmware-upgrade-reboot.rsc +++ b/firmware-upgrade-reboot.rsc @@ -8,11 +8,11 @@ # install firmware upgrade, and reboot # https://rsc.eworm.de/doc/firmware-upgrade-reboot.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global LogPrint; From c720eadd2c42286653ac8984d6e7c255b2ad97a8 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 126/291] ospf-to-leds: use :onerror for outer block --- ospf-to-leds.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ospf-to-leds.rsc b/ospf-to-leds.rsc index a8662b3..e2f4dcf 100644 --- a/ospf-to-leds.rsc +++ b/ospf-to-leds.rsc @@ -12,7 +12,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global LogPrint; @@ -44,6 +44,6 @@ /system/leds/set type=off [ find where leds=$LED ]; } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From 4b92181f2eefcc416c3281fc376c42e33712eb55 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 127/291] fw-addr-lists: fail if global functions do not become ready --- fw-addr-lists.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fw-addr-lists.rsc b/fw-addr-lists.rsc index 0fd79c1..1a892da 100644 --- a/fw-addr-lists.rsc +++ b/fw-addr-lists.rsc @@ -8,11 +8,11 @@ # download, import and update firewall address-lists # https://rsc.eworm.de/doc/fw-addr-lists.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global FwAddrLists; From 9a5a2aec4fc08685725e3d0ef2b98459cfd433e3 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 128/291] packages-update: use :onerror for outer block --- packages-update.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages-update.rsc b/packages-update.rsc index b11596e..dce7cca 100644 --- a/packages-update.rsc +++ b/packages-update.rsc @@ -13,7 +13,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global BackupRandomDelay; @@ -163,6 +163,6 @@ $LogPrint info $ScriptName ("Rebooting for update."); :delay 1s; /system/reboot; -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From 925e7f869e59b1c544062bdd6693f2a286a5504e Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 129/291] gps-track: fail if global functions do not become ready --- gps-track.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gps-track.rsc b/gps-track.rsc index bd280c9..d66bf00 100644 --- a/gps-track.rsc +++ b/gps-track.rsc @@ -9,11 +9,11 @@ # track gps data by sending json data to http server # https://rsc.eworm.de/doc/gps-track.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global GpsTrackUrl; From aeccd36f16a13ebe01a48a9b522b503adf599c6e Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 130/291] ppp-on-up: use :onerror for outer block --- ppp-on-up.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ppp-on-up.rsc b/ppp-on-up.rsc index e09bd9d..ffe3079 100644 --- a/ppp-on-up.rsc +++ b/ppp-on-up.rsc @@ -12,7 +12,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global LogPrint; @@ -39,6 +39,6 @@ $LogPrint warning $ScriptName ("Running script '" . $ScriptName . "' failed!"); } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From 76778f04319819eec8e2285f3a88703e4290cbde Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 131/291] hotspot-to-wpa-cleanup: fail if global functions do not become ready --- hotspot-to-wpa-cleanup.capsman.rsc | 6 +++--- hotspot-to-wpa-cleanup.template.rsc | 6 +++--- hotspot-to-wpa-cleanup.wifi.rsc | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hotspot-to-wpa-cleanup.capsman.rsc b/hotspot-to-wpa-cleanup.capsman.rsc index 6cd1bfb..fd0e554 100644 --- a/hotspot-to-wpa-cleanup.capsman.rsc +++ b/hotspot-to-wpa-cleanup.capsman.rsc @@ -12,11 +12,11 @@ # # !! Do not edit this file, it is generated from template! -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global EitherOr; diff --git a/hotspot-to-wpa-cleanup.template.rsc b/hotspot-to-wpa-cleanup.template.rsc index 18d6bea..11f359c 100644 --- a/hotspot-to-wpa-cleanup.template.rsc +++ b/hotspot-to-wpa-cleanup.template.rsc @@ -13,11 +13,11 @@ # !! This is just a template to generate the real script! # !! Pattern '%TEMPL%' is replaced, paths are filtered. -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global EitherOr; diff --git a/hotspot-to-wpa-cleanup.wifi.rsc b/hotspot-to-wpa-cleanup.wifi.rsc index 6348f74..7f0ebae 100644 --- a/hotspot-to-wpa-cleanup.wifi.rsc +++ b/hotspot-to-wpa-cleanup.wifi.rsc @@ -12,11 +12,11 @@ # # !! Do not edit this file, it is generated from template! -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global EitherOr; From 3eec13b8b58d57c04d957e13d016c9e587a5de68 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 132/291] sms-action: use :onerror for outer block --- sms-action.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sms-action.rsc b/sms-action.rsc index 3c8307a..d5bd553 100644 --- a/sms-action.rsc +++ b/sms-action.rsc @@ -12,7 +12,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global SmsAction; @@ -36,6 +36,6 @@ } else={ $LogPrint warning $ScriptName ("The code for action '" . $Action . "' failed syntax validation!"); } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From 057bbb8481f57cde2917aa358b36f6793f3bff85 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 133/291] hotspot-to-wpa: fail if global functions do not become ready --- hotspot-to-wpa.capsman.rsc | 6 +++--- hotspot-to-wpa.template.rsc | 6 +++--- hotspot-to-wpa.wifi.rsc | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hotspot-to-wpa.capsman.rsc b/hotspot-to-wpa.capsman.rsc index 54724cf..a9a1407 100644 --- a/hotspot-to-wpa.capsman.rsc +++ b/hotspot-to-wpa.capsman.rsc @@ -11,11 +11,11 @@ # # !! Do not edit this file, it is generated from template! -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global EitherOr; diff --git a/hotspot-to-wpa.template.rsc b/hotspot-to-wpa.template.rsc index 6764af9..84a43bc 100644 --- a/hotspot-to-wpa.template.rsc +++ b/hotspot-to-wpa.template.rsc @@ -12,11 +12,11 @@ # !! This is just a template to generate the real script! # !! Pattern '%TEMPL%' is replaced, paths are filtered. -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global EitherOr; diff --git a/hotspot-to-wpa.wifi.rsc b/hotspot-to-wpa.wifi.rsc index e74081a..5c5afda 100644 --- a/hotspot-to-wpa.wifi.rsc +++ b/hotspot-to-wpa.wifi.rsc @@ -11,11 +11,11 @@ # # !! Do not edit this file, it is generated from template! -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global EitherOr; From aae9b4d4e39c36ceeef1d0e1125c8bce9255bdac Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 134/291] sms-forward: use :onerror for outer block --- sms-forward.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sms-forward.rsc b/sms-forward.rsc index 8169022..ddaa3a8 100644 --- a/sms-forward.rsc +++ b/sms-forward.rsc @@ -13,7 +13,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global Identity; @@ -96,6 +96,6 @@ } } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From bcdb74f31d9f4006ff55f83900a85e310f14c372 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 13:52:57 +0200 Subject: [PATCH 135/291] global-config: introduce a state variable --- global-config.rsc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/global-config.rsc b/global-config.rsc index 42a457a..c0577ff 100644 --- a/global-config.rsc +++ b/global-config.rsc @@ -6,6 +6,9 @@ # global configuration # https://rsc.eworm.de/ +# Warning: Do *NOT* copy this line to overlay! +:global GlobalConfigReady false; + # Set this to 'true' to disable news and change notifications. :global NoNewsAndChangesNotification false; @@ -275,3 +278,6 @@ [ /system/script/get $Script name ] . " failed!"); } } + +# signal we are ready +:set GlobalConfigReady true; From 83cf003f62877f34abb112ed5105b391ea11f4e6 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 136/291] ipsec-to-dns: fail if global functions do not become ready --- ipsec-to-dns.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ipsec-to-dns.rsc b/ipsec-to-dns.rsc index a273932..fb7b55c 100644 --- a/ipsec-to-dns.rsc +++ b/ipsec-to-dns.rsc @@ -9,11 +9,11 @@ # and add/remove/update DNS entries from IPSec mode-config # https://rsc.eworm.de/doc/ipsec-to-dns.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global Domain; From 3ad8cafc7a01ced329b4b1af6cafd87a282e71df Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 137/291] telegram-chat: use :onerror for outer block --- telegram-chat.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/telegram-chat.rsc b/telegram-chat.rsc index 5db4860..155bb02 100644 --- a/telegram-chat.rsc +++ b/telegram-chat.rsc @@ -13,7 +13,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global Identity; @@ -190,6 +190,6 @@ } :set TelegramChatOffset ([ :pick $TelegramChatOffset 1 3 ], \ [ $IfThenElse ($UpdateID >= $TelegramChatOffset->2) ($UpdateID + 1) ($TelegramChatOffset->2) ]); -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From 60c5e84401ddb1490bd43daf796e4ba86ca22327 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:36 +0200 Subject: [PATCH 138/291] accesslist-duplicates: check for global config to be ready --- accesslist-duplicates.capsman.rsc | 6 +++--- accesslist-duplicates.local.rsc | 6 +++--- accesslist-duplicates.template.rsc | 6 +++--- accesslist-duplicates.wifi.rsc | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/accesslist-duplicates.capsman.rsc b/accesslist-duplicates.capsman.rsc index 545b24e..5e6cf0a 100644 --- a/accesslist-duplicates.capsman.rsc +++ b/accesslist-duplicates.capsman.rsc @@ -12,9 +12,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :local Seen ({}); diff --git a/accesslist-duplicates.local.rsc b/accesslist-duplicates.local.rsc index ac2c7fe..a6b4f41 100644 --- a/accesslist-duplicates.local.rsc +++ b/accesslist-duplicates.local.rsc @@ -12,9 +12,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :local Seen ({}); diff --git a/accesslist-duplicates.template.rsc b/accesslist-duplicates.template.rsc index 8955991..e51198d 100644 --- a/accesslist-duplicates.template.rsc +++ b/accesslist-duplicates.template.rsc @@ -13,9 +13,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :local Seen ({}); diff --git a/accesslist-duplicates.wifi.rsc b/accesslist-duplicates.wifi.rsc index 331de75..cadacb6 100644 --- a/accesslist-duplicates.wifi.rsc +++ b/accesslist-duplicates.wifi.rsc @@ -12,9 +12,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :local Seen ({}); From 41b705aa5a2158a7da7c51da4c95db96d7363d9c Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 139/291] ipv6-update: fail if global functions do not become ready --- ipv6-update.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ipv6-update.rsc b/ipv6-update.rsc index 633919d..24167c0 100644 --- a/ipv6-update.rsc +++ b/ipv6-update.rsc @@ -8,11 +8,11 @@ # update firewall and dns settings on IPv6 prefix change # https://rsc.eworm.de/doc/ipv6-update.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global LogPrint; From fe3d9f841822d210d13af90025415015e89743a8 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 140/291] update-gre-address: use :onerror for outer block --- update-gre-address.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/update-gre-address.rsc b/update-gre-address.rsc index cddfa92..2570f80 100644 --- a/update-gre-address.rsc +++ b/update-gre-address.rsc @@ -13,7 +13,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global CharacterReplace; @@ -41,6 +41,6 @@ } } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From d57916fc267e9fdeb9c878f578c2b7d3736fbac6 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:36 +0200 Subject: [PATCH 141/291] backup-cloud: check for global config to be ready --- backup-cloud.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backup-cloud.rsc b/backup-cloud.rsc index f0861f0..e41db27 100644 --- a/backup-cloud.rsc +++ b/backup-cloud.rsc @@ -11,9 +11,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global BackupRandomDelay; From 829fce789b6d0bd5de192c8491e1b54a5fe9ba35 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 142/291] lease-script: fail if global functions do not become ready --- lease-script.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lease-script.rsc b/lease-script.rsc index 309337c..501e047 100644 --- a/lease-script.rsc +++ b/lease-script.rsc @@ -8,11 +8,11 @@ # run scripts on DHCP lease # https://rsc.eworm.de/doc/lease-script.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global Grep; From d2af793683cdfa7e187da10cf8baf5c99e9c7fe1 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:44:23 +0200 Subject: [PATCH 143/291] update-tunnelbroker: use :onerror for outer block --- update-tunnelbroker.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/update-tunnelbroker.rsc b/update-tunnelbroker.rsc index 45afa6f..10adef0 100644 --- a/update-tunnelbroker.rsc +++ b/update-tunnelbroker.rsc @@ -15,7 +15,7 @@ :while ($GlobalFunctionsReady != true) do={ :delay 500ms; } :local ExitOK false; -:do { +:onerror Err { :local ScriptName [ :jobname ]; :global CertificateAvailable; @@ -69,6 +69,6 @@ /interface/6to4/set $Interface local-address=$PublicAddress; } } -} on-error={ - :global ExitError; $ExitError $ExitOK [ :jobname ]; +} do={ + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From 37a6d4cc438b2b3481d8904aa0ec4dcde9a96ce8 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:36 +0200 Subject: [PATCH 144/291] backup-email: check for global config to be ready --- backup-email.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backup-email.rsc b/backup-email.rsc index da2ee02..632d2e6 100644 --- a/backup-email.rsc +++ b/backup-email.rsc @@ -11,9 +11,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global BackupPassword; From a6ab95ccef4bc3255b7d45f66f86865337459f67 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 145/291] log-forward: fail if global functions do not become ready --- log-forward.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/log-forward.rsc b/log-forward.rsc index 0ce420f..3774dac 100644 --- a/log-forward.rsc +++ b/log-forward.rsc @@ -8,11 +8,11 @@ # forward log messages via notification # https://rsc.eworm.de/doc/log-forward.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global Identity; From 02986eb77a2f6e2b8a0f008ca21ed49dd6195e24 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:45:14 +0200 Subject: [PATCH 146/291] mod/bridge-port-to: use :onerror for outer block --- mod/bridge-port-to.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mod/bridge-port-to.rsc b/mod/bridge-port-to.rsc index 39a036e..93eedce 100644 --- a/mod/bridge-port-to.rsc +++ b/mod/bridge-port-to.rsc @@ -10,7 +10,7 @@ :global BridgePortTo; -:set BridgePortTo do={ :do { +:set BridgePortTo do={ :onerror Err { :local BridgePortTo [ :tostr $1 ]; :global IfThenElse; @@ -65,6 +65,6 @@ $LogPrint info $0 ("Re-enabling interfaces..."); /interface/ethernet/enable $InterfaceReEnable; } -} on-error={ - :global ExitError; $ExitError false $0; +} do={ + :global ExitError; $ExitError false $0 $Err; } } From 200167fa38037a02d63c249639027614f101118f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:36 +0200 Subject: [PATCH 147/291] backup-partition: check for global config to be ready --- backup-partition.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backup-partition.rsc b/backup-partition.rsc index f99a66c..c2221d2 100644 --- a/backup-partition.rsc +++ b/backup-partition.rsc @@ -12,9 +12,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global BackupPartitionCopyBeforeFeatureUpdate; From 63606ad25cec7d1345c3b3a9158472328f02444c Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 148/291] mode-button: fail if global functions do not become ready --- mode-button.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mode-button.rsc b/mode-button.rsc index 83897ba..e5c836f 100644 --- a/mode-button.rsc +++ b/mode-button.rsc @@ -9,11 +9,11 @@ # act on multiple mode and reset button presses # https://rsc.eworm.de/doc/mode-button.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global ModeButton; From d5141f43e5e812e387eadb7b6f505f136032c48f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:45:14 +0200 Subject: [PATCH 149/291] mod/bridge-port-vlan: use :onerror for outer block --- mod/bridge-port-vlan.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mod/bridge-port-vlan.rsc b/mod/bridge-port-vlan.rsc index 0eeb9b5..6deee99 100644 --- a/mod/bridge-port-vlan.rsc +++ b/mod/bridge-port-vlan.rsc @@ -10,7 +10,7 @@ :global BridgePortVlan; -:global BridgePortVlan do={ :do { +:global BridgePortVlan do={ :onerror Err { :local ConfigTo [ :tostr $1 ]; :global IfThenElse; @@ -74,6 +74,6 @@ $LogPrint info $0 ("Re-enabling interfaces..."); /interface/ethernet/enable $InterfaceReEnable; } -} on-error={ - :global ExitError; $ExitError false $0; +} do={ + :global ExitError; $ExitError false $0 $Err; } } From 27fc07e9406ae6a37f642213d5da3d23b92e63f2 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:36 +0200 Subject: [PATCH 150/291] backup-upload: check for global config to be ready --- backup-upload.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backup-upload.rsc b/backup-upload.rsc index 9373b4c..11ced4c 100644 --- a/backup-upload.rsc +++ b/backup-upload.rsc @@ -12,9 +12,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global BackupPassword; From 2374be9a2192a1bcf43aa487facc1c17da34e08d Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 151/291] netwatch-dns: fail if global functions do not become ready --- netwatch-dns.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/netwatch-dns.rsc b/netwatch-dns.rsc index 1d2d86b..5a928f0 100644 --- a/netwatch-dns.rsc +++ b/netwatch-dns.rsc @@ -9,11 +9,11 @@ # monitor and manage dns/doh with netwatch # https://rsc.eworm.de/doc/netwatch-dns.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global CertificateAvailable; From 9b558ff8a1bc57f3197e71d73b468e820577d4f7 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:45:14 +0200 Subject: [PATCH 152/291] mod/inspectvar: use :onerror for outer block --- mod/inspectvar.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mod/inspectvar.rsc b/mod/inspectvar.rsc index c861557..89c0286 100644 --- a/mod/inspectvar.rsc +++ b/mod/inspectvar.rsc @@ -12,12 +12,12 @@ :global InspectVarReturn; # inspect variable and print on terminal -:set InspectVar do={ :do { +:set InspectVar do={ :onerror Err { :global InspectVarReturn; :put [ :tocrlf [ $InspectVarReturn $1 ] ]; -} on-error={ - :global ExitError; $ExitError false $0; +} do={ + :global ExitError; $ExitError false $0 $Err; } } # inspect variable and return formatted string From 12037ff6e618d84bead0252d9fee36617e9e7ee6 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:36 +0200 Subject: [PATCH 153/291] capsman-download-packages: check for global config to be ready --- capsman-download-packages.capsman.rsc | 6 +++--- capsman-download-packages.template.rsc | 6 +++--- capsman-download-packages.wifi.rsc | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/capsman-download-packages.capsman.rsc b/capsman-download-packages.capsman.rsc index ee82638..cab1e4c 100644 --- a/capsman-download-packages.capsman.rsc +++ b/capsman-download-packages.capsman.rsc @@ -13,9 +13,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global CleanFilePath; diff --git a/capsman-download-packages.template.rsc b/capsman-download-packages.template.rsc index 91a9167..ea41120 100644 --- a/capsman-download-packages.template.rsc +++ b/capsman-download-packages.template.rsc @@ -14,9 +14,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global CleanFilePath; diff --git a/capsman-download-packages.wifi.rsc b/capsman-download-packages.wifi.rsc index cb6cb6f..a810356 100644 --- a/capsman-download-packages.wifi.rsc +++ b/capsman-download-packages.wifi.rsc @@ -13,9 +13,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global CleanFilePath; From 446aa3d7ffff5f9b70be2bfafdcef2ec88f3742c Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 154/291] netwatch-notify: fail if global functions do not become ready --- netwatch-notify.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/netwatch-notify.rsc b/netwatch-notify.rsc index d256689..0c48330 100644 --- a/netwatch-notify.rsc +++ b/netwatch-notify.rsc @@ -8,11 +8,11 @@ # monitor netwatch and send notifications # https://rsc.eworm.de/doc/netwatch-notify.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global NetwatchNotify; From 8cddc63767010072417d405cc4460febb8e9978d Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:45:14 +0200 Subject: [PATCH 155/291] mod/ipcalc: use :onerror for outer block --- mod/ipcalc.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mod/ipcalc.rsc b/mod/ipcalc.rsc index 477cf4a..eacff6d 100644 --- a/mod/ipcalc.rsc +++ b/mod/ipcalc.rsc @@ -12,7 +12,7 @@ :global IPCalcReturn; # print netmask, network, min host, max host and broadcast -:set IPCalc do={ :do { +:set IPCalc do={ :onerror Err { :local Input [ :tostr $1 ]; :global FormatLine; @@ -27,8 +27,8 @@ [ $FormatLine "HostMin" ($Values->"hostmin") ] . "\n" . \ [ $FormatLine "HostMax" ($Values->"hostmax") ] . "\n" . \ [ $FormatLine "Broadcast" ($Values->"broadcast") ]) ]; -} on-error={ - :global ExitError; $ExitError false $0; +} do={ + :global ExitError; $ExitError false $0 $Err; } } # calculate and return netmask, network, min host, max host and broadcast From 40b19a179d0b7b87cfc2bf2fd9a92c0a20f95532 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:36 +0200 Subject: [PATCH 156/291] capsman-rolling-upgrade: check for global config to be ready --- capsman-rolling-upgrade.capsman.rsc | 6 +++--- capsman-rolling-upgrade.template.rsc | 6 +++--- capsman-rolling-upgrade.wifi.rsc | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/capsman-rolling-upgrade.capsman.rsc b/capsman-rolling-upgrade.capsman.rsc index 2097880..0d4114a 100644 --- a/capsman-rolling-upgrade.capsman.rsc +++ b/capsman-rolling-upgrade.capsman.rsc @@ -14,9 +14,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global LogPrint; diff --git a/capsman-rolling-upgrade.template.rsc b/capsman-rolling-upgrade.template.rsc index 75de088..690d73d 100644 --- a/capsman-rolling-upgrade.template.rsc +++ b/capsman-rolling-upgrade.template.rsc @@ -15,9 +15,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global LogPrint; diff --git a/capsman-rolling-upgrade.wifi.rsc b/capsman-rolling-upgrade.wifi.rsc index e6c6fac..8e32ab2 100644 --- a/capsman-rolling-upgrade.wifi.rsc +++ b/capsman-rolling-upgrade.wifi.rsc @@ -14,9 +14,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global LogPrint; From ff812dd1928657dbae9df59e2d19d6f6fe33fb1f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 157/291] ospf-to-leds: fail if global functions do not become ready --- ospf-to-leds.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ospf-to-leds.rsc b/ospf-to-leds.rsc index e2f4dcf..cdc06e5 100644 --- a/ospf-to-leds.rsc +++ b/ospf-to-leds.rsc @@ -8,11 +8,11 @@ # visualize ospf instance state via leds # https://rsc.eworm.de/doc/ospf-to-leds.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global LogPrint; From 862830b341716250daba288091b36d64926dccdb Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:45:14 +0200 Subject: [PATCH 158/291] mod/notification-email: use :onerror for outer block --- mod/notification-email.rsc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mod/notification-email.rsc b/mod/notification-email.rsc index 7b89d98..c0f9d86 100644 --- a/mod/notification-email.rsc +++ b/mod/notification-email.rsc @@ -35,7 +35,7 @@ } # flush e-mail queue -:set FlushEmailQueue do={ :do { +:set FlushEmailQueue do={ :onerror Err { :global EmailQueue; :global EitherOr; @@ -135,8 +135,8 @@ /system/scheduler/set interval=(($SchedVal->"run-count") . "m") \ comment="Waiting for retry..." $Scheduler; -} on-error={ - :global ExitError; $ExitError false $0; +} do={ + :global ExitError; $ExitError false $0 $Err; } } # generate filter for log-forward @@ -248,12 +248,12 @@ } # send notification via e-mail - expects at least two string arguments -:set SendEMail do={ :do { +:set SendEMail do={ :onerror Err { :global SendEMail2; $SendEMail2 ({ origin=$0; subject=$1; message=$2; link=$3 }); -} on-error={ - :global ExitError; $ExitError false $0; +} do={ + :global ExitError; $ExitError false $0 $Err; } } # send notification via e-mail - expects one array argument From ef1a402c4e61be10824ef441811d6f8a03ed35a7 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 159/291] certificate-renew-issued: check for global config to be ready --- certificate-renew-issued.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/certificate-renew-issued.rsc b/certificate-renew-issued.rsc index 3fd6020..14917e4 100644 --- a/certificate-renew-issued.rsc +++ b/certificate-renew-issued.rsc @@ -10,9 +10,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global CertIssuedExportPass; From 4358dabb19d45e3bee816d6f9bc76dad21a3c10c Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 160/291] packages-update: fail if global functions do not become ready --- packages-update.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages-update.rsc b/packages-update.rsc index dce7cca..81a6d13 100644 --- a/packages-update.rsc +++ b/packages-update.rsc @@ -9,11 +9,11 @@ # download packages and reboot for installation # https://rsc.eworm.de/doc/packages-update.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global BackupRandomDelay; From 9d845d40f00250e1b3107c175aa2f1a77ffb3a63 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:45:14 +0200 Subject: [PATCH 161/291] mod/notification-gotify: use :onerror for outer block --- mod/notification-gotify.rsc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mod/notification-gotify.rsc b/mod/notification-gotify.rsc index 7070918..3ae4cdd 100644 --- a/mod/notification-gotify.rsc +++ b/mod/notification-gotify.rsc @@ -17,7 +17,7 @@ :global SendGotify2; # flush Gotify queue -:set FlushGotifyQueue do={ :do { +:set FlushGotifyQueue do={ :onerror Err { :global GotifyQueue; :global IsFullyConnected; @@ -53,8 +53,8 @@ /system/scheduler/remove [ find where name="_FlushGotifyQueue" ]; :set GotifyQueue; } -} on-error={ - :global ExitError; $ExitError false $0; +} do={ + :global ExitError; $ExitError false $0 $Err; } } # send notification via Gotify - expects one array argument @@ -121,12 +121,12 @@ } # send notification via Gotify - expects at least two string arguments -:set SendGotify do={ :do { +:set SendGotify do={ :onerror Err { :global SendGotify2; $SendGotify2 ({ origin=$0; subject=$1; message=$2; link=$3; silent=$4 }); -} on-error={ - :global ExitError; $ExitError false $0; +} do={ + :global ExitError; $ExitError false $0 $Err; } } # send notification via Gotify - expects one array argument From 4954a886958a7e3e0b9c05dcd9e8d4135f0d5a04 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 162/291] check-certificates: check for global config to be ready --- check-certificates.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/check-certificates.rsc b/check-certificates.rsc index 505ec4b..c10e33b 100644 --- a/check-certificates.rsc +++ b/check-certificates.rsc @@ -11,9 +11,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global CertRenewTime; From 7b624faaa108201522cb792fcf776c39e30a0839 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 163/291] ppp-on-up: fail if global functions do not become ready --- ppp-on-up.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ppp-on-up.rsc b/ppp-on-up.rsc index ffe3079..ef08c9d 100644 --- a/ppp-on-up.rsc +++ b/ppp-on-up.rsc @@ -8,11 +8,11 @@ # run scripts on ppp up # https://rsc.eworm.de/doc/ppp-on-up.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global LogPrint; From d865deb8a8710d98453adf221e72fdfd0a71dc33 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:45:14 +0200 Subject: [PATCH 164/291] mod/notification-matrix: use :onerror for outer block --- mod/notification-matrix.rsc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mod/notification-matrix.rsc b/mod/notification-matrix.rsc index e989ee0..c8cf887 100644 --- a/mod/notification-matrix.rsc +++ b/mod/notification-matrix.rsc @@ -19,7 +19,7 @@ :global SetupMatrixJoinRoom; # flush Matrix queue -:set FlushMatrixQueue do={ :do { +:set FlushMatrixQueue do={ :onerror Err { :global MatrixQueue; :global IsFullyConnected; @@ -58,8 +58,8 @@ /system/scheduler/remove [ find where name="_FlushMatrixQueue" ]; :set MatrixQueue; } -} on-error={ - :global ExitError; $ExitError false $0; +} do={ + :global ExitError; $ExitError false $0 $Err; } } # send notification via Matrix - expects one array argument @@ -167,12 +167,12 @@ } # send notification via Matrix - expects at least two string arguments -:set SendMatrix do={ :do { +:set SendMatrix do={ :onerror Err { :global SendMatrix2; $SendMatrix2 ({ origin=$0; subject=$1; message=$2; link=$3 }); -} on-error={ - :global ExitError; $ExitError false $0; +} do={ + :global ExitError; $ExitError false $0 $Err; } } # send notification via Matrix - expects one array argument From 1936dcb563c47b4ca4847912077f5f609d1360ad Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 165/291] check-health: check for global config to be ready --- check-health.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/check-health.rsc b/check-health.rsc index 40ce101..1b92d1e 100644 --- a/check-health.rsc +++ b/check-health.rsc @@ -10,9 +10,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global CheckHealthCPUUtilization; From 0ef8888412f2f9ad8fe8ffc714b3dfb30802f55e Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 166/291] sms-action: fail if global functions do not become ready --- sms-action.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sms-action.rsc b/sms-action.rsc index d5bd553..0f02bce 100644 --- a/sms-action.rsc +++ b/sms-action.rsc @@ -8,11 +8,11 @@ # run action on received SMS # https://rsc.eworm.de/doc/sms-action.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global SmsAction; From e3a15cc6b803453290d2cc8e2415c207473aa2a1 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:45:14 +0200 Subject: [PATCH 167/291] mod/notification-ntfy: use :onerror for outer block --- mod/notification-ntfy.rsc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mod/notification-ntfy.rsc b/mod/notification-ntfy.rsc index 2748c5b..8e5688e 100644 --- a/mod/notification-ntfy.rsc +++ b/mod/notification-ntfy.rsc @@ -16,7 +16,7 @@ :global SendNtfy2; # flush ntfy queue -:set FlushNtfyQueue do={ :do { +:set FlushNtfyQueue do={ :onerror Err { :global NtfyQueue; :global IsFullyConnected; @@ -52,8 +52,8 @@ /system/scheduler/remove [ find where name="_FlushNtfyQueue" ]; :set NtfyQueue; } -} on-error={ - :global ExitError; $ExitError false $0; +} do={ + :global ExitError; $ExitError false $0 $Err; } } # send notification via ntfy - expects one array argument @@ -143,12 +143,12 @@ } # send notification via ntfy - expects at least two string arguments -:set SendNtfy do={ :do { +:set SendNtfy do={ :onerror Err { :global SendNtfy2; $SendNtfy2 ({ origin=$0; subject=$1; message=$2; link=$3; silent=$4 }); -} on-error={ - :global ExitError; $ExitError false $0; +} do={ + :global ExitError; $ExitError false $0 $Err; } } # send notification via ntfy - expects one array argument From 506acb748b9e6670323b68fb46b90e5d16ddff15 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 168/291] check-lte-firmware-upgrade: check for global config to be ready --- check-lte-firmware-upgrade.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/check-lte-firmware-upgrade.rsc b/check-lte-firmware-upgrade.rsc index 6030e4d..1a5e08c 100644 --- a/check-lte-firmware-upgrade.rsc +++ b/check-lte-firmware-upgrade.rsc @@ -10,9 +10,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global SentLteFirmwareUpgradeNotification; From 24ea16cf91dae10a654e77911dbb53b213a6fd4f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 169/291] sms-forward: fail if global functions do not become ready --- sms-forward.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sms-forward.rsc b/sms-forward.rsc index ddaa3a8..9c3e4a5 100644 --- a/sms-forward.rsc +++ b/sms-forward.rsc @@ -9,11 +9,11 @@ # forward SMS to e-mail # https://rsc.eworm.de/doc/sms-forward.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global Identity; From f7ba78702f92bec374b59066e57772d76f97358f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:45:14 +0200 Subject: [PATCH 170/291] mod/notification-telegram: use :onerror for outer block --- mod/notification-telegram.rsc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mod/notification-telegram.rsc b/mod/notification-telegram.rsc index 5ef353b..51c8dbf 100644 --- a/mod/notification-telegram.rsc +++ b/mod/notification-telegram.rsc @@ -17,7 +17,7 @@ :global SendTelegram2; # flush telegram queue -:set FlushTelegramQueue do={ :do { +:set FlushTelegramQueue do={ :onerror Err { :global TelegramQueue; :global TelegramMessageIDs; @@ -55,12 +55,12 @@ /system/scheduler/remove [ find where name="_FlushTelegramQueue" ]; :set TelegramQueue; } -} on-error={ - :global ExitError; $ExitError false $0; +} do={ + :global ExitError; $ExitError false $0 $Err; } } # get the chat id -:set GetTelegramChatId do={ :do { +:set GetTelegramChatId do={ :onerror Err { :global TelegramTokenId; :global CertificateAvailable; @@ -94,8 +94,8 @@ :if (($Message->"is_topic_message") = true) do={ $LogPrint info $0 ("The thread id is: " . ($Message->"message_thread_id")); } -} on-error={ - :global ExitError; $ExitError false $0; +} do={ + :global ExitError; $ExitError false $0 $Err; } } # send notification via telegram - expects one array argument @@ -226,12 +226,12 @@ } # send notification via telegram - expects at least two string arguments -:set SendTelegram do={ :do { +:set SendTelegram do={ :onerror Err { :global SendTelegram2; $SendTelegram2 ({ origin=$0; subject=$1; message=$2; link=$3; silent=$4 }); -} on-error={ - :global ExitError; $ExitError false $0; +} do={ + :global ExitError; $ExitError false $0 $Err; } } # send notification via telegram - expects one array argument From 78463f469b02768c1197db9c2cc35c46581c7fcc Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 171/291] check-perpetual-license: check for global config to be ready --- check-perpetual-license.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/check-perpetual-license.rsc b/check-perpetual-license.rsc index d46f0b4..c2f0dff 100644 --- a/check-perpetual-license.rsc +++ b/check-perpetual-license.rsc @@ -10,9 +10,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global Identity; From 35bce7c5eb775e7d9d0e774344918383d17b9009 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 172/291] telegram-chat: fail if global functions do not become ready --- telegram-chat.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/telegram-chat.rsc b/telegram-chat.rsc index 155bb02..f62034c 100644 --- a/telegram-chat.rsc +++ b/telegram-chat.rsc @@ -9,11 +9,11 @@ # use Telegram to chat with your Router and send commands # https://rsc.eworm.de/doc/telegram-chat.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global Identity; From 5958851bd7e3b034dda25f670e0019247c4d73a0 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:45:14 +0200 Subject: [PATCH 173/291] mod/scriptrunonce: use :onerror for outer block --- mod/scriptrunonce.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mod/scriptrunonce.rsc b/mod/scriptrunonce.rsc index 7fcd5b5..3797c15 100644 --- a/mod/scriptrunonce.rsc +++ b/mod/scriptrunonce.rsc @@ -11,7 +11,7 @@ :global ScriptRunOnce; # fetch and run script(s) once -:set ScriptRunOnce do={ :do { +:set ScriptRunOnce do={ :onerror Err { :local Scripts [ :toarray $1 ]; :global ScriptRunOnceBaseUrl; @@ -51,6 +51,6 @@ :return true; } -} on-error={ - :global ExitError; $ExitError false $0; +} do={ + :global ExitError; $ExitError false $0 $Err; } } From 59c66de69065989d8f3b6032c156d484299f2032 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 174/291] check-routeros-update: check for global config to be ready --- check-routeros-update.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/check-routeros-update.rsc b/check-routeros-update.rsc index 932256a..34d0647 100644 --- a/check-routeros-update.rsc +++ b/check-routeros-update.rsc @@ -11,9 +11,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global Identity; From 87edd0bd29f3825fd638760f20343f5afe890ae3 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 175/291] update-gre-address: fail if global functions do not become ready --- update-gre-address.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/update-gre-address.rsc b/update-gre-address.rsc index 2570f80..8d98eaa 100644 --- a/update-gre-address.rsc +++ b/update-gre-address.rsc @@ -9,11 +9,11 @@ # ipsec remote peer # https://rsc.eworm.de/doc/update-gre-address.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global CharacterReplace; From af40ae82edaccbf6d1995f8ad1a5250f57f950db Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 09:45:14 +0200 Subject: [PATCH 176/291] mod/ssh-keys-import: use :onerror for outer block --- mod/ssh-keys-import.rsc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mod/ssh-keys-import.rsc b/mod/ssh-keys-import.rsc index 2fae4b1..9a6cd39 100644 --- a/mod/ssh-keys-import.rsc +++ b/mod/ssh-keys-import.rsc @@ -12,7 +12,7 @@ :global SSHKeysImportFile; # import single key passed as string -:set SSHKeysImport do={ :do { +:set SSHKeysImport do={ :onerror Err { :local Key [ :tostr $1 ]; :local User [ :tostr $2 ]; @@ -65,12 +65,12 @@ $RmDir "tmpfs/ssh-keys-import"; :return false; } -} on-error={ - :global ExitError; $ExitError false $0; +} do={ + :global ExitError; $ExitError false $0 $Err; } } # import keys from a file -:set SSHKeysImportFile do={ :do { +:set SSHKeysImportFile do={ :onerror Err { :local FileName [ :tostr $1 ]; :local User [ :tostr $2 ]; @@ -109,6 +109,6 @@ $LogPrint warning $0 ("SSH key of type '" . $KeyVal->0 . "' is not supported."); } } -} on-error={ - :global ExitError; $ExitError false $0; +} do={ + :global ExitError; $ExitError false $0 $Err; } } From 286ed96cc34efa929093bb72e64d102b458ae60e Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 177/291] collect-wireless-mac: check for global config to be ready --- collect-wireless-mac.capsman.rsc | 6 +++--- collect-wireless-mac.local.rsc | 6 +++--- collect-wireless-mac.template.rsc | 6 +++--- collect-wireless-mac.wifi.rsc | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/collect-wireless-mac.capsman.rsc b/collect-wireless-mac.capsman.rsc index fa6198a..06b8d84 100644 --- a/collect-wireless-mac.capsman.rsc +++ b/collect-wireless-mac.capsman.rsc @@ -13,9 +13,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global Identity; diff --git a/collect-wireless-mac.local.rsc b/collect-wireless-mac.local.rsc index 4082bbb..6716582 100644 --- a/collect-wireless-mac.local.rsc +++ b/collect-wireless-mac.local.rsc @@ -13,9 +13,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global Identity; diff --git a/collect-wireless-mac.template.rsc b/collect-wireless-mac.template.rsc index 5167156..53e6b0a 100644 --- a/collect-wireless-mac.template.rsc +++ b/collect-wireless-mac.template.rsc @@ -14,9 +14,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global Identity; diff --git a/collect-wireless-mac.wifi.rsc b/collect-wireless-mac.wifi.rsc index af0dd8b..43ac851 100644 --- a/collect-wireless-mac.wifi.rsc +++ b/collect-wireless-mac.wifi.rsc @@ -13,9 +13,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global Identity; From 6040f70b19a06dc0d9817f3240b1bb13c34d453c Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 11:15:15 +0200 Subject: [PATCH 178/291] update-tunnelbroker: fail if global functions do not become ready --- update-tunnelbroker.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/update-tunnelbroker.rsc b/update-tunnelbroker.rsc index 10adef0..2deb5b2 100644 --- a/update-tunnelbroker.rsc +++ b/update-tunnelbroker.rsc @@ -11,11 +11,11 @@ # update local address of tunnelbroker interface # https://rsc.eworm.de/doc/update-tunnelbroker.md -:global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } - :local ExitOK false; :onerror Err { + :global GlobalFunctionsReady; + :retry { :if ($GlobalFunctionsReady != true) \ + do={ :error ("Global functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global CertificateAvailable; From b19c448f7839aea73830fb0f3bb7314f98ce2f2c Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 179/291] daily-psk: check for global config to be ready --- daily-psk.capsman.rsc | 6 +++--- daily-psk.local.rsc | 6 +++--- daily-psk.template.rsc | 6 +++--- daily-psk.wifi.rsc | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/daily-psk.capsman.rsc b/daily-psk.capsman.rsc index a1b01fc..3ecd6b6 100644 --- a/daily-psk.capsman.rsc +++ b/daily-psk.capsman.rsc @@ -13,9 +13,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global DailyPskMatchComment; diff --git a/daily-psk.local.rsc b/daily-psk.local.rsc index 6ba6ce2..d496350 100644 --- a/daily-psk.local.rsc +++ b/daily-psk.local.rsc @@ -13,9 +13,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global DailyPskMatchComment; diff --git a/daily-psk.template.rsc b/daily-psk.template.rsc index 43ce333..5a1df2f 100644 --- a/daily-psk.template.rsc +++ b/daily-psk.template.rsc @@ -14,9 +14,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global DailyPskMatchComment; diff --git a/daily-psk.wifi.rsc b/daily-psk.wifi.rsc index 7e1714d..c441e58 100644 --- a/daily-psk.wifi.rsc +++ b/daily-psk.wifi.rsc @@ -13,9 +13,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global DailyPskMatchComment; From ad6ad5bfccfec0bfbb83848ddf6784ef12e1e770 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 180/291] dhcp-lease-comment: check for global config to be ready --- dhcp-lease-comment.capsman.rsc | 6 +++--- dhcp-lease-comment.local.rsc | 6 +++--- dhcp-lease-comment.template.rsc | 6 +++--- dhcp-lease-comment.wifi.rsc | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/dhcp-lease-comment.capsman.rsc b/dhcp-lease-comment.capsman.rsc index 724682b..3615bb9 100644 --- a/dhcp-lease-comment.capsman.rsc +++ b/dhcp-lease-comment.capsman.rsc @@ -13,9 +13,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global LogPrint; diff --git a/dhcp-lease-comment.local.rsc b/dhcp-lease-comment.local.rsc index 0a5f3b5..9da5333 100644 --- a/dhcp-lease-comment.local.rsc +++ b/dhcp-lease-comment.local.rsc @@ -13,9 +13,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global LogPrint; diff --git a/dhcp-lease-comment.template.rsc b/dhcp-lease-comment.template.rsc index 71307b7..62cace1 100644 --- a/dhcp-lease-comment.template.rsc +++ b/dhcp-lease-comment.template.rsc @@ -14,9 +14,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global LogPrint; diff --git a/dhcp-lease-comment.wifi.rsc b/dhcp-lease-comment.wifi.rsc index 1f29f0b..667708c 100644 --- a/dhcp-lease-comment.wifi.rsc +++ b/dhcp-lease-comment.wifi.rsc @@ -13,9 +13,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global LogPrint; From 857993cf90b0bb432c18292816734f55ed2867cf Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 181/291] dhcp-to-dns: check for global config to be ready --- dhcp-to-dns.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dhcp-to-dns.rsc b/dhcp-to-dns.rsc index e66704b..a9c91e1 100644 --- a/dhcp-to-dns.rsc +++ b/dhcp-to-dns.rsc @@ -11,9 +11,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global Domain; From a68763c4dd4ca4e93dcd0edd98cd25bc8ac5d734 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 182/291] firmware-upgrade-reboot: check for global config to be ready --- firmware-upgrade-reboot.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/firmware-upgrade-reboot.rsc b/firmware-upgrade-reboot.rsc index d5774db..e3ca55b 100644 --- a/firmware-upgrade-reboot.rsc +++ b/firmware-upgrade-reboot.rsc @@ -10,9 +10,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global LogPrint; From 9e70bca30b792785034422db15bf158d94e666e6 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 183/291] fw-addr-lists: check for global config to be ready --- fw-addr-lists.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fw-addr-lists.rsc b/fw-addr-lists.rsc index 1a892da..4ee3c34 100644 --- a/fw-addr-lists.rsc +++ b/fw-addr-lists.rsc @@ -10,9 +10,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global FwAddrLists; From 148892694fe43d6382ec368e450634342965882a Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 184/291] gps-track: check for global config to be ready --- gps-track.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gps-track.rsc b/gps-track.rsc index d66bf00..4cc5066 100644 --- a/gps-track.rsc +++ b/gps-track.rsc @@ -11,9 +11,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global GpsTrackUrl; From 713e63da87d57d77961ddf606b4438a4c2b7ecd7 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 185/291] hotspot-to-wpa-cleanup: check for global config to be ready --- hotspot-to-wpa-cleanup.capsman.rsc | 6 +++--- hotspot-to-wpa-cleanup.template.rsc | 6 +++--- hotspot-to-wpa-cleanup.wifi.rsc | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hotspot-to-wpa-cleanup.capsman.rsc b/hotspot-to-wpa-cleanup.capsman.rsc index fd0e554..e4ac967 100644 --- a/hotspot-to-wpa-cleanup.capsman.rsc +++ b/hotspot-to-wpa-cleanup.capsman.rsc @@ -14,9 +14,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global EitherOr; diff --git a/hotspot-to-wpa-cleanup.template.rsc b/hotspot-to-wpa-cleanup.template.rsc index 11f359c..d51e1d0 100644 --- a/hotspot-to-wpa-cleanup.template.rsc +++ b/hotspot-to-wpa-cleanup.template.rsc @@ -15,9 +15,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global EitherOr; diff --git a/hotspot-to-wpa-cleanup.wifi.rsc b/hotspot-to-wpa-cleanup.wifi.rsc index 7f0ebae..8bb2631 100644 --- a/hotspot-to-wpa-cleanup.wifi.rsc +++ b/hotspot-to-wpa-cleanup.wifi.rsc @@ -14,9 +14,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global EitherOr; From 6a9fced721e9ed54b451aeecc2e68f761663dfb6 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 186/291] hotspot-to-wpa: check for global config to be ready --- hotspot-to-wpa.capsman.rsc | 6 +++--- hotspot-to-wpa.template.rsc | 6 +++--- hotspot-to-wpa.wifi.rsc | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hotspot-to-wpa.capsman.rsc b/hotspot-to-wpa.capsman.rsc index a9a1407..8977cee 100644 --- a/hotspot-to-wpa.capsman.rsc +++ b/hotspot-to-wpa.capsman.rsc @@ -13,9 +13,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global EitherOr; diff --git a/hotspot-to-wpa.template.rsc b/hotspot-to-wpa.template.rsc index 84a43bc..c5d977d 100644 --- a/hotspot-to-wpa.template.rsc +++ b/hotspot-to-wpa.template.rsc @@ -14,9 +14,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global EitherOr; diff --git a/hotspot-to-wpa.wifi.rsc b/hotspot-to-wpa.wifi.rsc index 5c5afda..6a97e46 100644 --- a/hotspot-to-wpa.wifi.rsc +++ b/hotspot-to-wpa.wifi.rsc @@ -13,9 +13,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global EitherOr; From ce29fcf49ed381ebd910f74193ce3be7cac1def9 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 187/291] ipsec-to-dns: check for global config to be ready --- ipsec-to-dns.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ipsec-to-dns.rsc b/ipsec-to-dns.rsc index fb7b55c..1b5ed13 100644 --- a/ipsec-to-dns.rsc +++ b/ipsec-to-dns.rsc @@ -11,9 +11,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global Domain; From 59f9a1187f769dc57d778a77264ae69591ac594b Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 188/291] ipv6-update: check for global config to be ready --- ipv6-update.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ipv6-update.rsc b/ipv6-update.rsc index 24167c0..580a426 100644 --- a/ipv6-update.rsc +++ b/ipv6-update.rsc @@ -10,9 +10,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global LogPrint; From 10bd9a1cb5b3d556abcc5732d894e3bcc797e94b Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 189/291] lease-script: check for global config to be ready --- lease-script.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lease-script.rsc b/lease-script.rsc index 501e047..b166ee3 100644 --- a/lease-script.rsc +++ b/lease-script.rsc @@ -10,9 +10,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global Grep; From 160effd91b66459dd9a2ecaf5ecc442a33f135c5 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 190/291] log-forward: check for global config to be ready --- log-forward.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/log-forward.rsc b/log-forward.rsc index 3774dac..be7eff7 100644 --- a/log-forward.rsc +++ b/log-forward.rsc @@ -10,9 +10,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global Identity; From bc1c238158a18f5fc7122a5110f21d29e72540cb Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 191/291] mode-button: check for global config to be ready --- mode-button.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mode-button.rsc b/mode-button.rsc index e5c836f..c6422f0 100644 --- a/mode-button.rsc +++ b/mode-button.rsc @@ -11,9 +11,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global ModeButton; From 2d39dbdf7c363ba5657dee6c94f9763bbaab3e86 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 192/291] netwatch-dns: check for global config to be ready --- netwatch-dns.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/netwatch-dns.rsc b/netwatch-dns.rsc index 5a928f0..3da1498 100644 --- a/netwatch-dns.rsc +++ b/netwatch-dns.rsc @@ -11,9 +11,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global CertificateAvailable; From 5b40380cd2dfe6b3fcd0828460851c41e1d1b416 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 193/291] netwatch-notify: check for global config to be ready --- netwatch-notify.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/netwatch-notify.rsc b/netwatch-notify.rsc index 0c48330..fb8e8d5 100644 --- a/netwatch-notify.rsc +++ b/netwatch-notify.rsc @@ -10,9 +10,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global NetwatchNotify; From aaecd1b457f5e5779276c7217d1c5429536d5534 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 194/291] ospf-to-leds: check for global config to be ready --- ospf-to-leds.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ospf-to-leds.rsc b/ospf-to-leds.rsc index cdc06e5..26f8aa3 100644 --- a/ospf-to-leds.rsc +++ b/ospf-to-leds.rsc @@ -10,9 +10,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global LogPrint; From 38ec392a5fd462a803f4e04219a0d4acbf98bc63 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 195/291] packages-update: check for global config to be ready --- packages-update.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages-update.rsc b/packages-update.rsc index 81a6d13..4fde131 100644 --- a/packages-update.rsc +++ b/packages-update.rsc @@ -11,9 +11,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global BackupRandomDelay; From 194698f53f27bebc9ee349597c764b58cd4475b0 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 196/291] ppp-on-up: check for global config to be ready --- ppp-on-up.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ppp-on-up.rsc b/ppp-on-up.rsc index ef08c9d..f16d73f 100644 --- a/ppp-on-up.rsc +++ b/ppp-on-up.rsc @@ -10,9 +10,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global LogPrint; From 6270ac45d8ed241cfe31e345cccc097cb33bd02b Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 197/291] sms-action: check for global config to be ready --- sms-action.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sms-action.rsc b/sms-action.rsc index 0f02bce..47e1922 100644 --- a/sms-action.rsc +++ b/sms-action.rsc @@ -10,9 +10,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global SmsAction; From 15248ffd39b982a176d87c39db6c3f789102a29f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 198/291] sms-forward: check for global config to be ready --- sms-forward.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sms-forward.rsc b/sms-forward.rsc index 9c3e4a5..8ca5ae4 100644 --- a/sms-forward.rsc +++ b/sms-forward.rsc @@ -11,9 +11,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global Identity; From 9b5419b939cadc751076c68a2b6bb8434a828444 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 199/291] telegram-chat: check for global config to be ready --- telegram-chat.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/telegram-chat.rsc b/telegram-chat.rsc index f62034c..b1f7f99 100644 --- a/telegram-chat.rsc +++ b/telegram-chat.rsc @@ -11,9 +11,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global Identity; From b4d80d3b178e376568a3e7bbcb5dce29c631e383 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 200/291] update-gre-address: check for global config to be ready --- update-gre-address.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/update-gre-address.rsc b/update-gre-address.rsc index 8d98eaa..dd7d63e 100644 --- a/update-gre-address.rsc +++ b/update-gre-address.rsc @@ -11,9 +11,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global CharacterReplace; From f2dbb9eff34aa43fd2be41f9a6a36da06e07dbb0 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:08:37 +0200 Subject: [PATCH 201/291] update-tunnelbroker: check for global config to be ready --- update-tunnelbroker.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/update-tunnelbroker.rsc b/update-tunnelbroker.rsc index 2deb5b2..8e5e1d0 100644 --- a/update-tunnelbroker.rsc +++ b/update-tunnelbroker.rsc @@ -13,9 +13,9 @@ :local ExitOK false; :onerror Err { - :global GlobalFunctionsReady; - :retry { :if ($GlobalFunctionsReady != true) \ - do={ :error ("Global functions not ready."); }; } delay=500ms max=50; + :global GlobalConfigReady; :global GlobalFunctionsReady; + :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ + do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50; :local ScriptName [ :jobname ]; :global CertificateAvailable; From 0f58cecc0f2f114d5520db5d283fcd7d243c1bc1 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:09:50 +0200 Subject: [PATCH 202/291] global-wait: check for global config to be ready --- global-wait.rsc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/global-wait.rsc b/global-wait.rsc index ca3fc0c..23b5629 100644 --- a/global-wait.rsc +++ b/global-wait.rsc @@ -8,5 +8,6 @@ # wait for global-functions to finish # https://rsc.eworm.de/doc/global-wait.md +:global GlobalConfigReady; :global GlobalFunctionsReady; -:while ($GlobalFunctionsReady != true) do={ :delay 500ms; } +:while ($GlobalConfigReady != true || $GlobalFunctionsReady != true) do={ :delay 500ms; } From 4561b17dbff272b1b5671155ee1838dba2f24062 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 13:57:05 +0200 Subject: [PATCH 203/291] global-config: add another comment with visual hint --- global-config.rsc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/global-config.rsc b/global-config.rsc index c0577ff..2d7d43d 100644 --- a/global-config.rsc +++ b/global-config.rsc @@ -8,6 +8,9 @@ # Warning: Do *NOT* copy this line to overlay! :global GlobalConfigReady false; +# || ... but +# \||/ start +# \/ here! # Set this to 'true' to disable news and change notifications. :global NoNewsAndChangesNotification false; From 661aad522b09bf4aba5b0be4877669e0a826b4a6 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 14:05:47 +0200 Subject: [PATCH 204/291] global-config: add another visual hint --- global-config.rsc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/global-config.rsc b/global-config.rsc index 2d7d43d..589a58a 100644 --- a/global-config.rsc +++ b/global-config.rsc @@ -270,8 +270,11 @@ "cert2-cn"="4n0th3r-s3cr3t"; }; +# /\ Warning: Do *NOT* copy +# /\7\ the code below to overlay! +# /_()_\ Things *will* break! +# # load custom settings from overlay and snippets -# Warning: Do *NOT* copy this code to overlay! :foreach Script in=([ /system/script/find where name="global-config-overlay" ], \ [ /system/script/find where name~"^global-config-overlay.d/" ]) do={ :do { From f095b581e74b5c5a8110c801243b2ec039499120 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 6 May 2025 19:42:12 +0200 Subject: [PATCH 205/291] global-functions: $ScriptInstallUpdate: set config and functions not ready... ... before reload. This should fix some corner cases where scripts ran with broken configuration or functions. Also do reload both - configuration and functions - to simplify the function. --- global-functions.rsc | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index 29e6d06..6e3d712 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -1126,6 +1126,8 @@ :global CommitId; :global CommitInfo; :global ExpectedConfigVersion; + :global GlobalConfigReady; + :global GlobalFunctionsReady; :global Identity; :global IDonate; :global NoNewsAndChangesNotification; @@ -1159,8 +1161,7 @@ :local CommitIdBefore $CommitId; :local ExpectedConfigVersionBefore $ExpectedConfigVersion; - :local ReloadGlobalFunctions false; - :local ReloadGlobalConfig false; + :local ReloadGlobal false; :local DeviceMode [ /system/device-mode/get ]; :local CheckSums ({}); @@ -1269,31 +1270,25 @@ $LogPrint info $0 ("Updating script: " . $ScriptVal->"name"); /system/script/set owner=($ScriptVal->"name") \ source=[ $IfThenElse ($ScriptUpdatesCRLF = true) $SourceCRLF $SourceNew ] $Script; - :if ($ScriptVal->"name" = "global-config") do={ - :set ReloadGlobalConfig true; - } - :if ($ScriptVal->"name" = "global-functions" || $ScriptVal->"name" ~ ("^mod/.")) do={ - :set ReloadGlobalFunctions true; + :if ($ScriptVal->"name" = "global-config" || \ + $ScriptVal->"name" = "global-functions" || \ + $ScriptVal->"name" ~ ("^mod/.")) do={ + :set ReloadGlobal true; } } on-error={ } } - :if ($ReloadGlobalFunctions = true) do={ - $LogPrint info $0 ("Reloading global functions."); - :do { - /system/script/run global-functions; - } on-error={ - $LogPrint error $0 ("Reloading global functions failed!"); - } - } + :if ($ReloadGlobal = true) do={ + $LogPrint info $0 ("Reloading global configuration and functions."); + :set GlobalConfigReady false; + :set GlobalFunctionsReady false; + :delay 1s; - :if ($ReloadGlobalConfig = true) do={ - $LogPrint info $0 ("Reloading global configuration."); - :do { + :onerror Err { /system/script/run global-config; - } on-error={ - $LogPrint error $0 ("Reloading global configuration failed!" . \ - " Syntax error or missing overlay?"); + /system/script/run global-functions; + } do={ + $LogPrint error $0 ("Reloading global configuration and functions failed! " . $Err); } } From 90857805622a97ac3b150da60579952bf2ba0185 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 7 May 2025 11:45:55 +0200 Subject: [PATCH 206/291] sms-forward: delay after removal... ... to give the SIM card some time to succeed. Removing several messages one after another fails without this. --- sms-forward.rsc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sms-forward.rsc b/sms-forward.rsc index 8ca5ae4..4798a8a 100644 --- a/sms-forward.rsc +++ b/sms-forward.rsc @@ -62,6 +62,7 @@ ($SmsVal->"message")~("^:cmd " . $Settings->"secret" . " script ")) do={ $LogPrint debug $ScriptName ("Removing SMS, which started a script."); /tool/sms/inbox/remove $Sms; + :delay 50ms; } else={ :set Messages ($Messages . "\n\nOn " . $SmsVal->"timestamp" . \ " type " . $SmsVal->"type" . ":\n" . $SmsVal->"message"); @@ -93,6 +94,7 @@ " by " . $Identity . " from " . $Phone . ":" . $Messages) }); :foreach Sms in=$Delete do={ /tool/sms/inbox/remove $Sms; + :delay 50ms; } } } From 01f3cb91e796fba77bc7ec810d98a31fe2a33843 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 7 May 2025 14:31:37 +0200 Subject: [PATCH 207/291] sms-forward: add error handling on message removal --- sms-forward.rsc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/sms-forward.rsc b/sms-forward.rsc index 4798a8a..a564056 100644 --- a/sms-forward.rsc +++ b/sms-forward.rsc @@ -61,8 +61,12 @@ :if ($Phone = $Settings->"allowed-number" && \ ($SmsVal->"message")~("^:cmd " . $Settings->"secret" . " script ")) do={ $LogPrint debug $ScriptName ("Removing SMS, which started a script."); - /tool/sms/inbox/remove $Sms; - :delay 50ms; + :onerror Err { + /tool/sms/inbox/remove $Sms; + :delay 50ms; + } do={ + $LogPrint warning $ScriptName ("Failed to remove message: " . $Err); + } } else={ :set Messages ($Messages . "\n\nOn " . $SmsVal->"timestamp" . \ " type " . $SmsVal->"type" . ":\n" . $SmsVal->"message"); @@ -93,8 +97,12 @@ message=("Received " . [ $IfThenElse ($Count = 1) "this message" ("these " . $Count . " messages") ] . \ " by " . $Identity . " from " . $Phone . ":" . $Messages) }); :foreach Sms in=$Delete do={ - /tool/sms/inbox/remove $Sms; - :delay 50ms; + :onerror Err { + /tool/sms/inbox/remove $Sms; + :delay 50ms; + } do={ + $LogPrint warning $ScriptName ("Failed to remove message: " . $Err); + } } } } From 6691e2e765c7dbfa3e639bea2331bbbf0b83ed4f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 21 May 2025 21:51:16 +0200 Subject: [PATCH 208/291] global-functions: $DownloadPackage: reverse failure logic... ... and do not retry. --- global-functions.rsc | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index 6e3d712..1dd7708 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -391,25 +391,22 @@ :local Url ("https://upgrade.mikrotik.com/routeros/" . $PkgVer . "/" . $PkgFile); $LogPrint info $0 ("Downloading package file '" . $PkgName . "'..."); $LogPrint debug $0 ("... from url: " . $Url); - :local Retry 3; - :while ($Retry > 0) do={ - :do { - /tool/fetch check-certificate=yes-without-crl $Url dst-path=$PkgDest; - $WaitForFile $PkgDest; - :if ([ /file/get [ find where name=$PkgDest ] type ] = "package") do={ - :return true; - } - } on-error={ - $LogPrint debug $0 ("Downloading package file failed."); - } - - $RmFile $PkgDest; - :set Retry ($Retry - 1); + :do { + /tool/fetch check-certificate=yes-without-crl $Url dst-path=$PkgDest; + $WaitForFile $PkgDest; + } on-error={ + $LogPrint warning $0 ("Downloading package file '" . $PkgName . "' failed."); + :return false; } - $LogPrint warning $0 ("Downloading package file '" . $PkgName . "' failed."); - :return false; + :if ([ /file/get [ find where name=$PkgDest ] type ] != "package") do={ + $LogPrint warning $0 ("Downloaded file is not a package, removing."); + $RmFile $PkgDest; + :return false; + } + + :return true; } # return either first (if "true") or second From c3fce370660b8c128f579d2a419c657395748c2e Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 7 May 2025 17:59:20 +0200 Subject: [PATCH 209/291] backup-partition: :do ... on-error=... -> :onerror ... do=... --- backup-partition.rsc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/backup-partition.rsc b/backup-partition.rsc index c2221d2..ae7ad03 100644 --- a/backup-partition.rsc +++ b/backup-partition.rsc @@ -32,14 +32,15 @@ :global LogPrint; - :do { + :onerror Err { /partitions/copy-to $FallbackTo; $LogPrint info $ScriptName ("Copied RouterOS to partition '" . $FallbackToName . "'."); - :return true; - } on-error={ - $LogPrint error $ScriptName ("Failed copying RouterOS to partition '" . $FallbackToName . "'!"); + } do={ + $LogPrint error $ScriptName ("Failed copying RouterOS to partition '" . \ + $FallbackToName . "': " . $Err); :return false; } + :return true; } :if ([ $ScriptLock $ScriptName ] = false) do={ @@ -107,16 +108,17 @@ } } - :do { + :onerror Err { /system/scheduler/add start-time=startup name="running-from-backup-partition" \ on-event=(":log warning (\"Running from partition '\" . " . \ "[ /partitions/get [ find where running ] name ] . \"'!\")"); /partitions/save-config-to $FallbackTo; /system/scheduler/remove "running-from-backup-partition"; $LogPrint info $ScriptName ("Saved configuration to partition '" . $FallbackToName . "'."); - } on-error={ + } do={ /system/scheduler/remove [ find where name="running-from-backup-partition" ]; - $LogPrint error $ScriptName ("Failed saving configuration to partition '" . $FallbackToName . "'!"); + $LogPrint error $ScriptName ("Failed saving configuration to partition '" . \ + $FallbackToName . "': " . $Err); :set PackagesUpdateBackupFailure true; :set ExitOK true; :error false; From dc2296d5004b806aa5c5812c0e1a7ff4016be005 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 7 May 2025 18:03:30 +0200 Subject: [PATCH 210/291] backup-upload: :do ... on-error=... -> :onerror ... do=... --- backup-upload.rsc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/backup-upload.rsc b/backup-upload.rsc index 11ced4c..e6b9f92 100644 --- a/backup-upload.rsc +++ b/backup-upload.rsc @@ -90,13 +90,13 @@ /system/backup/save encryption=aes-sha256 name=$FilePath password=$BackupPassword; $WaitForFile ($FilePath . ".backup"); - :do { + :onerror Err { /tool/fetch upload=yes url=($BackupUploadUrl . "/" . $FileName . ".backup") \ user=$BackupUploadUser password=$BackupUploadPass src-path=($FilePath . ".backup"); :set BackupFile [ /file/get ($FilePath . ".backup") ]; :set ($BackupFile->"name") ($FileName . ".backup"); - } on-error={ - $LogPrint error $ScriptName ("Uploading backup file failed!"); + } do={ + $LogPrint error $ScriptName ("Uploading backup file failed: " . $Err); :set BackupFile "failed"; :set Failed 1; } @@ -109,13 +109,13 @@ /export terse show-sensitive file=$FilePath; $WaitForFile ($FilePath . ".rsc"); - :do { + :onerror Err { /tool/fetch upload=yes url=($BackupUploadUrl . "/" . $FileName . ".rsc") \ user=$BackupUploadUser password=$BackupUploadPass src-path=($FilePath . ".rsc"); :set ExportFile [ /file/get ($FilePath . ".rsc") ]; :set ($ExportFile->"name") ($FileName . ".rsc"); - } on-error={ - $LogPrint error $ScriptName ("Uploading configuration export failed!"); + } do={ + $LogPrint error $ScriptName ("Uploading configuration export failed: " . $Err); :set ExportFile "failed"; :set Failed 1; } @@ -130,13 +130,13 @@ file=($FilePath . ".conf\00"); $WaitForFile ($FilePath . ".conf"); - :do { + :onerror Err { /tool/fetch upload=yes url=($BackupUploadUrl . "/" . $FileName . ".conf") \ user=$BackupUploadUser password=$BackupUploadPass src-path=($FilePath . ".conf"); :set ConfigFile [ /file/get ($FilePath . ".conf") ]; :set ($ConfigFile->"name") ($FileName . ".conf"); - } on-error={ - $LogPrint error $ScriptName ("Uploading global-config-overlay failed!"); + } do={ + $LogPrint error $ScriptName ("Uploading global-config-overlay failed: " . $Err); :set ConfigFile "failed"; :set Failed 1; } From 187aeba78bebef1d1f47524c690ad260adffcadd Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 09:04:15 +0200 Subject: [PATCH 211/291] check-health: :do ... on-error=... -> :onerror ... do=... --- check-health.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/check-health.rsc b/check-health.rsc index 1b92d1e..4cb9940 100644 --- a/check-health.rsc +++ b/check-health.rsc @@ -89,10 +89,10 @@ :foreach Plugin in=$Plugins do={ :local PluginVal [ /system/script/get $Plugin ]; :if ([ $ValidateSyntax ($PluginVal->"source") ] = true) do={ - :do { + :onerror Err { /system/script/run $Plugin; - } on-error={ - $LogPrint error $ScriptName ("Plugin '" . $ScriptVal->"name" . "' failed to run."); + } do={ + $LogPrint error $ScriptName ("Plugin '" . $ScriptVal->"name" . "' failed to run: " . $Err); } } else={ $LogPrint error $ScriptName ("Plugin '" . $ScriptVal->"name" . "' failed syntax validation, skipping."); From 1925d2847c6d9b48364e24153fcbfb10cd9e758d Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 09:05:41 +0200 Subject: [PATCH 212/291] check-lte-firmware-upgrade: :do ... on-error=... -> :onerror ... do=... --- check-lte-firmware-upgrade.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/check-lte-firmware-upgrade.rsc b/check-lte-firmware-upgrade.rsc index 1a5e08c..9f4b656 100644 --- a/check-lte-firmware-upgrade.rsc +++ b/check-lte-firmware-upgrade.rsc @@ -45,12 +45,12 @@ :local IntName [ /interface/lte/get $Interface name ]; :local Firmware; :local Info; - :do { + :onerror Err { :set Firmware [ /interface/lte/firmware-upgrade $Interface as-value ]; :set Info [ /interface/lte/monitor $Interface once as-value ]; - } on-error={ + } do={ $LogPrint debug $ScriptName ("Could not get latest LTE firmware version for interface " . \ - $IntName . "."); + $IntName . ": " . $Err); :return false; } From 79f681b80115b2f663feda478294717bb021c7ba Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 09:06:25 +0200 Subject: [PATCH 213/291] check-routeros-update: :do ... on-error=... -> :onerror ... do=... --- check-routeros-update.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/check-routeros-update.rsc b/check-routeros-update.rsc index 34d0647..e28a019 100644 --- a/check-routeros-update.rsc +++ b/check-routeros-update.rsc @@ -141,13 +141,13 @@ :if ([ :len $SafeUpdateUrl ] > 0) do={ :local Result; - :do { + :onerror Err { :set Result [ /tool/fetch check-certificate=yes-without-crl \ ($SafeUpdateUrl . $Update->"channel" . "?installed=" . $Update->"installed-version" . \ "&latest=" . $Update->"latest-version") http-header-field=({ [ $FetchUserAgentStr $ScriptName ] }) \ output=user as-value ]; - } on-error={ - $LogPrint warning $ScriptName ("Failed receiving safe version for " . $Update->"channel" . "."); + } do={ + $LogPrint warning $ScriptName ("Failed receiving safe version for " . $Update->"channel" . ": " . $Err); } :if ($Result->"status" = "finished" && $Result->"data" = $Update->"latest-version") do={ $LogPrint info $ScriptName ("Version " . $Update->"latest-version" . " is considered safe, updating..."); From 142b0760b0e8daa205cc1fc8f471716e219ece82 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 09:17:46 +0200 Subject: [PATCH 214/291] fw-addr-lists: :do ... on-error=... -> :onerror ... do=... --- fw-addr-lists.rsc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fw-addr-lists.rsc b/fw-addr-lists.rsc index 4ee3c34..659fb2f 100644 --- a/fw-addr-lists.rsc +++ b/fw-addr-lists.rsc @@ -176,13 +176,13 @@ :foreach Address,Timeout in=$Branch do={ $LogPrintVerbose debug $ScriptName ("Adding IPv4 address to list '" . $FwListName . \ "' with " . $Timeout . ": " . $Address); - :do { + :onerror Err { /ip/firewall/address-list/add list=$FwListName comment=$ListComment \ address=$Address timeout=$Timeout; :set CntAdd ($CntAdd + 1); - } on-error={ - $LogPrint warning $ScriptName ("Failed to add IPv4 address to list '" . $FwListName . \ - "': " . $Address); + } do={ + $LogPrint warning $ScriptName ("Failed to add IPv4 address " . $Address . \ + " to list '" . $FwListName . "': " . $Err); } } } @@ -192,13 +192,13 @@ :foreach Address,Timeout in=$Branch do={ $LogPrintVerbose debug $ScriptName ("Adding IPv6 address to list '" . $FwListName . \ "' with " . $Timeout . ": " . $Address); - :do { + :onerror Err { /ipv6/firewall/address-list/add list=$FwListName comment=$ListComment \ address=$Address timeout=$Timeout; :set CntAdd ($CntAdd + 1); - } on-error={ - $LogPrint warning $ScriptName ("Failed to add IPv6 address to list '" . $FwListName . \ - "': " . $Address); + } do={ + $LogPrint warning $ScriptName ("Failed to add IPv6 address " . $Address . \ + " to list '" . $FwListName . "': " . $Err); } } } From b807fc9e90b105c2057631c23f5685d18b811951 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 09:21:03 +0200 Subject: [PATCH 215/291] fw-addr-lists: adopt changes in wording... ... to match the changes from previous commit. --- fw-addr-lists.rsc | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/fw-addr-lists.rsc b/fw-addr-lists.rsc index 659fb2f..5a03875 100644 --- a/fw-addr-lists.rsc +++ b/fw-addr-lists.rsc @@ -135,15 +135,15 @@ :local Branch [ $GetBranch $Address ]; :local TimeOut ($IPv4Addresses->$Branch->$Address); :if ([ :typeof $TimeOut ] = "time") do={ - $LogPrintVerbose debug $ScriptName ("Renewing IPv4 address in list '" . $FwListName . \ - "' with " . $TimeOut . ": " . $Address); + $LogPrintVerbose debug $ScriptName ("Renewing IPv4 address " . $Address . \ + " in list '" . $FwListName . "' with " . $TimeOut . "."); /ip/firewall/address-list/set $Entry timeout=$TimeOut; :set ($IPv4Addresses->$Branch->$Address); :set CntRenew ($CntRenew + 1); } else={ :if ($Failure = false) do={ - $LogPrintVerbose debug $ScriptName ("Removing IPv4 address from list '" . $FwListName . \ - "': " . $Address); + $LogPrintVerbose debug $ScriptName ("Removing IPv4 address " . $Address . \ + " from list '" . $FwListName . "."); /ip/firewall/address-list/remove $Entry; :set CntRemove ($CntRemove + 1); } @@ -156,15 +156,15 @@ :local Branch [ $GetBranch $Address ]; :local TimeOut ($IPv6Addresses->$Branch->$Address); :if ([ :typeof $TimeOut ] = "time") do={ - $LogPrintVerbose debug $ScriptName ("Renewing IPv6 address in list '" . $FwListName . \ - "' with " . $TimeOut . ": " . $Address); + $LogPrintVerbose debug $ScriptName ("Renewing IPv6 address " . $Address . \ + " in list '" . $FwListName . "' with " . $TimeOut . "."); /ipv6/firewall/address-list/set $Entry timeout=$TimeOut; :set ($IPv6Addresses->$Branch->$Address); :set CntRenew ($CntRenew + 1); } else={ :if ($Failure = false) do={ - $LogPrintVerbose debug $ScriptName ("Removing IPv6 address from list '" . $FwListName . \ - "': " . $Address); + $LogPrintVerbose debug $ScriptName ("Removing IPv6 address " . $Address . \ + " from list '" . $FwListName ."."); /ipv6/firewall/address-list/remove $Entry; :set CntRemove ($CntRemove + 1); } @@ -174,8 +174,8 @@ :foreach BranchName,Branch in=$IPv4Addresses do={ $LogPrintVerbose debug $ScriptName ("Handling branch: " . $BranchName); :foreach Address,Timeout in=$Branch do={ - $LogPrintVerbose debug $ScriptName ("Adding IPv4 address to list '" . $FwListName . \ - "' with " . $Timeout . ": " . $Address); + $LogPrintVerbose debug $ScriptName ("Adding IPv4 address " . $Address . \ + " to list '" . $FwListName . "' with " . $Timeout . "."); :onerror Err { /ip/firewall/address-list/add list=$FwListName comment=$ListComment \ address=$Address timeout=$Timeout; @@ -190,8 +190,8 @@ :foreach BranchName,Branch in=$IPv6Addresses do={ $LogPrintVerbose debug $ScriptName ("Handling branch: " . $BranchName); :foreach Address,Timeout in=$Branch do={ - $LogPrintVerbose debug $ScriptName ("Adding IPv6 address to list '" . $FwListName . \ - "' with " . $Timeout . ": " . $Address); + $LogPrintVerbose debug $ScriptName ("Adding IPv6 address " . $Address . \ + " to list '" . $FwListName . "' with " . $Timeout . "."); :onerror Err { /ipv6/firewall/address-list/add list=$FwListName comment=$ListComment \ address=$Address timeout=$Timeout; From a9e7bb0a05c4b4a2744039ce7369760c5cbc0c9f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 09:22:02 +0200 Subject: [PATCH 216/291] global-config: :do ... on-error=... -> :onerror ... do=... --- global-config.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/global-config.rsc b/global-config.rsc index 589a58a..86d528a 100644 --- a/global-config.rsc +++ b/global-config.rsc @@ -277,11 +277,11 @@ # load custom settings from overlay and snippets :foreach Script in=([ /system/script/find where name="global-config-overlay" ], \ [ /system/script/find where name~"^global-config-overlay.d/" ]) do={ - :do { + :onerror Err { /system/script/run $Script; - } on-error={ + } do={ :log error ("Loading configuration from overlay or snippet " . \ - [ /system/script/get $Script name ] . " failed!"); + [ /system/script/get $Script name ] . " failed: " . $Err); } } From 5b89f3e425c0703c804dda76ef22efe22b438cc3 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 21 May 2025 21:53:34 +0200 Subject: [PATCH 217/291] global-functions: $DownloadPackage: :do ... on-error=... -> :onerror ... do=... --- global-functions.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index 1dd7708..fc33f5a 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -392,11 +392,11 @@ $LogPrint info $0 ("Downloading package file '" . $PkgName . "'..."); $LogPrint debug $0 ("... from url: " . $Url); - :do { + :onerror Err { /tool/fetch check-certificate=yes-without-crl $Url dst-path=$PkgDest; $WaitForFile $PkgDest; - } on-error={ - $LogPrint warning $0 ("Downloading package file '" . $PkgName . "' failed."); + } do={ + $LogPrint warning $0 ("Downloading package file '" . $PkgName . "' failed: " . $Err); :return false; } From a6b36dde7bbd9bd4308588cbe0b10ae04399b8e6 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 09:24:56 +0200 Subject: [PATCH 218/291] global-functions: $FetchHuge: :do ... on-error=... -> :onerror ... do=... --- global-functions.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index fc33f5a..3b7ff7c 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -486,14 +486,14 @@ } :local FileName ($DirName . "/" . [ $CleanName $0 ] . "-" . [ $GetRandom20CharAlNum ]); - :do { + :onerror Err { /tool/fetch check-certificate=$CheckCert $Url dst-path=$FileName \ http-header-field=({ [ $FetchUserAgentStr $ScriptName ] }) as-value; - } on-error={ + } do={ :if ([ $WaitForFile $FileName 500ms ] = true) do={ $RmFile $FileName; } - $LogPrint debug $0 ("Failed downloading from: " . $Url); + $LogPrint debug $0 ("Failed downloading from " . $Url . " - " . $Err); $RmDir $DirName; :return false; } From 7a1fef78a26bfa913c4aaa5702b2d4178e663118 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 09:26:53 +0200 Subject: [PATCH 219/291] global-functions: $GetMacVendor: :do ... on-error=... -> :onerror ... do=... --- global-functions.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index 3b7ff7c..35dd0e0 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -586,12 +586,12 @@ ("https://api.macvendors.com/" . [ :pick $Mac 0 8 ]) output=user as-value ]->"data"); :return $Vendor; } on-error={ - :do { + :onerror Err { /tool/fetch check-certificate=yes-without-crl ("https://api.macvendors.com/") \ output=none as-value; $LogPrint debug $0 ("The mac vendor is not known in database."); - } on-error={ - $LogPrint warning $0 ("Failed getting mac vendor."); + } do={ + $LogPrint warning $0 ("Failed getting mac vendor: " . $Err); } :return "unknown vendor"; } From 09f9826760316c35cb229bde4d065c89290c6076 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 09:27:50 +0200 Subject: [PATCH 220/291] global-functions: $MkDir: :do ... on-error=... -> :onerror ... do=... --- global-functions.rsc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index 35dd0e0..271e3a2 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -894,11 +894,11 @@ $LogPrint info $0 ("Creating disk of type tmpfs."); $RmDir "tmpfs"; - :do { + :onerror Err { /disk/add slot=tmpfs type=tmpfs tmpfs-max-size=([ /system/resource/get total-memory ] / 3); $WaitForFile "tmpfs"; - } on-error={ - $LogPrint warning $0 ("Creating disk of type tmpfs failed!"); + } do={ + $LogPrint warning $0 ("Creating disk of type tmpfs failed: " . $Err); :return false; } :return true; @@ -923,11 +923,11 @@ } } - :do { + :onerror Err { /file/add type="directory" name=$Path; $WaitForFile $Path; - } on-error={ - $LogPrint warning $0 ("Making directory '" . $Path . "' failed!"); + } do={ + $LogPrint warning $0 ("Making directory '" . $Path . "' failed: " . $Err); :return false; } From 86a8919ed2f87d75b2150b09ec5f237dc93f046e Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 09:29:22 +0200 Subject: [PATCH 221/291] global-functions: $RmDir: :do ... on-error=... -> :onerror ... do=... --- global-functions.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index 271e3a2..f0256fc 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -1052,10 +1052,10 @@ :return true; } - :do { + :onerror Err { /file/remove $Dir; - } on-error={ - $LogPrint error $0 ("Removing directory '" . $DirName . "' (" . $Dir . ") failed."); + } do={ + $LogPrint error $0 ("Removing directory '" . $DirName . "' (" . $Dir . ") failed: " . $Err); :return false; } :return true; From 2317013121f8b3a53dd588f0fa5020b61ba7da53 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 09:30:08 +0200 Subject: [PATCH 222/291] global-functions: $RmFile: :do ... on-error=... -> :onerror ... do=... --- global-functions.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index f0256fc..c883291 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -1080,10 +1080,10 @@ :return true; } - :do { + :onerror Err { /file/remove $File; - } on-error={ - $LogPrint error $0 ("Removing file '" . $FileName . "' (" . $File . ") failed."); + } do={ + $LogPrint error $0 ("Removing file '" . $FileName . "' (" . $File . ") failed: " . $Err); :return false; } :return true; From 12926b7c429f93a2579b134deef245793195744b Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 09:33:39 +0200 Subject: [PATCH 223/291] global-functions: $ScriptInstallUpdate: :do ... on-error=... -> :onerror ... do=... --- global-functions.rsc | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index c883291..1bbc77e 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -1201,7 +1201,7 @@ } } - :do { + :onerror Err { :local BaseUrl [ $EitherOr ($ScriptInfo->"base-url") $ScriptUpdatesBaseUrl ]; :local UrlSuffix [ $EitherOr ($ScriptInfo->"url-suffix") $ScriptUpdatesUrlSuffix ]; :local Url ($BaseUrl . $ScriptVal->"name" . ".rsc" . $UrlSuffix); @@ -1211,13 +1211,11 @@ :if ($Result->"status" = "finished") do={ :set SourceNew [ :tolf ($Result->"data") ]; } - } on-error={ + } do={ + $LogPrint warning $0 ("Failed fetching script '" . $ScriptVal->"name" . . "': " . $Err); :if ($ScriptVal->"source" = "#!rsc by RouterOS\n") do={ - $LogPrint warning $0 ("Failed fetching script '" . $ScriptVal->"name" . \ - "', removing dummy. Typo on installation?"); + $LogPrint warning $0 ("Removing dummy. Typo on installation?"); /system/script/remove $Script; - } else={ - $LogPrint warning $0 ("Failed fetching script '" . $ScriptVal->"name" . "'!"); } :error false; } @@ -1304,7 +1302,7 @@ :global GlobalConfigMigration; :local ChangeLogCode; - :do { + :onerror Err { :local Url ($ScriptUpdatesBaseUrl . "news-and-changes.rsc" . $ScriptUpdatesUrlSuffix); $LogPrint debug $0 ("Fetching news, changes and migration: " . $Url); :local Result [ /tool/fetch check-certificate=yes-without-crl \ @@ -1312,16 +1310,16 @@ :if ($Result->"status" = "finished") do={ :set ChangeLogCode ($Result->"data"); } - } on-error={ - $LogPrint warning $0 ("Failed fetching news, changes and migration!"); + } do={ + $LogPrint warning $0 ("Failed fetching news, changes and migration: " . $Err); } :if ([ :len $ChangeLogCode ] > 0) do={ :if ([ $ValidateSyntax $ChangeLogCode ] = true) do={ - :do { + :onerror Err { [ :parse $ChangeLogCode ]; - } on-error={ - $LogPrint warning $0 ("The changelog failed to run!"); + } do={ + $LogPrint warning $0 ("The changelog failed to run: " . $Err); } } else={ $LogPrint warning $0 ("The changelog failed syntax validation!"); @@ -1343,10 +1341,10 @@ } $LogPrint info $0 ("Applying migration for change " . $I . ": " . $Migration); - :do { + :onerror Err { [ :parse $Migration ]; - } on-error={ - $LogPrint warning $0 ("Migration code for change " . $I . " failed to run!"); + } do={ + $LogPrint warning $0 ("Migration code for change " . $I . " failed to run: " . $Err); } } on-error={ } } From f5c4378676ef1e791738106723071c3dd6fe65ca Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 09:37:18 +0200 Subject: [PATCH 224/291] global-functions: $ValidateSyntax: :do ... on-error=... -> :onerror ... do=... --- global-functions.rsc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index 1bbc77e..11ab677 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -1652,9 +1652,9 @@ :set ValidateSyntax do={ :local Code [ :tostr $1 ]; - :do { + :onerror Err { [ :parse (":local Validate do={\n" . $Code . "\n}") ]; - } on-error={ + } do={ :return false; } :return true; From 8b1b73c936c0a0172383a521f7bc5fb70d9d2f14 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 09:39:17 +0200 Subject: [PATCH 225/291] global-functions: $ValidateSyntax: add debug output --- global-functions.rsc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/global-functions.rsc b/global-functions.rsc index 11ab677..51b47b5 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -1652,9 +1652,12 @@ :set ValidateSyntax do={ :local Code [ :tostr $1 ]; + :global LogPrint; + :onerror Err { [ :parse (":local Validate do={\n" . $Code . "\n}") ]; } do={ + $LogPrint debug $0 ("Valdation failed: " . $Err); :return false; } :return true; From 5c599beae1c539ef4b657a6d8cb32195b4bfa174 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 09:40:41 +0200 Subject: [PATCH 226/291] global-functions: :do ... on-error=... -> :onerror ... do=... --- global-functions.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index 51b47b5..8331e4a 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -1771,10 +1771,10 @@ :foreach Script in=[ /system/script/find where name ~ "^mod/." ] do={ :local ScriptVal [ /system/script/get $Script ]; :if ([ $ValidateSyntax ($ScriptVal->"source") ] = true) do={ - :do { + :onerror Err { /system/script/run $Script; - } on-error={ - $LogPrint error $0 ("Module '" . $ScriptVal->"name" . "' failed to run."); + } do={ + $LogPrint error $0 ("Module '" . $ScriptVal->"name" . "' failed to run: " . $Err); } } else={ $LogPrint error $0 ("Module '" . $ScriptVal->"name" . "' failed syntax validation, skipping."); From d5f9ecebfbda885c4600ff99ee2713a5827e0398 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 09:41:57 +0200 Subject: [PATCH 227/291] gps-track: :do ... on-error=... -> :onerror ... do=... --- gps-track.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gps-track.rsc b/gps-track.rsc index 4cc5066..6a090bf 100644 --- a/gps-track.rsc +++ b/gps-track.rsc @@ -34,7 +34,7 @@ :local Gps [ /system/gps/monitor once as-value ]; :if ($Gps->"valid" = true) do={ - :do { + :onerror Err { /tool/fetch check-certificate=yes-without-crl output=none http-method=post \ http-header-field=({ [ $FetchUserAgentStr $ScriptName ]; "Content-Type: application/json" }) \ http-data=[ :serialize to=json { "identity"=$Identity; \ @@ -42,8 +42,8 @@ $LogPrint debug $ScriptName ("Sending GPS data in " . $CoordinateFormat . " format: " . \ "lat: " . ($Gps->"latitude") . " " . \ "lon: " . ($Gps->"longitude")); - } on-error={ - $LogPrint warning $ScriptName ("Failed sending GPS data!"); + } do={ + $LogPrint warning $ScriptName ("Failed sending GPS data: " . $Err); } } else={ $LogPrint debug $ScriptName ("GPS data not valid."); From c1e6348bb9ffaaa9e43dafab039ec261614e0711 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 09:42:48 +0200 Subject: [PATCH 228/291] lease-script: :do ... on-error=... -> :onerror ... do=... --- lease-script.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lease-script.rsc b/lease-script.rsc index b166ee3..ab44956 100644 --- a/lease-script.rsc +++ b/lease-script.rsc @@ -53,11 +53,11 @@ } :foreach Order,Script in=$RunOrder do={ - :do { + :onerror Err { $LogPrint debug $ScriptName ("Running script with order " . $Order . ": " . $Script); /system/script/run $Script; - } on-error={ - $LogPrint warning $ScriptName ("Running script '" . $Script . "' failed!"); + } do={ + $LogPrint warning $ScriptName ("Running script '" . $Script . "' failed: " . $Err); } } } do={ From 5badafe109c6514a83b2935aa3543054eb20ddc3 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 09:54:51 +0200 Subject: [PATCH 229/291] mod/notification-telegram: :do ... on-error=... -> :onerror ... do=... --- mod/notification-telegram.rsc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mod/notification-telegram.rsc b/mod/notification-telegram.rsc index 51c8dbf..0832b07 100644 --- a/mod/notification-telegram.rsc +++ b/mod/notification-telegram.rsc @@ -38,14 +38,14 @@ :foreach Id,Message in=$TelegramQueue do={ :if ([ :typeof $Message ] = "array" ) do={ - :do { + :onerror Err { :local Data ([ /tool/fetch check-certificate=yes-without-crl output=user http-method=post \ ("https://api.telegram.org/bot" . ($Message->"tokenid") . "/sendMessage") \ http-data=($Message->"http-data") as-value ]->"data"); :set ($TelegramQueue->$Id); :set ($TelegramMessageIDs->[ :tostr ([ :deserialize from=json value=$Data ]->"result"->"message_id") ]) 1; - } on-error={ - $LogPrint debug $0 ("Sending queued Telegram message failed."); + } do={ + $LogPrint debug $0 ("Sending queued Telegram message failed: " . $Err); :set AllDone false; } } @@ -72,12 +72,12 @@ } :local Data; - :do { + :onerror Err { :set Data ([ /tool/fetch check-certificate=yes-without-crl output=user \ ("https://api.telegram.org/bot" . $TelegramTokenId . "/getUpdates?offset=0" . \ "&allowed_updates=%5B%22message%22%5D") as-value ]->"data"); - } on-error={ - $LogPrint warning $0 ("Fetching data failed!"); + } do={ + $LogPrint warning $0 ("Fetching data failed: " . $Err); :return false; } @@ -190,7 +190,7 @@ :local HTTPData ("chat_id=" . $ChatId . "&disable_notification=" . ($Notification->"silent") . \ "&reply_to_message_id=" . ($Notification->"replyto") . "&message_thread_id=" . $ThreadId . \ "&disable_web_page_preview=true&parse_mode=MarkdownV2"); - :do { + :onerror Err { :if ([ $CertificateAvailable "Go Daddy Root Certificate Authority - G2" ] = false) do={ $LogPrint warning $0 ("Downloading required certificate failed."); :error false; @@ -199,8 +199,8 @@ ("https://api.telegram.org/bot" . $TokenId . "/sendMessage") \ http-data=($HTTPData . "&text=" . [ $UrlEncode $Text ]) as-value ]->"data"); :set ($TelegramMessageIDs->[ :tostr ([ :deserialize from=json value=$Data ]->"result"->"message_id") ]) 1; - } on-error={ - $LogPrint info $0 ("Failed sending Telegram notification! Queuing..."); + } do={ + $LogPrint info $0 ("Failed sending Telegram notification: " . $Err . " - Queuing..."); :if ([ :typeof $TelegramQueue ] = "nothing") do={ :set TelegramQueue ({}); From 2a7fd7ea53d62cc9897643250bb04022f1377ae3 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 09:55:55 +0200 Subject: [PATCH 230/291] mod/notification-ntfy: :do ... on-error=... -> :onerror ... do=... --- mod/notification-ntfy.rsc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mod/notification-ntfy.rsc b/mod/notification-ntfy.rsc index 8e5688e..7114020 100644 --- a/mod/notification-ntfy.rsc +++ b/mod/notification-ntfy.rsc @@ -36,13 +36,13 @@ :foreach Id,Message in=$NtfyQueue do={ :if ([ :typeof $Message ] = "array" ) do={ - :do { + :onerror Err { /tool/fetch check-certificate=yes-without-crl output=none http-method=post \ http-header-field=($Message->"headers") http-data=($Message->"text") \ ($Message->"url") as-value; :set ($NtfyQueue->$Id); - } on-error={ - $LogPrint debug $0 ("Sending queued Ntfy message failed."); + } do={ + $LogPrint debug $0 ("Sending queued Ntfy message failed: " . $Err); :set AllDone false; } } @@ -107,7 +107,7 @@ :set Text ($Text . "\n" . [ $SymbolForNotification "link" ] . ($Notification->"link")); } - :do { + :onerror Err { :if ($Server = "ntfy.sh") do={ :if ([ $CertificateAvailable "ISRG Root X1" ] = false) do={ $LogPrint warning $0 ("Downloading required certificate failed."); @@ -116,8 +116,8 @@ } /tool/fetch check-certificate=yes-without-crl output=none http-method=post \ http-header-field=$Headers http-data=$Text $Url as-value; - } on-error={ - $LogPrint info $0 ("Failed sending ntfy notification! Queuing..."); + } do={ + $LogPrint info $0 ("Failed sending ntfy notification: " . $Err . " - Queuing..."); :if ([ :typeof $NtfyQueue ] = "nothing") do={ :set NtfyQueue ({}); From 3f092d34774ac500faec0870e89a048a26a5bbf0 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 09:57:31 +0200 Subject: [PATCH 231/291] mod/notification-matrix: :do ... on-error=... -> :onerror ... do=... --- mod/notification-matrix.rsc | 42 ++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/mod/notification-matrix.rsc b/mod/notification-matrix.rsc index c8cf887..e9b42a0 100644 --- a/mod/notification-matrix.rsc +++ b/mod/notification-matrix.rsc @@ -39,7 +39,7 @@ :foreach Id,Message in=$MatrixQueue do={ :if ([ :typeof $Message ] = "array" ) do={ - :do { + :onerror Err { /tool/fetch check-certificate=yes-without-crl output=none \ http-header-field=($Message->"headers") http-method=post \ http-data=[ :serialize to=json { "msgtype"="m.text"; "body"=($Message->"plain"); @@ -47,8 +47,8 @@ ("https://" . $Message->"homeserver" . "/_matrix/client/r0/rooms/" . $Message->"room" . \ "/send/m.room.message?access_token=" . $Message->"accesstoken") as-value; :set ($MatrixQueue->$Id); - } on-error={ - $LogPrint debug $0 ("Sending queued Matrix message failed."); + } do={ + $LogPrint debug $0 ("Sending queued Matrix message failed: " . $Err); :set AllDone false; } } @@ -129,15 +129,15 @@ [ $PrepareText $Label ] . ""); } - :do { + :onerror Err { /tool/fetch check-certificate=yes-without-crl output=none \ http-header-field=$Headers http-method=post \ http-data=[ :serialize to=json { "msgtype"="m.text"; "body"=$Plain; "format"="org.matrix.custom.html"; "formatted_body"=$Formatted } ] \ ("https://" . $HomeServer . "/_matrix/client/r0/rooms/" . $Room . \ "/send/m.room.message?access_token=" . $AccessToken) as-value; - } on-error={ - $LogPrint info $0 ("Failed sending Matrix notification! Queuing..."); + } do={ + $LogPrint info $0 ("Failed sending Matrix notification: " . $Err . " - Queuing..."); :if ([ :typeof $MatrixQueue ] = "nothing") do={ :set MatrixQueue ({}); @@ -196,14 +196,14 @@ :global MatrixHomeServer; :local Domain [ :pick $User ([ :find $User ":" ] + 1) [ :len $User] ]; - :do { + :onerror Err { :local Data ([ /tool/fetch check-certificate=yes-without-crl output=user \ http-header-field=({ [ $FetchUserAgentStr $0 ] }) \ ("https://" . $Domain . "/.well-known/matrix/client") as-value ]->"data"); :set MatrixHomeServer ([ :deserialize from=json value=$Data ]->"m.homeserver"->"base_url"); $LogPrint debug $0 ("Home server is: " . $MatrixHomeServer); - } on-error={ - $LogPrint error $0 ("Failed getting home server!"); + } do={ + $LogPrint error $0 ("Failed getting home server: " . $Err); :return false; } @@ -211,27 +211,27 @@ :set MatrixHomeServer [ :pick $MatrixHomeServer 8 [ :len $MatrixHomeServer ] ]; } - :do { + :onerror Err { :local Data ([ /tool/fetch check-certificate=yes-without-crl output=user \ http-header-field=({ [ $FetchUserAgentStr $0 ] }) http-method=post \ http-data=[ :serialize to=json { "type"="m.login.password"; "user"=$User; "password"=$Pass } ] \ ("https://" . $MatrixHomeServer . "/_matrix/client/r0/login") as-value ]->"data"); :set MatrixAccessToken ([ :deserialize from=json value=$Data ]->"access_token"); $LogPrint debug $0 ("Access token is: " . $MatrixAccessToken); - } on-error={ - $LogPrint error $0 ("Failed logging in (and getting access token)!"); + } do={ + $LogPrint error $0 ("Failed logging in (and getting access token): " . $Err); :return false; } - :do { + :onerror Err { /system/script/remove [ find where name="global-config-overlay.d/mod/notification-matrix" ]; /system/script/add name="global-config-overlay.d/mod/notification-matrix" source=( \ "# configuration snippet: mod/notification-matrix\n\n" . \ ":global MatrixHomeServer \"" . $MatrixHomeServer . "\";\n" . \ ":global MatrixAccessToken \"" . $MatrixAccessToken . "\";\n"); $LogPrint info $0 ("Added configuration snippet. Now create and join a room, please!"); - } on-error={ - $LogPrint error $0 ("Failed adding configuration snippet!"); + } do={ + $LogPrint error $0 ("Failed adding configuration snippet: " . $Err); :return false; } } @@ -248,24 +248,24 @@ :global MatrixHomeServer; :global MatrixRoom; - :do { + :onerror Err { /tool/fetch check-certificate=yes-without-crl output=none \ http-header-field=({ [ $FetchUserAgentStr $0 ] }) http-method=post http-data="" \ ("https://" . $MatrixHomeServer . "/_matrix/client/r0/rooms/" . [ $UrlEncode $MatrixRoom ] . \ "/join?access_token=" . [ $UrlEncode $MatrixAccessToken ]) as-value; $LogPrint debug $0 ("Joined the room."); - } on-error={ - $LogPrint error $0 ("Failed joining the room!"); + } do={ + $LogPrint error $0 ("Failed joining the room: " . $Err); :return false; } - :do { + :onerror Err { :local Snippet [ /system/script/find where name="global-config-overlay.d/mod/notification-matrix" ]; /system/script/set $Snippet source=([ get $Snippet source ] . \ ":global MatrixRoom \"" . $MatrixRoom . "\";\n"); $LogPrint info $0 ("Appended configuration to configuration snippet. Please review!"); - } on-error={ - $LogPrint error $0 ("Failed appending configuration to snippet!"); + } do={ + $LogPrint error $0 ("Failed appending configuration to snippet: " . $Err); :return false; } } From e01873301f7a92fc0109d8afce845a175f414504 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 09:58:53 +0200 Subject: [PATCH 232/291] mod/notification-gotify: :do ... on-error=... -> :onerror ... do=... --- mod/notification-gotify.rsc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mod/notification-gotify.rsc b/mod/notification-gotify.rsc index 3ae4cdd..d8eafbe 100644 --- a/mod/notification-gotify.rsc +++ b/mod/notification-gotify.rsc @@ -37,13 +37,13 @@ :foreach Id,Message in=$GotifyQueue do={ :if ([ :typeof $Message ] = "array" ) do={ - :do { + :onerror Err { /tool/fetch check-certificate=yes-without-crl output=none http-method=post \ http-header-field=($Message->"headers") http-data=[ :serialize to=json ($Message->"message") ] \ ($Message->"url") as-value; :set ($GotifyQueue->$Id); - } on-error={ - $LogPrint debug $0 ("Sending queued Gotify message failed."); + } do={ + $LogPrint debug $0 ("Sending queued Gotify message failed: " . $Err); :set AllDone false; } } @@ -91,11 +91,11 @@ ("\n" . [ $SymbolForNotification "link" ] . ($Notification->"link")) ]); \ "priority"=[ :tonum [ $IfThenElse ($Notification->"silent") 2 5 ] ] }); - :do { + :onerror Err { /tool/fetch check-certificate=yes-without-crl output=none http-method=post \ http-header-field=$Headers http-data=[ :serialize to=json $Message ] $Url as-value; - } on-error={ - $LogPrint info $0 ("Failed sending Gotify notification! Queuing..."); + } do={ + $LogPrint info $0 ("Failed sending Gotify notification: " . $Err . " - Queuing..."); :if ([ :typeof $GotifyQueue ] = "nothing") do={ :set GotifyQueue ({}); From 314e68e4cd3d097d510cb0bef25fec838421b689 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 09:45:59 +0200 Subject: [PATCH 233/291] mode-button: :do ... on-error=... -> :onerror ... do=... --- mode-button.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mode-button.rsc b/mode-button.rsc index c6422f0..d82f899 100644 --- a/mode-button.rsc +++ b/mode-button.rsc @@ -69,11 +69,11 @@ :delay 200ms; } - :do { + :onerror Err { [ :parse $Code ]; - } on-error={ + } do={ $LogPrint warning $FuncName \ - ("The code for " . $Count . " mode-button presses failed with runtime error!"); + ("The code for " . $Count . " mode-button presses failed with runtime error: " . $Err); } } else={ $LogPrint warning $FuncName \ From 9ae21c00bdbbda52fea6c2cc32248d714617f1f8 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 10:02:15 +0200 Subject: [PATCH 234/291] mod/scriptrunonce: :do ... on-error=... -> :onerror ... do=... --- mod/scriptrunonce.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mod/scriptrunonce.rsc b/mod/scriptrunonce.rsc index 3797c15..1d6aaf1 100644 --- a/mod/scriptrunonce.rsc +++ b/mod/scriptrunonce.rsc @@ -41,11 +41,11 @@ :return false; } - :do { + :onerror Err { $LogPrint info $0 ("Running script '" . $Script . "' now."); [ :parse $Source ]; - } on-error={ - $LogPrint warning $0 ("The script '" . $Script . "' failed to run!"); + } do={ + $LogPrint warning $0 ("The script '" . $Script . "' failed to run: " . $Err); :return false; } From 9cd4ed08a475b93fbf11266dc5a0804afd58e195 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 10:05:12 +0200 Subject: [PATCH 235/291] mod/ssh-keys-import: :do ... on-error=... -> :onerror ... do=... --- mod/ssh-keys-import.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mod/ssh-keys-import.rsc b/mod/ssh-keys-import.rsc index 9a6cd39..176c1b4 100644 --- a/mod/ssh-keys-import.rsc +++ b/mod/ssh-keys-import.rsc @@ -55,13 +55,13 @@ /file/add name=$FileName contents=($Key . ", md5=" . $FingerPrintMD5); $WaitForFile $FileName; - :do { + :onerror Err { /user/ssh-keys/import public-key-file=$FileName user=$User; $LogPrint info $0 ("Imported ssh public key (" . $KeyVal->2 . ", " . $KeyVal->0 . ", " . \ "MD5:" . $FingerPrintMD5 . ") for user '" . $User . "'."); $RmDir "tmpfs/ssh-keys-import"; - } on-error={ - $LogPrint warning $0 ("Failed importing key."); + } do={ + $LogPrint warning $0 ("Failed importing key: " . $Err); $RmDir "tmpfs/ssh-keys-import"; :return false; } From c757064eb9537321b7cad69db6e05ddc9c576583 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 10:05:39 +0200 Subject: [PATCH 236/291] =?UTF-8?q?mod/ssh-keys-import:=20:do=20...=20on-e?= =?UTF-8?q?rror=3D...=20->=20...=20well...=20-=20fix=20condition=20?= =?UTF-8?q?=F0=9F=A5=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mod/ssh-keys-import.rsc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mod/ssh-keys-import.rsc b/mod/ssh-keys-import.rsc index 176c1b4..9467525 100644 --- a/mod/ssh-keys-import.rsc +++ b/mod/ssh-keys-import.rsc @@ -94,9 +94,7 @@ :foreach KeyVal in=[ :deserialize $Keys delimiter=" " from=dsv options=dsv.plain ] do={ :local Continue false; :if ($KeyVal->0 = "ssh-ed25519" || $KeyVal->0 = "ssh-rsa") do={ - :do { - $SSHKeysImport ($KeyVal->0 . " " . $KeyVal->1 . " " . $KeyVal->2) $User; - } on-error={ + :if ([ $SSHKeysImport ($KeyVal->0 . " " . $KeyVal->1 . " " . $KeyVal->2) $User ] = false) do={ $LogPrint warning $0 ("Failed importing key for user '" . $User . "'."); } :set Continue true; From a523f9793861d8927388f18bb5f2319bbe04c0b8 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 10:07:30 +0200 Subject: [PATCH 237/291] netwatch-dns: :do ... on-error=... -> :onerror ... do=... --- netwatch-dns.rsc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/netwatch-dns.rsc b/netwatch-dns.rsc index 3da1498..4fa076a 100644 --- a/netwatch-dns.rsc +++ b/netwatch-dns.rsc @@ -118,15 +118,15 @@ } :local Data false; - :do { + :onerror Err { :set Data ([ /tool/fetch check-certificate=yes-without-crl output=user \ http-header-field=({ "accept: application/dns-message" }) \ url=(($DohServer->"doh-url") . "?dns=" . [ :convert to=base64 ([ :rndstr length=2 ] . \ "\01\00" . "\00\01" . "\00\00" . "\00\00" . "\00\00" . "\09doh-check\05eworm\02de\00" . \ "\00\10" . "\00\01") ]) as-value ]->"data"); - } on-error={ - $LogPrint warning $ScriptName ("Request to DoH server failed (network or certificate issue): " . \ - ($DohServer->"doh-url")); + } do={ + $LogPrint warning $ScriptName ("Request to DoH server " . ($DohServer->"doh-url") . \ + " failed: " . $Err); } :if ($Data != false) do={ From fefe59751f1487fbdd4feace39c32445bd97547c Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 10:09:59 +0200 Subject: [PATCH 238/291] netwatch-notify: :do ... on-error=... -> :onerror ... do=... --- netwatch-notify.rsc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/netwatch-notify.rsc b/netwatch-notify.rsc index fb8e8d5..00f03cd 100644 --- a/netwatch-notify.rsc +++ b/netwatch-notify.rsc @@ -38,10 +38,10 @@ :global ValidateSyntax; :if ([ $ValidateSyntax $Hook ] = true) do={ - :do { + onerror Err { [ :parse $Hook ]; - } on-error={ - $LogPrint warning $ScriptName ("The " . $State . "-hook for " . $Type . " '" . $Name . "' failed to run."); + } do={ + $LogPrint warning $ScriptName ("The " . $State . "-hook for " . $Type . " '" . $Name . "' failed to run: " . $Err); :return ("The hook failed to run."); } } else={ @@ -107,7 +107,7 @@ :if ([ :typeof ($HostInfo->"resolve") ] = "str") do={ :if ([ $IsDNSResolving ] = true) do={ - :do { + :onerror Err { :local Resolve [ :resolve type=[ $IfThenElse ([ :typeof ($HostVal->"host") ] = "ip") \ "ipv4" "ipv6" ] ($HostInfo->"resolve") ]; :if ($Resolve != $HostVal->"host") do={ @@ -121,13 +121,13 @@ :set ($HostVal->"status") "unknown"; } } - } on-error={ + } do={ :set ($Metric->"resolve-failcnt") ($Metric->"resolve-failcnt" + 1); :if ($Metric->"resolve-failcnt" = 3) do={ $LogPrint [ $IfThenElse ($HostInfo->"no-resolve-fail" != true) warning debug ] \ $ScriptName ("Resolving name '" . $HostInfo->"resolve" . [ $IfThenElse \ ($HostInfo->"resolve" != $HostInfo->"name") ("' for " . $Type . " '" . \ - $HostInfo->"name") "" ] . "' failed."); + $HostInfo->"name") "" ] . "' failed: " . $Err); } } } From d0adf9974e75668fc16e736ce2dc29a1477b10b8 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 10:12:08 +0200 Subject: [PATCH 239/291] sms-forward: :do ... on-error=... -> :onerror ... do=... --- sms-forward.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sms-forward.rsc b/sms-forward.rsc index a564056..feb640e 100644 --- a/sms-forward.rsc +++ b/sms-forward.rsc @@ -74,12 +74,12 @@ :if ($Phone~($Hook->"allowed-number") && ($SmsVal->"message")~($Hook->"match")) do={ :if ([ $ValidateSyntax ($Hook->"command") ] = true) do={ $LogPrint info $ScriptName ("Running hook '" . $Hook->"match" . "': " . $Hook->"command"); - :do { + :onerror Err { :local Command [ :parse ($Hook->"command") ]; $Command Phone=$Phone Message=($SmsVal->"message"); :set Messages ($Messages . "\n\nRan hook '" . $Hook->"match" . "':\n" . $Hook->"command"); - } on-error={ - $LogPrint warning $ScriptName ("The code for hook '" . $Hook->"match" . "' failed to run!"); + } do={ + $LogPrint warning $ScriptName ("The code for hook '" . $Hook->"match" . "' failed to run: " . $Err); } } else={ $LogPrint warning $ScriptName ("The code for hook '" . $Hook->"match" . "' failed syntax validation!"); From f22d46da96dfe0c421172d30ee1baf9976205329 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 10:13:05 +0200 Subject: [PATCH 240/291] telegram-chat: :do ... on-error=... -> :onerror ... do=... --- telegram-chat.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/telegram-chat.rsc b/telegram-chat.rsc index b1f7f99..5bfa31c 100644 --- a/telegram-chat.rsc +++ b/telegram-chat.rsc @@ -70,14 +70,14 @@ :local Data false; :for I from=1 to=4 do={ :if ($Data = false) do={ - :do { + :onerror Err { :set Data ([ /tool/fetch check-certificate=yes-without-crl output=user \ ("https://api.telegram.org/bot" . $TelegramTokenId . "/getUpdates?offset=" . \ $TelegramChatOffset->0 . "&allowed_updates=%5B%22message%22%5D") as-value ]->"data"); :set TelegramRandomDelay [ $MAX 0 ($TelegramRandomDelay - 1) ]; - } on-error={ + } do={ :if ($I < 4) do={ - $LogPrint debug $ScriptName ("Fetch failed, " . $I . ". try."); + $LogPrint debug $ScriptName ("Fetch failed, " . $I . ". try: " . $Err); :set TelegramRandomDelay [ $MIN 15 ($TelegramRandomDelay + 5) ]; :delay (($I * $I) . "s"); } From 10ac81634877858717a3d99fee418edc9887b377 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 10:14:24 +0200 Subject: [PATCH 241/291] unattended-lte-firmware-upgrade: :do ... on-error=... -> :onerror ... do=... --- unattended-lte-firmware-upgrade.rsc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/unattended-lte-firmware-upgrade.rsc b/unattended-lte-firmware-upgrade.rsc index 83925fd..237c2d8 100644 --- a/unattended-lte-firmware-upgrade.rsc +++ b/unattended-lte-firmware-upgrade.rsc @@ -12,10 +12,10 @@ :foreach Interface in=[ /interface/lte/find where running ] do={ :local Firmware; :local IntName [ /interface/lte/get $Interface name ]; - :do { + :onerror Err { :set Firmware [ /interface/lte/firmware-upgrade $Interface as-value ]; - } on-error={ - :log debug ("Could not get latest LTE firmware version for interface " . $IntName . "."); + } do={ + :log debug ("Could not get latest LTE firmware version for interface " . $IntName . ": " . $Err); } :if ([ :typeof $Firmware ] = "array") do={ @@ -27,7 +27,7 @@ :set LTEFirmwareUpgrade; /system/scheduler/remove ($1 . "-firmware-upgrade"); - :do { + :onerror Err { /interface/lte/firmware-upgrade $1 upgrade=yes; :log info ("LTE firmware upgrade on '" . $1 . "' finished, waiting for reset."); :delay 240s; @@ -36,8 +36,8 @@ ($Firmware->"installed") != ($Firmware->"latest")) do={ :log warning ("LTE firmware versions still differ. Upgrade failed anyway?"); } - } on-error={ - :log error ("LTE firmware upgrade on '" . $1 . "' failed."); + } do={ + :log error ("LTE firmware upgrade on '" . $1 . "' failed: " . $Err); } } From 205bcce6f9d49518f1e1999154d96b0e0bb6d1ed Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 10:15:35 +0200 Subject: [PATCH 242/291] update-tunnelbroker: :do ... on-error=... -> :onerror ... do=... --- update-tunnelbroker.rsc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/update-tunnelbroker.rsc b/update-tunnelbroker.rsc index 8e5e1d0..9057e1e 100644 --- a/update-tunnelbroker.rsc +++ b/update-tunnelbroker.rsc @@ -41,12 +41,12 @@ :for I from=2 to=0 do={ :if ($Data = false) do={ - :do { + :onerror Err { :set Data ([ /tool/fetch check-certificate=yes-without-crl \ ("https://ipv4.tunnelbroker.net/nic/update?hostname=" . $Comment->"id") \ user=($Comment->"user") password=($Comment->"pass") output=user as-value ]->"data"); - } on-error={ - $LogPrint debug $ScriptName ("Failed downloading, " . $I . " retries pending."); + } do={ + $LogPrint debug $ScriptName ("Failed downloading: " . $Err . " - " . $I . " retries pending."); :delay 2s; } } From 3521995dbc1173e722819efca1908cd0df251b1d Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 11:07:39 +0200 Subject: [PATCH 243/291] mod/inspectvar: use $CharacterMultiply --- mod/inspectvar.rsc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mod/inspectvar.rsc b/mod/inspectvar.rsc index 89c0286..b864d9a 100644 --- a/mod/inspectvar.rsc +++ b/mod/inspectvar.rsc @@ -33,11 +33,9 @@ :local Value [ :tostr $2 ]; :local Level [ :tonum $3 ]; - :local Indent ""; - :for I from=1 to=$Level step=1 do={ - :set Indent ($Indent . " "); - } - :return ($Indent . "-" . $Prefix . "-> " . $Value); + :global CharacterMultiply; + + :return ([ $CharacterMultiply " " $Level ] . "-" . $Prefix . "-> " . $Value); } :local TypeOf [ :typeof $Input ]; From 187735f35f7b361b1cc6d45f703d5c121681254c Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 11:12:02 +0200 Subject: [PATCH 244/291] mod/inspectvar: print the length for strings --- mod/inspectvar.rsc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mod/inspectvar.rsc b/mod/inspectvar.rsc index b864d9a..84c40d8 100644 --- a/mod/inspectvar.rsc +++ b/mod/inspectvar.rsc @@ -39,6 +39,7 @@ } :local TypeOf [ :typeof $Input ]; + :local Len [ :len $Input ]; :local Return [ $IndentReturn "type" $TypeOf $Level ]; :if ($TypeOf = "array") do={ @@ -48,6 +49,10 @@ [ $InspectVarReturn $Value ($Level + 2) ]); } } else={ + :if ($TypeOf = "str") do={ + :set $Return ($Return . "\n" . \ + [ $IndentReturn "len" $Len $Level ]); + } :if ($TypeOf != "nothing") do={ :set $Return ($Return . "\n" . \ [ $IndentReturn "value" [ $IfThenElse ([ :len $Input ] > 80) \ From 36f155ce621abe427d126a6ee3a3363bff15b2bb Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 11:15:21 +0200 Subject: [PATCH 245/291] mod/inspectvar: remove CR, replace LF --- mod/inspectvar.rsc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mod/inspectvar.rsc b/mod/inspectvar.rsc index 84c40d8..b32480f 100644 --- a/mod/inspectvar.rsc +++ b/mod/inspectvar.rsc @@ -25,6 +25,7 @@ :local Input $1; :local Level (0 + [ :tonum $2 ]); + :global CharacterReplace; :global IfThenElse; :global InspectVarReturn; @@ -52,6 +53,7 @@ :if ($TypeOf = "str") do={ :set $Return ($Return . "\n" . \ [ $IndentReturn "len" $Len $Level ]); + :set Input [ $CharacterReplace [ $CharacterReplace $Input ("\r") "" ] ("\n") " " ]; } :if ($TypeOf != "nothing") do={ :set $Return ($Return . "\n" . \ From bd3cc3bbd49934f42fe9f6c6820501c7cc9d33ba Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 13:35:49 +0200 Subject: [PATCH 246/291] mod/inspectvar: replace only when matching --- mod/inspectvar.rsc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mod/inspectvar.rsc b/mod/inspectvar.rsc index b32480f..fc1b366 100644 --- a/mod/inspectvar.rsc +++ b/mod/inspectvar.rsc @@ -53,7 +53,12 @@ :if ($TypeOf = "str") do={ :set $Return ($Return . "\n" . \ [ $IndentReturn "len" $Len $Level ]); - :set Input [ $CharacterReplace [ $CharacterReplace $Input ("\r") "" ] ("\n") " " ]; + :if ([ :typeof [ :find $Input ("\r") ] ] = "num") do={ + :set Input [ $CharacterReplace $Input ("\r") "" ]; + } + :if ([ :typeof [ :find $Input ("\n") ] ] = "num") do={ + :set Input [ $CharacterReplace $Input ("\n") " " ]; + } } :if ($TypeOf != "nothing") do={ :set $Return ($Return . "\n" . \ From ff218e4ce5032b2ead7f33f53382bda98f6e5e2e Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 11:21:59 +0200 Subject: [PATCH 247/291] mod/notification-email: add error handling when sending mail --- mod/notification-email.rsc | 57 +++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/mod/notification-email.rsc b/mod/notification-email.rsc index c0f9d86..e05a813 100644 --- a/mod/notification-email.rsc +++ b/mod/notification-email.rsc @@ -89,35 +89,40 @@ :foreach Id,Message in=$EmailQueue do={ :if ([ :typeof $Message ] = "array" ) do={ - :local Attach ({}); :while ([ /tool/e-mail/get last-status ] = "in-progress") do={ :delay 1s; } - :foreach File in=[ :toarray [ $EitherOr ($Message->"attach") "" ] ] do={ - :if ([ :len [ /file/find where name=$File ] ] = 1) do={ - :set Attach ($Attach, $File); - } else={ - $LogPrint warning $0 ("File '" . $File . "' does not exist, can not attach."); - } - } - /tool/e-mail/send from=[ $EMailGenerateFrom ] to=($Message->"to") cc=($Message->"cc") \ - subject=($Message->"subject") body=($Message->"body") file=$Attach; - :local Wait true; - :do { - :delay 1s; - :local Status [ /tool/e-mail/get last-status ]; - :if ($Status = "succeeded") do={ - :set ($EmailQueue->$Id); - :set Wait false; - :if (($Message->"remove-attach") = true) do={ - :foreach File in=$Attach do={ - /file/remove $File; - } + :onerror Err { + :local Attach ({}); + :foreach File in=[ :toarray [ $EitherOr ($Message->"attach") "" ] ] do={ + :if ([ :len [ /file/find where name=$File ] ] = 1) do={ + :set Attach ($Attach, $File); + } else={ + $LogPrint warning $0 ("File '" . $File . "' does not exist, can not attach."); } } - :if ($Status = "failed") do={ - :set AllDone false; - :set Wait false; - } - } while=($Wait = true); + /tool/e-mail/send from=[ $EMailGenerateFrom ] to=($Message->"to") cc=($Message->"cc") \ + subject=($Message->"subject") body=($Message->"body") file=$Attach; + :local Wait true; + :do { + :delay 1s; + :local Status [ /tool/e-mail/get last-status ]; + :if ($Status = "succeeded") do={ + :set ($EmailQueue->$Id); + :set Wait false; + :if (($Message->"remove-attach") = true) do={ + :foreach File in=$Attach do={ + /file/remove $File; + } + } + } + :if ($Status = "failed") do={ + :set AllDone false; + :set Wait false; + } + } while=($Wait = true); + } do={ + $LogPrint warning $0 ("Sending queued mail failed: " . $Err); + :set AllDone false; + } } } From 74dc809b98759cb337fbaf6b1fa98bb0137dadc0 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 13:29:01 +0200 Subject: [PATCH 248/291] mod/notification-email: properly truncate the body Truned out that the size limit for e-mail message/body is anywhere just below 64kB... So truncate at about 62.000 bytes. --- mod/notification-email.rsc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/mod/notification-email.rsc b/mod/notification-email.rsc index e05a813..c799c87 100644 --- a/mod/notification-email.rsc +++ b/mod/notification-email.rsc @@ -181,6 +181,7 @@ :global IfThenElse; :global NotificationEMailSignature; :global NotificationEMailSubject; + :global SymbolForNotification; :local To [ $EitherOr ($EmailGeneralToOverride->($Notification->"origin")) $EmailGeneralTo ]; :local Cc [ $EitherOr ($EmailGeneralCcOverride->($Notification->"origin")) $EmailGeneralCc ]; @@ -193,13 +194,22 @@ :if ([ :typeof $EmailQueue ] = "nothing") do={ :set EmailQueue ({}); } + :local Truncated false; + :local Body ($Notification->"message"); + :if ([ :len $Body ] > 62000) do={ + :set Body ([ :pick $Body 0 62000 ] . "..."); + :set Truncated true; + } :local Signature [ $EitherOr [ $NotificationEMailSignature ] [ /system/note/get note ] ]; + :set Body ($Body . "\n" . \ + [ $IfThenElse ([ :len ($Notification->"link") ] > 0) ("\n" . ($Notification->"link")) ] . \ + [ $IfThenElse ($Truncated = true) ("\n" . [ $SymbolForNotification "scissors" ] . \ + "The message was too long and has been truncated!") ] . \ + [ $IfThenElse ([ :len $Signature ] > 0) ("\n-- \n" . $Signature) "" ]); :set ($EmailQueue->[ :len $EmailQueue ]) { to=$To; cc=$Cc; subject=[ $NotificationEMailSubject ($Notification->"subject") ]; - body=(($Notification->"message") . \ - [ $IfThenElse ([ :len ($Notification->"link") ] > 0) ("\n\n" . ($Notification->"link")) "" ] . \ - [ $IfThenElse ([ :len $Signature ] > 0) ("\n-- \n" . $Signature) "" ]); \ + body=$Body; \ attach=($Notification->"attach"); remove-attach=($Notification->"remove-attach") }; :if ([ :len [ /system/scheduler/find where name="_FlushEmailQueue" ] ] = 0) do={ /system/scheduler/add name="_FlushEmailQueue" interval=1s start-time=startup \ From 2a956874777c83748f4a2afea4e9ee1382928230 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 8 May 2025 14:54:42 +0200 Subject: [PATCH 249/291] mod/notification-email: add the link symbol --- mod/notification-email.rsc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mod/notification-email.rsc b/mod/notification-email.rsc index c799c87..5293766 100644 --- a/mod/notification-email.rsc +++ b/mod/notification-email.rsc @@ -202,7 +202,8 @@ } :local Signature [ $EitherOr [ $NotificationEMailSignature ] [ /system/note/get note ] ]; :set Body ($Body . "\n" . \ - [ $IfThenElse ([ :len ($Notification->"link") ] > 0) ("\n" . ($Notification->"link")) ] . \ + [ $IfThenElse ([ :len ($Notification->"link") ] > 0) \ + ("\n" . [ $SymbolForNotification "link" ] . ($Notification->"link")) ] . \ [ $IfThenElse ($Truncated = true) ("\n" . [ $SymbolForNotification "scissors" ] . \ "The message was too long and has been truncated!") ] . \ [ $IfThenElse ([ :len $Signature ] > 0) ("\n-- \n" . $Signature) "" ]); From ce129ee4418a09d4b1987e3d94818a561d9fd384 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Sun, 11 May 2025 22:02:18 +0200 Subject: [PATCH 250/291] fw-addr-lists: for IPv6 the CIDR is always expected --- fw-addr-lists.rsc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fw-addr-lists.rsc b/fw-addr-lists.rsc index 5a03875..efd37db 100644 --- a/fw-addr-lists.rsc +++ b/fw-addr-lists.rsc @@ -114,8 +114,8 @@ :error true; } :if ($Address ~ "^[0-9a-zA-Z]*:[0-9a-zA-Z:\\.]+(/[0-9]{1,3})?\$") do={ - :if ($Address ~ "/128\$") do={ - :set Address [ :pick $Address 0 ([ :len $Address ] - 4) ]; + :if ([ :typeof [ :find $Address "/" ] ] = "nil") do={ + :set Address ($Address . "/128"); } :set ($IPv6Addresses->$Branch->$Address) $TimeOut; :error true; From e78c71948dfa847fd21820dffacd3c6e7165d832 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 12 May 2025 16:50:06 +0200 Subject: [PATCH 251/291] mod/notification-telegram: fix indention --- mod/notification-telegram.rsc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/notification-telegram.rsc b/mod/notification-telegram.rsc index 0832b07..2eb90e1 100644 --- a/mod/notification-telegram.rsc +++ b/mod/notification-telegram.rsc @@ -189,7 +189,7 @@ :local HTTPData ("chat_id=" . $ChatId . "&disable_notification=" . ($Notification->"silent") . \ "&reply_to_message_id=" . ($Notification->"replyto") . "&message_thread_id=" . $ThreadId . \ - "&disable_web_page_preview=true&parse_mode=MarkdownV2"); + "&disable_web_page_preview=true&parse_mode=MarkdownV2"); :onerror Err { :if ([ $CertificateAvailable "Go Daddy Root Certificate Authority - G2" ] = false) do={ $LogPrint warning $0 ("Downloading required certificate failed."); From 1b5dd1e1d3555f347bd6ff587659ac8b8ec5c73e Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 12 May 2025 16:53:55 +0200 Subject: [PATCH 252/291] telegram-chat: support trusted group chat ids But be warned: Adding a person to a trusted group will give her/him administrative control over the device(s) - without changes on the device itself! On the other hand... Removing permissions is easily done by removing a person from a group. Closes: https://github.com/eworm-de/routeros-scripts/issues/101 --- telegram-chat.rsc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/telegram-chat.rsc b/telegram-chat.rsc index 5bfa31c..50fc0cc 100644 --- a/telegram-chat.rsc +++ b/telegram-chat.rsc @@ -107,7 +107,9 @@ :local ThreadId [ $IfThenElse ($Message->"is_topic_message") ($Message->"message_thread_id") "" ]; :foreach IdsTrusted in=($TelegramChatId, $TelegramChatIdsTrusted) do={ - :if ($From->"id" = $IdsTrusted || $From->"username" = $IdsTrusted) do={ + :if ($From->"id" = $IdsTrusted || \ + $From->"username" = $IdsTrusted || \ + $Chat->"id" = $IdsTrusted) do={ :set Trusted true; } } From f1396b83aa7f506fe653184016cd970728eb9407 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 13 May 2025 09:52:12 +0200 Subject: [PATCH 253/291] telegram-chat: support debug output for updates in JSON --- telegram-chat.rsc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/telegram-chat.rsc b/telegram-chat.rsc index 50fc0cc..277c40f 100644 --- a/telegram-chat.rsc +++ b/telegram-chat.rsc @@ -33,6 +33,7 @@ :global GetRandom20CharAlNum; :global IfThenElse; :global LogPrint; + :global LogPrintVerbose; :global MAX; :global MIN; :global MkDir; @@ -96,6 +97,8 @@ :local Uptime [ /system/resource/get uptime ]; :foreach Update in=($JSON->"result") do={ :set UpdateID ($Update->"update_id"); + $LogPrintVerbose debug $ScriptName ("Update " . $UpdateID . ": " . [ :serialize to=json $Update ]); + :local Message ($Update->"message"); :local IsReply ([ :typeof ($Message->"reply_to_message") ] = "string"); :local IsMyReply ($TelegramMessageIDs->[ :tostr ($Message->"reply_to_message"->"message_id") ]); From 64fe923c5aea4e6b8cd549a39f8e76c1e9814391 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 13 May 2025 10:02:03 +0200 Subject: [PATCH 254/291] DEBUG: fix typo --- DEBUG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEBUG.md b/DEBUG.md index d5e9beb..66bf728 100644 --- a/DEBUG.md +++ b/DEBUG.md @@ -42,7 +42,7 @@ Other actions (`disk`, `email`, `remote` or `support`) can be used as well. I do not recommend using `echo` - use [debug output](#debug-output) instead. -Disable or remote that setting to restore regular logging. +Disable or remove that setting to restore regular logging. ## Verbose output From 86ad41f6b612ef3b904e053b2dbf2f12d3260842 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 23 May 2025 09:06:02 +0200 Subject: [PATCH 255/291] fix the trust state for certificates RouterOS 7.19 is suffering an issue with certificate store, where the trust state is not available correctly. This effects certificates imported a long time ago, with RouterOS 7.4 or older. Fixing trust state for all certificates by re-setting the trust state... (Reported as SUP-188791...) --- global-functions.rsc | 2 +- news-and-changes.rsc | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/global-functions.rsc b/global-functions.rsc index 8331e4a..ef849e0 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -15,7 +15,7 @@ # Git commit id & info, expected configuration version :global CommitId "unknown"; :global CommitInfo "unknown"; -:global ExpectedConfigVersion 137; +:global ExpectedConfigVersion 138; # global variables not to be changed by user :global GlobalFunctionsReady false; diff --git a/news-and-changes.rsc b/news-and-changes.rsc index a9a2904..dbfb1b9 100644 --- a/news-and-changes.rsc +++ b/news-and-changes.rsc @@ -62,6 +62,7 @@ 135="Introduced helper function '\$GetTelegramChatId' for 'mod/notification-telegram' which helps retrieve information."; 136="Introduced script 'check-perpetual-license' to check for license state on CHR."; 137="Added support to send notifications via Gotify (gotify.net)."; + 138="RouterOS 7.19 is suffering an issue with certificate store. Fixing trust state for all certificates..."; }; # Migration steps to be applied on script updates @@ -71,4 +72,5 @@ 104=":global CharacterReplace; :global ScriptInstallUpdate; :foreach Script in={ \"capsman-download-packages\"; \"capsman-rolling-upgrade\"; \"hotspot-to-wpa\"; \"hotspot-to-wpa-cleanup\" } do={ /system/script/set name=(\$Script . \".capsman\") [ find where name=\$Script ]; :foreach Scheduler in=[ /system/scheduler/find where on-event~(\$Script . \"([^-.]|\\\$)\") ] do={ /system/scheduler/set \$Scheduler on-event=[ \$CharacterReplace [ get \$Scheduler on-event ] \$Script (\$Script . \".capsman\") ]; }; }; /ip/hotspot/user/profile/set on-login=\"hotspot-to-wpa.capsman\" [ find where on-login=\"hotspot-to-wpa\" ]; \$ScriptInstallUpdate;"; 111=":local Rec [ /ip/dns/static/find where comment~\"^managed by dhcp-to-dns for \" ]; :if ([ :len \$Rec ] > 0) do={ /ip/dns/static/remove \$Rec; /system/script/run dhcp-to-dns; }"; 132=":if ([ :len [ /system/script/find where name=\"check-health\" ] ] > 0) do={ :local Code \":local Install \\\"check-health\\\"; :if ([ :len [ /system/health/find where type=\\\"\\\" name~\\\"-state\\\\\\\$\\\" ] ] > 0) do={ :set Install (\\\$Install . \\\",check-health.d/state\\\"); }; :if ([ :len [ /system/health/find where type=\\\"C\\\" ] ] > 0) do={ :set Install (\\\$Install . \\\",check-health.d/temperature\\\"); }; :if ([ :len [ /system/health/find where type=\\\"V\\\" ] ] > 0) do={ :set Install (\\\$Install . \\\",check-health.d/voltage\\\"); }; :global ScriptInstallUpdate; \\\$ScriptInstallUpdate \\\$Install;\"; :global ValidateSyntax; :if ([ \$ValidateSyntax \$Code ] = true) do={ :do { [ :parse \$Code ]; } on-error={ }; }; }"; + 138="/certificate/set trusted=yes [ find where trusted=yes ];"; }; From 4bd7d44cd2b9252d7389f049c367e57c642551d5 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 23 May 2025 11:16:40 +0200 Subject: [PATCH 256/291] global-functions: $ScriptInstallUpdate: fix syntax error --- global-functions.rsc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global-functions.rsc b/global-functions.rsc index ef849e0..55dbdee 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -1212,7 +1212,7 @@ :set SourceNew [ :tolf ($Result->"data") ]; } } do={ - $LogPrint warning $0 ("Failed fetching script '" . $ScriptVal->"name" . . "': " . $Err); + $LogPrint warning $0 ("Failed fetching script '" . $ScriptVal->"name" . "': " . $Err); :if ($ScriptVal->"source" = "#!rsc by RouterOS\n") do={ $LogPrint warning $0 ("Removing dummy. Typo on installation?"); /system/script/remove $Script; From c50acd697a75d9e1dd3d336405d4bdc1567546ee Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 23 May 2025 17:36:56 +0200 Subject: [PATCH 257/291] telegram-chat: fix detection of replies --- telegram-chat.rsc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telegram-chat.rsc b/telegram-chat.rsc index 277c40f..9862479 100644 --- a/telegram-chat.rsc +++ b/telegram-chat.rsc @@ -100,7 +100,7 @@ $LogPrintVerbose debug $ScriptName ("Update " . $UpdateID . ": " . [ :serialize to=json $Update ]); :local Message ($Update->"message"); - :local IsReply ([ :typeof ($Message->"reply_to_message") ] = "string"); + :local IsReply ([ :typeof ($Message->"reply_to_message") ] = "array"); :local IsMyReply ($TelegramMessageIDs->[ :tostr ($Message->"reply_to_message"->"message_id") ]); :if (($IsMyReply = 1 || $TelegramChatOffset->0 > 0 || $Uptime > 5m) && $UpdateID >= $TelegramChatOffset->2) do={ :local Trusted false; From 6a49c483b679d7dc68b7b12617be24508c3fa5b4 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 23 May 2025 17:38:22 +0200 Subject: [PATCH 258/291] telegram-chat: rename variable... ... to better describe the use. --- telegram-chat.rsc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/telegram-chat.rsc b/telegram-chat.rsc index 9862479..fdd0883 100644 --- a/telegram-chat.rsc +++ b/telegram-chat.rsc @@ -100,7 +100,7 @@ $LogPrintVerbose debug $ScriptName ("Update " . $UpdateID . ": " . [ :serialize to=json $Update ]); :local Message ($Update->"message"); - :local IsReply ([ :typeof ($Message->"reply_to_message") ] = "array"); + :local IsAnyReply ([ :typeof ($Message->"reply_to_message") ] = "array"); :local IsMyReply ($TelegramMessageIDs->[ :tostr ($Message->"reply_to_message"->"message_id") ]); :if (($IsMyReply = 1 || $TelegramChatOffset->0 > 0 || $Uptime > 5m) && $UpdateID >= $TelegramChatOffset->2) do={ :local Trusted false; @@ -138,7 +138,7 @@ " from update " . $UpdateID . "!"); :set Done true; } - :if ($Done = false && ($IsMyReply = 1 || ($IsReply = false && \ + :if ($Done = false && ($IsMyReply = 1 || ($IsAnyReply = false && \ $TelegramChatActive = true)) && [ :len $Command ] > 0) do={ :if ([ $ValidateSyntax $Command ] = true) do={ :local State ""; From 3d3b270748b43362d0ec51a1e52f300e6770b469 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 28 May 2025 14:07:57 +0200 Subject: [PATCH 259/291] README: give a hint on builtin certificate store I guess this should become the default any time in future... --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2a8b2ce..bc09840 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,14 @@ including demonstation recorded live at [MUM Europe ### The long way in detail The update script does server certificate verification, so first step is to -download the certificates. If you intend to download the scripts from a +download the certificates. + +> đŸ’Ąī¸ **Hint**: RouterOS 7.19 comes with a builtin certificate store. You +> can skip the steps regarding certificate download and import if you set +> the trust for these builtin trust anchors: +> `/certificate/settings/set builtin-trust-anchors=trusted;` + +If you intend to download the scripts from a different location (for example from github.com) install the corresponding certificate chain. From d59c4aee26788f3c5088c32a3bd54f0562b4d2b4 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 28 May 2025 14:16:57 +0200 Subject: [PATCH 260/291] README: add a paragraph and link to jump --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bc09840..243e1fc 100644 --- a/README.md +++ b/README.md @@ -75,8 +75,9 @@ The update script does server certificate verification, so first step is to download the certificates. > đŸ’Ąī¸ **Hint**: RouterOS 7.19 comes with a builtin certificate store. You -> can skip the steps regarding certificate download and import if you set -> the trust for these builtin trust anchors: +> can skip the steps regarding certificate download and import and jump +> to [installation of scripts](#installation-of-scripts) if you set the +> trust for these builtin trust anchors: > `/certificate/settings/set builtin-trust-anchors=trusted;` If you intend to download the scripts from a @@ -113,6 +114,8 @@ is shown. Always make sure there are no certificates installed you do not know or want! +#### Installation of scripts + All following commands will verify the server certificate. For validity the certificate's lifetime is checked with local time, so make sure the device's date and time is set correctly! From bf684a7197f9ad07e23415de5779a366af7dd71b Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 28 May 2025 15:08:26 +0200 Subject: [PATCH 261/291] global-functions: $CertificateAvailable: try to use builtin certificates The builtin certificates were introduced with RouterOS 7.19, so requires this hacky :parse workaround. --- global-functions.rsc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/global-functions.rsc b/global-functions.rsc index 55dbdee..759b274 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -119,6 +119,11 @@ :return false; } + :if (([ /certificate/settings/get ]->"builtin-trust-anchors") = "trusted" && \ + [[ :parse (":return [ :len [ /certificate/builtin/find where common-name=\"" . $CommonName . "\" ] ]") ]] > 0) do={ + :return true; + } + :if ([ :len [ /certificate/find where common-name=$CommonName ] ] = 0) do={ $LogPrint info $0 ("Certificate with CommonName '" . $CommonName . "' not available."); :if ([ $CertificateDownload $CommonName ] = false) do={ From d69b39957278a9393762ec1653895eeb69483e9e Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 28 May 2025 16:38:50 +0200 Subject: [PATCH 262/291] INITIAL-COMMANDS: use builtin certificates if possible --- INITIAL-COMMANDS.md | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/INITIAL-COMMANDS.md b/INITIAL-COMMANDS.md index 79773bd..40f609b 100644 --- a/INITIAL-COMMANDS.md +++ b/INITIAL-COMMANDS.md @@ -18,17 +18,21 @@ Run the complete base installation: { :local BaseUrl "https://git.eworm.de/cgit/routeros-scripts/plain/"; + :local CertCommonName "ISRG Root X2"; :local CertFileName "ISRG-Root-X2.pem"; :local CertFingerprint "69729b8e15a86efc177a57afb7171dfc64add28c2fca8cf1507e34453ccb1470"; - :put "Importing certificate..."; - /tool/fetch ($BaseUrl . "certs/" . $CertFileName) dst-path=$CertFileName as-value; - :delay 1s; - /certificate/import file-name=$CertFileName passphrase=""; - :if ([ :len [ /certificate/find where fingerprint=$CertFingerprint ] ] != 1) do={ - :error "Something is wrong with your certificates!"; + :if (!(([ /certificate/settings/get ]->"builtin-trust-anchors") = "trusted" && \ + [[ :parse (":return [ :len [ /certificate/builtin/find where common-name=\"" . $CertCommonName . "\" ] ]") ]] > 0)) do={ + :put "Importing certificate..."; + /tool/fetch ($BaseUrl . "certs/" . $CertFileName) dst-path=$CertFileName as-value; + :delay 1s; + /certificate/import file-name=$CertFileName passphrase=""; + :if ([ :len [ /certificate/find where fingerprint=$CertFingerprint ] ] != 1) do={ + :error "Something is wrong with your certificates!"; + }; + :delay 1s; }; - :delay 1s; :put "Renaming global-config-overlay, if exists..."; /system/script/set name=("global-config-overlay-" . [ /system/clock/get date ] . "-" . [ /system/clock/get time ]) [ find where name="global-config-overlay" ]; :foreach Script in={ "global-config"; "global-config-overlay"; "global-functions" } do={ @@ -41,9 +45,11 @@ Run the complete base installation: :put "Scheduling to load configuration and functions..."; /system/scheduler/remove [ find where name="global-scripts" ]; /system/scheduler/add name="global-scripts" start-time=startup on-event="/system/script { run global-config; run global-functions; }"; - :put "Renaming certificate by its common-name..."; - :global CertificateNameByCN; - $CertificateNameByCN $CertFingerprint; + :if ([ :len [ /certificate/find where fingerprint=$CertFingerprint ] ] > 0) do={ + :put "Renaming certificate by its common-name..."; + :global CertificateNameByCN; + $CertificateNameByCN $CertFingerprint; + }; }; Then continue setup with From b70e6e79843f7c1bbc0031dd74cdf8005d3da4ff Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 2 Jun 2025 21:53:23 +0200 Subject: [PATCH 263/291] global-functions: introduce $FileGet --- global-functions.rsc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/global-functions.rsc b/global-functions.rsc index 759b274..3a2d20a 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -38,6 +38,7 @@ :global ExitError; :global FetchHuge; :global FetchUserAgentStr; +:global FileGet; :global FormatLine; :global FormatMultiLines; :global GetMacVendor; @@ -529,6 +530,18 @@ $Resource->"architecture-name" . " " . $Caller . "/Fetch (https://rsc.eworm.de/)"); } +# get file properties in array, or false on error +:set FileGet do={ + :local FileName [ :tostr $1 ]; + + :local FileVal false; + :do { + :set FileVal [ /file/get $FileName ]; + } on-error={ } + + :return $FileVal; +} + # format a line for output :set FormatLine do={ :local Key [ :tostr $1 ]; From 1e4f168735663cc09395980b5fa24a25f6403347 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 30 May 2025 20:42:25 +0200 Subject: [PATCH 264/291] global-functions: $MkDir: use $FileGet ... ... to work around restrictions in new file handling. --- global-functions.rsc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/global-functions.rsc b/global-functions.rsc index 3a2d20a..3b2ab95 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -893,6 +893,7 @@ :local Path [ :tostr $1 ]; :global CleanFilePath; + :global FileGet; :global LogPrint; :global RmDir; :global WaitForFile; @@ -930,7 +931,8 @@ $LogPrint debug $0 ("Making directory: " . $Path); - :if ([ :len [ /file/find where name=$Path type="directory" ] ] = 1) do={ + :local PathVal [ $FileGet $Path ]; + :if ($PathVal->"type" = "directory") do={ $LogPrint debug $0 ("... which already exists."); :return true; } From d993495e44563f841f7fed19fcf3162a6cb7b971 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 30 May 2025 21:38:26 +0200 Subject: [PATCH 265/291] global-functions: $RmDir: use $FileGet ... ... to work around restrictions in new file handling. --- global-functions.rsc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index 3b2ab95..2d0cd39 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -1057,25 +1057,26 @@ :set RmDir do={ :local DirName [ :tostr $1 ]; + :global FileGet; :global LogPrint; $LogPrint debug $0 ("Removing directory: ". $DirName); - :if ([ :len [ /file/find where name=$DirName type!=directory ] ] > 0) do={ - $LogPrint error $0 ("Directory '" . $DirName . "' is not a directory."); - :return false; - } - - :local Dir [ /file/find where name=$DirName type=directory ]; - :if ([ :len $Dir ] = 0) do={ + :local DirVal [ $FileGet $DirName ]; + :if ($DirVal = false) do={ $LogPrint debug $0 ("... which does not exist."); :return true; } + :if ($DirVal->"type" != "directory") do={ + $LogPrint error $0 ("Directory '" . $DirName . "' is not a directory."); + :return false; + } + :onerror Err { - /file/remove $Dir; + /file/remove $DirName; } do={ - $LogPrint error $0 ("Removing directory '" . $DirName . "' (" . $Dir . ") failed: " . $Err); + $LogPrint error $0 ("Removing directory '" . $DirName . "' failed: " . $Err); :return false; } :return true; From fb8e616846ab8decb10a8b792b5307a01195110d Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 30 May 2025 21:41:34 +0200 Subject: [PATCH 266/291] global-functions: $RmFile: use $FileGet ... ... to work around restrictions in new file handling. --- global-functions.rsc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index 2d0cd39..985deba 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -1086,25 +1086,26 @@ :set RmFile do={ :local FileName [ :tostr $1 ]; + :global FileGet; :global LogPrint; $LogPrint debug $0 ("Removing file: ". $FileName); - :if ([ :len [ /file/find where name=$FileName (type=directory or type=disk) ] ] > 0) do={ - $LogPrint error $0 ("File '" . $FileName . "' is not a file."); - :return false; - } - - :local File [ /file/find where name=$FileName !(type=directory or type=disk) ]; - :if ([ :len $File ] = 0) do={ + :local FileVal [ $FileGet $FileName ]; + :if ($FileVal = false) do={ $LogPrint debug $0 ("... which does not exist."); :return true; } + :if ($FileVal->"type" = "directory" || $FileVal->"type" = "disk") do={ + $LogPrint error $0 ("File '" . $FileName . "' is not a file."); + :return false; + } + :onerror Err { - /file/remove $File; + /file/remove $FileName; } do={ - $LogPrint error $0 ("Removing file '" . $FileName . "' (" . $File . ") failed: " . $Err); + $LogPrint error $0 ("Removing file '" . $FileName . "' failed: " . $Err); :return false; } :return true; From e08bb2192dfd22b25652553f28304818a3602331 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 30 May 2025 20:48:05 +0200 Subject: [PATCH 267/291] global-functions: $WaitForFile: drop the workaround This was fixed in RouterOS 7.18rc1, so should be ok to remove now. --- global-functions.rsc | 9 --------- 1 file changed, 9 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index 985deba..3a62169 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -1757,15 +1757,6 @@ :set I ($I + 1); } - :while ([ :len [ /file/find where name=$FileName ] ] > 0) do={ - :do { - /file/get $FileName; - :return true; - } on-error={ } - :delay $Delay; - :set Delay ($Delay * 3 / 2); - } - :return false; } From 0e00a228d67d77fadc80eee2df04c2cec25b8db8 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 30 May 2025 21:25:20 +0200 Subject: [PATCH 268/291] global-functions: $WaitForFile: use :retry for simplification, ... ... and to work around restrictions in new file handling. --- global-functions.rsc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index 3a62169..fa5d2be 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -1746,16 +1746,14 @@ :global MAX; :set FileName [ $CleanFilePath $FileName ]; - :local I 1; :local Delay ([ $MAX [ $EitherOr $WaitTime 2s ] 100ms ] / 10); - :while ([ :len [ /file/find where name=$FileName ] ] = 0) do={ - :if ($I >= 10) do={ - :return false; - } - :delay $Delay; - :set I ($I + 1); - } + :do { + :retry { + /file/get $FileName; + :return true; + } delay=$Delay max=10; + } on-error={ } :return false; } From cb984a5e527a12aaa2336cfd66f180302755f066 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 30 May 2025 20:34:07 +0200 Subject: [PATCH 269/291] global-functions: introduce $FileExists --- global-functions.rsc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/global-functions.rsc b/global-functions.rsc index fa5d2be..ddddc40 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -38,6 +38,7 @@ :global ExitError; :global FetchHuge; :global FetchUserAgentStr; +:global FileExists; :global FileGet; :global FormatLine; :global FormatMultiLines; @@ -530,6 +531,29 @@ $Resource->"architecture-name" . " " . $Caller . "/Fetch (https://rsc.eworm.de/)"); } +# check for existence of file, optionally with type +:set FileExists do={ + :local FileName [ :tostr $1 ]; + :local Type [ :tostr $2 ]; + + :global FileGet; + + :local FileVal [ $FileGet $FileName ]; + :if ($FileVal = false) do={ + :return false; + } + + :if ([ :len ($FileVal->"size") ] = 0) do={ + :return false; + } + + :if ([ :len $Type ] = 0 || $FileVal->"type" = $Type) do={ + :return true; + } + + :return false; +} + # get file properties in array, or false on error :set FileGet do={ :local FileName [ :tostr $1 ]; From 8353a8547f45a18e167b8ffd3779d8bd469dd1c7 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 30 May 2025 20:44:49 +0200 Subject: [PATCH 270/291] global-functions: $DownloadPackage: use $FileExists ... ... to work around restrictions in new file handling. --- global-functions.rsc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index ddddc40..50426b6 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -365,6 +365,7 @@ :global CertificateAvailable; :global CleanFilePath; + :global FileExists; :global LogPrint; :global MkDir; :global RmFile; @@ -385,7 +386,7 @@ :return false; } - :if ([ :len [ /file/find where name=$PkgDest type="package" ] ] > 0) do={ + :if ([ $FileExists $PkgDest "package" ] = true) do={ $LogPrint info $0 ("Package file " . $PkgName . " already exists."); :return true; } @@ -407,7 +408,7 @@ :return false; } - :if ([ /file/get [ find where name=$PkgDest ] type ] != "package") do={ + :if ([ $FileExists $PkgDest "package" ] = false) do={ $LogPrint warning $0 ("Downloaded file is not a package, removing."); $RmFile $PkgDest; :return false; From a2f837be591e4e64f2634e1d2e57352989326e98 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 30 May 2025 22:39:18 +0200 Subject: [PATCH 271/291] backup-email: use :retry and $FileExists ... ... to work around restrictions in new file handling. --- backup-email.rsc | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/backup-email.rsc b/backup-email.rsc index 632d2e6..cff6fd8 100644 --- a/backup-email.rsc +++ b/backup-email.rsc @@ -27,6 +27,7 @@ :global CleanName; :global DeviceInfo; + :global FileExists; :global FormatLine; :global LogPrint; :global MkDir; @@ -124,16 +125,16 @@ attach=$Attach; remove-attach=true }); # wait for the mail to be sent - :local I 0; - :while ([ :len [ /file/find where name ~ ($FilePath . "\\.(backup|rsc)\$") ] ] > 0) do={ - :if ($I >= 120) do={ - $LogPrint warning $ScriptName ("Files are still available, sending e-mail failed."); - :set PackagesUpdateBackupFailure true; - :set ExitOK true; - :error false; - } - :delay 1s; - :set I ($I + 1); + :do { + :retry { + :if ([ $FileExists ($FilePath . ".backup") "backup" ] = true || \ + [ $FileExists ($FilePath . ".rsc") "script" ] = true) do={ + :error "Files are still available."; + } + } delay=1s max=120; + } on-error={ + $LogPrint warning $ScriptName ("Files are still available, sending e-mail failed."); + :set PackagesUpdateBackupFailure true; } } do={ :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; From 43bac7c33c50e164ff7ac56029519d510bc08973 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 2 Jun 2025 23:52:29 +0200 Subject: [PATCH 272/291] backup-email: check for .conf file --- backup-email.rsc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backup-email.rsc b/backup-email.rsc index cff6fd8..cc62105 100644 --- a/backup-email.rsc +++ b/backup-email.rsc @@ -127,7 +127,8 @@ # wait for the mail to be sent :do { :retry { - :if ([ $FileExists ($FilePath . ".backup") "backup" ] = true || \ + :if ([ $FileExists ($FilePath . ".conf") ".conf file" ] = true || \ + [ $FileExists ($FilePath . ".backup") "backup" ] = true || \ [ $FileExists ($FilePath . ".rsc") "script" ] = true) do={ :error "Files are still available."; } From daee05dbd7c03aa7ce977ba7856234026185c4a1 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 2 Jun 2025 23:49:50 +0200 Subject: [PATCH 273/291] backup-email: add a comment why files are not removed --- backup-email.rsc | 1 + 1 file changed, 1 insertion(+) diff --git a/backup-email.rsc b/backup-email.rsc index cc62105..8015bea 100644 --- a/backup-email.rsc +++ b/backup-email.rsc @@ -137,6 +137,7 @@ $LogPrint warning $ScriptName ("Files are still available, sending e-mail failed."); :set PackagesUpdateBackupFailure true; } + # do not remove the files here, as the mail is still queued! } do={ :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From e3284ca77081642d2105d6a6773fa6767188dbec Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 30 May 2025 22:46:03 +0200 Subject: [PATCH 274/291] mod/notification-email: use $FileExists ... ... to work around restrictions in new file handling. --- mod/notification-email.rsc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mod/notification-email.rsc b/mod/notification-email.rsc index 5293766..75e11b9 100644 --- a/mod/notification-email.rsc +++ b/mod/notification-email.rsc @@ -40,6 +40,7 @@ :global EitherOr; :global EMailGenerateFrom; + :global FileExists; :global IsDNSResolving; :global IsTimeSync; :global LogPrint; @@ -93,7 +94,7 @@ :onerror Err { :local Attach ({}); :foreach File in=[ :toarray [ $EitherOr ($Message->"attach") "" ] ] do={ - :if ([ :len [ /file/find where name=$File ] ] = 1) do={ + :if ([ $FileExists $File ] = true) do={ :set Attach ($Attach, $File); } else={ $LogPrint warning $0 ("File '" . $File . "' does not exist, can not attach."); From 2d81984aed8894200e4f8c6c72596b8b05bdbb93 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 30 May 2025 22:46:16 +0200 Subject: [PATCH 275/291] mod/notification-email: use $RmFile --- mod/notification-email.rsc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mod/notification-email.rsc b/mod/notification-email.rsc index 75e11b9..ad9762a 100644 --- a/mod/notification-email.rsc +++ b/mod/notification-email.rsc @@ -44,6 +44,7 @@ :global IsDNSResolving; :global IsTimeSync; :global LogPrint; + :global RmFile; :local AllDone true; :local QueueLen [ :len $EmailQueue ]; @@ -111,7 +112,7 @@ :set Wait false; :if (($Message->"remove-attach") = true) do={ :foreach File in=$Attach do={ - /file/remove $File; + $RmFile $File; } } } From 80aed200fd7400e4a4958ba314912488780be635 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 30 May 2025 22:48:57 +0200 Subject: [PATCH 276/291] mod/ssh-keys-import: use $FileExists ... ... to work around restrictions in new file handling. --- mod/ssh-keys-import.rsc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mod/ssh-keys-import.rsc b/mod/ssh-keys-import.rsc index 9467525..7bdc95d 100644 --- a/mod/ssh-keys-import.rsc +++ b/mod/ssh-keys-import.rsc @@ -75,6 +75,7 @@ :local User [ :tostr $2 ]; :global EitherOr; + :global FileExists; :global LogPrint; :global ParseKeyValueStore; :global SSHKeysImport; @@ -84,8 +85,7 @@ :return false; } - :local File [ /file/find where name=$FileName ]; - :if ([ :len $File ] = 0) do={ + :if ([ $FileExists $FileName ] = true) do={ $LogPrint warning $0 ("File '" . $FileName . "' does not exist."); :return false; } From 30b80e903dbf80510fbb05f21c598ecf6c1834d7 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 30 May 2025 22:41:03 +0200 Subject: [PATCH 277/291] telegram-chat: use $FileExists ... ... to work around restrictions in new file handling. --- telegram-chat.rsc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/telegram-chat.rsc b/telegram-chat.rsc index fdd0883..7f7b7a7 100644 --- a/telegram-chat.rsc +++ b/telegram-chat.rsc @@ -30,6 +30,7 @@ :global CertificateAvailable; :global EitherOr; :global EscapeForRegEx; + :global FileExists; :global GetRandom20CharAlNum; :global IfThenElse; :global LogPrint; @@ -154,7 +155,7 @@ :if ([ $WaitForFile ($File . ".done") [ $EitherOr $TelegramChatRunTime 20s ] ] = false) do={ :set State ([ $SymbolForNotification "warning-sign" ] . "The command did not finish, still running in background.\n\n"); } - :if ([ :len [ /file/find where name=($File . ".failed") ] ] > 0) do={ + :if ([ $FileExists ($File . ".failed") ] = true) do={ :set State ([ $SymbolForNotification "cross-mark" ] . "The command failed with an error!\n\n"); } :local Content ([ /file/read chunk-size=32768 file=$File as-value ]->"data"); From 5b15c82bb11f9da1b6858504dc1e0de401e91c8f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 2 Jun 2025 22:16:43 +0200 Subject: [PATCH 278/291] capsman-download-packages: use $FileGet ... ... to work around restrictions in new file handling. --- capsman-download-packages.capsman.rsc | 3 ++- capsman-download-packages.template.rsc | 3 ++- capsman-download-packages.wifi.rsc | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/capsman-download-packages.capsman.rsc b/capsman-download-packages.capsman.rsc index cab1e4c..e296e15 100644 --- a/capsman-download-packages.capsman.rsc +++ b/capsman-download-packages.capsman.rsc @@ -20,6 +20,7 @@ :global CleanFilePath; :global DownloadPackage; + :global FileGet; :global LogPrint; :global MkDir; :global RmFile; @@ -42,7 +43,7 @@ :error false; } - :if ([ :len [ /file/find where name=$PackagePath type="directory" ] ] = 0) do={ + :if ([ $FileGet $PackagePath ] = false) do={ :if ([ $MkDir $PackagePath ] = false) do={ $LogPrint warning $ScriptName ("Creating directory at CAPsMAN package path (" . \ $PackagePath . ") failed!"); diff --git a/capsman-download-packages.template.rsc b/capsman-download-packages.template.rsc index ea41120..4040d4d 100644 --- a/capsman-download-packages.template.rsc +++ b/capsman-download-packages.template.rsc @@ -21,6 +21,7 @@ :global CleanFilePath; :global DownloadPackage; + :global FileGet; :global LogPrint; :global MkDir; :global RmFile; @@ -44,7 +45,7 @@ :error false; } - :if ([ :len [ /file/find where name=$PackagePath type="directory" ] ] = 0) do={ + :if ([ $FileGet $PackagePath ] = false) do={ :if ([ $MkDir $PackagePath ] = false) do={ $LogPrint warning $ScriptName ("Creating directory at CAPsMAN package path (" . \ $PackagePath . ") failed!"); diff --git a/capsman-download-packages.wifi.rsc b/capsman-download-packages.wifi.rsc index a810356..809fe8e 100644 --- a/capsman-download-packages.wifi.rsc +++ b/capsman-download-packages.wifi.rsc @@ -20,6 +20,7 @@ :global CleanFilePath; :global DownloadPackage; + :global FileGet; :global LogPrint; :global MkDir; :global RmFile; @@ -42,7 +43,7 @@ :error false; } - :if ([ :len [ /file/find where name=$PackagePath type="directory" ] ] = 0) do={ + :if ([ $FileGet $PackagePath ] = false) do={ :if ([ $MkDir $PackagePath ] = false) do={ $LogPrint warning $ScriptName ("Creating directory at CAPsMAN package path (" . \ $PackagePath . ") failed!"); From 15fd522d3db507cc7c22af9cd59ff85d41a5be6f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 30 May 2025 23:22:59 +0200 Subject: [PATCH 279/291] capsman-download-packages: adopt new functionality from file menu --- capsman-download-packages.capsman.rsc | 8 ++++---- capsman-download-packages.template.rsc | 8 ++++---- capsman-download-packages.wifi.rsc | 8 ++++---- doc/capsman-download-packages.md | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/capsman-download-packages.capsman.rsc b/capsman-download-packages.capsman.rsc index e296e15..aaebf5c 100644 --- a/capsman-download-packages.capsman.rsc +++ b/capsman-download-packages.capsman.rsc @@ -4,7 +4,7 @@ # Michael Gisbers # https://rsc.eworm.de/COPYING.md # -# requires RouterOS, version=7.15 +# requires RouterOS, version=7.18 # # download and cleanup packages for CAP installation from CAPsMAN # https://rsc.eworm.de/doc/capsman-download-packages.md @@ -54,8 +54,8 @@ "). Please place your packages!"); } - :foreach Package in=[ /file/find where type=package \ - package-version!=$InstalledVersion name~("^" . $PackagePath) ] do={ + :foreach Package in=[ /file/find recursive where path=$PackagePath \ + type="package" package-version!=$InstalledVersion ] do={ :local File [ /file/get $Package ]; :if ($File->"package-architecture" = "mips") do={ :set ($File->"package-architecture") "mipsbe"; @@ -67,7 +67,7 @@ } } - :if ([ :len [ /file/find where type=package name~("^" . $PackagePath) ] ] = 0) do={ + :if ([ :len [ /file/find recursive where path=$PackagePath type="package" ] ] = 0) do={ $LogPrint info $ScriptName ("No packages available, downloading default set."); :foreach Arch in={ "arm"; "mipsbe" } do={ :foreach Package in={ "routeros"; "wireless" } do={ diff --git a/capsman-download-packages.template.rsc b/capsman-download-packages.template.rsc index 4040d4d..ebbba70 100644 --- a/capsman-download-packages.template.rsc +++ b/capsman-download-packages.template.rsc @@ -4,7 +4,7 @@ # Michael Gisbers # https://rsc.eworm.de/COPYING.md # -# requires RouterOS, version=7.15 +# requires RouterOS, version=7.18 # # download and cleanup packages for CAP installation from CAPsMAN # https://rsc.eworm.de/doc/capsman-download-packages.md @@ -56,8 +56,8 @@ "). Please place your packages!"); } - :foreach Package in=[ /file/find where type=package \ - package-version!=$InstalledVersion name~("^" . $PackagePath) ] do={ + :foreach Package in=[ /file/find recursive where path=$PackagePath \ + type="package" package-version!=$InstalledVersion ] do={ :local File [ /file/get $Package ]; :if ($File->"package-architecture" = "mips") do={ :set ($File->"package-architecture") "mipsbe"; @@ -69,7 +69,7 @@ } } - :if ([ :len [ /file/find where type=package name~("^" . $PackagePath) ] ] = 0) do={ + :if ([ :len [ /file/find recursive where path=$PackagePath type="package" ] ] = 0) do={ $LogPrint info $ScriptName ("No packages available, downloading default set."); # NOT /interface/wifi/ # :foreach Arch in={ "arm"; "mipsbe" } do={ diff --git a/capsman-download-packages.wifi.rsc b/capsman-download-packages.wifi.rsc index 809fe8e..7de0431 100644 --- a/capsman-download-packages.wifi.rsc +++ b/capsman-download-packages.wifi.rsc @@ -4,7 +4,7 @@ # Michael Gisbers # https://rsc.eworm.de/COPYING.md # -# requires RouterOS, version=7.15 +# requires RouterOS, version=7.18 # # download and cleanup packages for CAP installation from CAPsMAN # https://rsc.eworm.de/doc/capsman-download-packages.md @@ -54,8 +54,8 @@ "). Please place your packages!"); } - :foreach Package in=[ /file/find where type=package \ - package-version!=$InstalledVersion name~("^" . $PackagePath) ] do={ + :foreach Package in=[ /file/find recursive where path=$PackagePath \ + type="package" package-version!=$InstalledVersion ] do={ :local File [ /file/get $Package ]; :if ($File->"package-architecture" = "mips") do={ :set ($File->"package-architecture") "mipsbe"; @@ -67,7 +67,7 @@ } } - :if ([ :len [ /file/find where type=package name~("^" . $PackagePath) ] ] = 0) do={ + :if ([ :len [ /file/find recursive where path=$PackagePath type="package" ] ] = 0) do={ $LogPrint info $ScriptName ("No packages available, downloading default set."); :foreach Arch in={ "arm"; "arm64" } do={ :local Packages { "arm"={ "routeros"; "wifi-qcom"; "wifi-qcom-ac" }; diff --git a/doc/capsman-download-packages.md b/doc/capsman-download-packages.md index 5722227..4daad49 100644 --- a/doc/capsman-download-packages.md +++ b/doc/capsman-download-packages.md @@ -4,7 +4,7 @@ Download packages for CAP upgrade from CAPsMAN [![GitHub stars](https://img.shields.io/github/stars/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=red)](https://github.com/eworm-de/routeros-scripts/stargazers) [![GitHub forks](https://img.shields.io/github/forks/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=green)](https://github.com/eworm-de/routeros-scripts/network) [![GitHub watchers](https://img.shields.io/github/watchers/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=blue)](https://github.com/eworm-de/routeros-scripts/watchers) -[![required RouterOS version](https://img.shields.io/badge/RouterOS-7.15-yellow?style=flat)](https://mikrotik.com/download/changelogs/) +[![required RouterOS version](https://img.shields.io/badge/RouterOS-7.18-yellow?style=flat)](https://mikrotik.com/download/changelogs/) [![Telegram group @routeros_scripts](https://img.shields.io/badge/Telegram-%40routeros__scripts-%2326A5E4?logo=telegram&style=flat)](https://t.me/routeros_scripts) [![donate with PayPal](https://img.shields.io/badge/Like_it%3F-Donate!-orange?logo=githubsponsors&logoColor=orange&style=flat)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J) From c3d3d61f92d4d3e219373045dbd3b982af18a824 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 2 Jun 2025 15:58:00 +0200 Subject: [PATCH 280/291] packages-update: support deferred reboot with longer interval --- doc/packages-update.md | 4 ++-- packages-update.rsc | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/packages-update.md b/doc/packages-update.md index 75225fe..a0a1795 100644 --- a/doc/packages-update.md +++ b/doc/packages-update.md @@ -46,8 +46,8 @@ Configuration The configuration goes to `global-config-overlay`, this is the only parameter: -* `PackagesUpdateDeferReboot`: defer the reboot for night (between 3 AM - and 5 AM) +* `PackagesUpdateDeferReboot`: defer the reboot for night (between 3 AM and + 5 AM), use a numerical value in days suffixed with a `d` to defer further By modifying the scheduler's `start-time` you can force the reboot at different time. diff --git a/packages-update.rsc b/packages-update.rsc index 4fde131..43f6749 100644 --- a/packages-update.rsc +++ b/packages-update.rsc @@ -31,19 +31,24 @@ :local Schedule do={ :local ScriptName [ :tostr $1 ]; + :global PackagesUpdateDeferReboot; + :global GetRandomNumber; + :global IfThenElse; :global LogPrint; :global RebootForUpdate do={ /system/reboot; } + :local Interval [ $IfThenElse ($PackagesUpdateDeferReboot >= 1d) $PackagesUpdateDeferReboot 1d ]; :local StartTime [ :tostr [ :totime (10800 + [ $GetRandomNumber 7200 ]) ] ]; - /system/scheduler/add name="_RebootForUpdate" start-time=$StartTime interval=1d \ + /system/scheduler/add name="_RebootForUpdate" start-time=$StartTime interval=$Interval \ on-event=("/system/scheduler/remove \"_RebootForUpdate\"; " . \ ":global RebootForUpdate; \$RebootForUpdate;"); $LogPrint info $ScriptName ("Scheduled reboot for update at " . $StartTime . \ - " local time (" . [ /system/clock/get time-zone-name ] . ")."); + " local time (" . [ /system/clock/get time-zone-name ] . ")" . \ + [ $IfThenElse ($Interval > 1d) (" deferred by " . $Interval) ] . "."); :return true; } @@ -153,7 +158,7 @@ :error true; } } else={ - :if ($PackagesUpdateDeferReboot = true) do={ + :if ($PackagesUpdateDeferReboot = true || $PackagesUpdateDeferReboot >= 1d) do={ $Schedule $ScriptName; :set ExitOK true; :error true; From 1f4bf9ee63c57a711652954d6d408b221a6503e5 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 2 Jun 2025 16:12:28 +0200 Subject: [PATCH 281/291] check-routeros-update: remove a stale scheduler --- check-routeros-update.rsc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/check-routeros-update.rsc b/check-routeros-update.rsc index e28a019..8b80dde 100644 --- a/check-routeros-update.rsc +++ b/check-routeros-update.rsc @@ -28,6 +28,7 @@ :global EscapeForRegEx; :global FetchUserAgentStr; :global LogPrint; + :global RebootForUpdate; :global ScriptFromTerminal; :global ScriptLock; :global SendNotification2; @@ -62,9 +63,14 @@ $WaitFullyConnected; :if ([ :len [ /system/scheduler/find where name="_RebootForUpdate" ] ] > 0) do={ - $LogPrint info $ScriptName ("A reboot for update is already scheduled."); - :set ExitOK true; - :error false; + :if ([ :typeof $RebootForUpdate ] = "nothing") do={ + $LogPrint info $ScriptName ("Found a stale scheduler for reboot, removing."); + /system/scheduler/remove "_RebootForUpdate"; + } else={ + $LogPrint info $ScriptName ("A reboot for update is already scheduled."); + :set ExitOK true; + :error false; + } } $LogPrint debug $ScriptName ("Checking for updates..."); From 0de6d006ae1773b38bef60845c6c343bc20f5da6 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 2 Jun 2025 21:37:59 +0200 Subject: [PATCH 282/291] update list of contributors --- CONTRIBUTIONS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTIONS.md b/CONTRIBUTIONS.md index 5bf5d08..00861c1 100644 --- a/CONTRIBUTIONS.md +++ b/CONTRIBUTIONS.md @@ -35,6 +35,7 @@ Add yourself to the list, [donate with PayPal â†—ī¸](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J)! * Abdul Mannan Abbasi +* Alex Maier * Andrea Ruffini Perico * Andrew Cox * Christoph Boss (@Kampfwurst) From 595b4aea9d43f6eef3aa3dad7a198431a7e3cf9a Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 10 Jun 2025 22:54:40 +0200 Subject: [PATCH 283/291] capsman-download-packages: revert changes for "new functionality" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (Though we keep the quoting for type.) Well, turned out this functionality is for `/file/print` only, but does not work with `/file/find`. đŸĢŖđŸĨ´ This reverts commit 15fd522d3db507cc7c22af9cd59ff85d41a5be6f. --- capsman-download-packages.capsman.rsc | 8 ++++---- capsman-download-packages.template.rsc | 8 ++++---- capsman-download-packages.wifi.rsc | 8 ++++---- doc/capsman-download-packages.md | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/capsman-download-packages.capsman.rsc b/capsman-download-packages.capsman.rsc index aaebf5c..2ea1667 100644 --- a/capsman-download-packages.capsman.rsc +++ b/capsman-download-packages.capsman.rsc @@ -4,7 +4,7 @@ # Michael Gisbers # https://rsc.eworm.de/COPYING.md # -# requires RouterOS, version=7.18 +# requires RouterOS, version=7.15 # # download and cleanup packages for CAP installation from CAPsMAN # https://rsc.eworm.de/doc/capsman-download-packages.md @@ -54,8 +54,8 @@ "). Please place your packages!"); } - :foreach Package in=[ /file/find recursive where path=$PackagePath \ - type="package" package-version!=$InstalledVersion ] do={ + :foreach Package in=[ /file/find where type="package" \ + package-version!=$InstalledVersion name~("^" . $PackagePath) ] do={ :local File [ /file/get $Package ]; :if ($File->"package-architecture" = "mips") do={ :set ($File->"package-architecture") "mipsbe"; @@ -67,7 +67,7 @@ } } - :if ([ :len [ /file/find recursive where path=$PackagePath type="package" ] ] = 0) do={ + :if ([ :len [ /file/find where type="package" name~("^" . $PackagePath) ] ] = 0) do={ $LogPrint info $ScriptName ("No packages available, downloading default set."); :foreach Arch in={ "arm"; "mipsbe" } do={ :foreach Package in={ "routeros"; "wireless" } do={ diff --git a/capsman-download-packages.template.rsc b/capsman-download-packages.template.rsc index ebbba70..f95212a 100644 --- a/capsman-download-packages.template.rsc +++ b/capsman-download-packages.template.rsc @@ -4,7 +4,7 @@ # Michael Gisbers # https://rsc.eworm.de/COPYING.md # -# requires RouterOS, version=7.18 +# requires RouterOS, version=7.15 # # download and cleanup packages for CAP installation from CAPsMAN # https://rsc.eworm.de/doc/capsman-download-packages.md @@ -56,8 +56,8 @@ "). Please place your packages!"); } - :foreach Package in=[ /file/find recursive where path=$PackagePath \ - type="package" package-version!=$InstalledVersion ] do={ + :foreach Package in=[ /file/find where type="package" \ + package-version!=$InstalledVersion name~("^" . $PackagePath) ] do={ :local File [ /file/get $Package ]; :if ($File->"package-architecture" = "mips") do={ :set ($File->"package-architecture") "mipsbe"; @@ -69,7 +69,7 @@ } } - :if ([ :len [ /file/find recursive where path=$PackagePath type="package" ] ] = 0) do={ + :if ([ :len [ /file/find where type="package" name~("^" . $PackagePath) ] ] = 0) do={ $LogPrint info $ScriptName ("No packages available, downloading default set."); # NOT /interface/wifi/ # :foreach Arch in={ "arm"; "mipsbe" } do={ diff --git a/capsman-download-packages.wifi.rsc b/capsman-download-packages.wifi.rsc index 7de0431..03fd9e7 100644 --- a/capsman-download-packages.wifi.rsc +++ b/capsman-download-packages.wifi.rsc @@ -4,7 +4,7 @@ # Michael Gisbers # https://rsc.eworm.de/COPYING.md # -# requires RouterOS, version=7.18 +# requires RouterOS, version=7.15 # # download and cleanup packages for CAP installation from CAPsMAN # https://rsc.eworm.de/doc/capsman-download-packages.md @@ -54,8 +54,8 @@ "). Please place your packages!"); } - :foreach Package in=[ /file/find recursive where path=$PackagePath \ - type="package" package-version!=$InstalledVersion ] do={ + :foreach Package in=[ /file/find where type="package" \ + package-version!=$InstalledVersion name~("^" . $PackagePath) ] do={ :local File [ /file/get $Package ]; :if ($File->"package-architecture" = "mips") do={ :set ($File->"package-architecture") "mipsbe"; @@ -67,7 +67,7 @@ } } - :if ([ :len [ /file/find recursive where path=$PackagePath type="package" ] ] = 0) do={ + :if ([ :len [ /file/find where type="package" name~("^" . $PackagePath) ] ] = 0) do={ $LogPrint info $ScriptName ("No packages available, downloading default set."); :foreach Arch in={ "arm"; "arm64" } do={ :local Packages { "arm"={ "routeros"; "wifi-qcom"; "wifi-qcom-ac" }; diff --git a/doc/capsman-download-packages.md b/doc/capsman-download-packages.md index 4daad49..5722227 100644 --- a/doc/capsman-download-packages.md +++ b/doc/capsman-download-packages.md @@ -4,7 +4,7 @@ Download packages for CAP upgrade from CAPsMAN [![GitHub stars](https://img.shields.io/github/stars/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=red)](https://github.com/eworm-de/routeros-scripts/stargazers) [![GitHub forks](https://img.shields.io/github/forks/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=green)](https://github.com/eworm-de/routeros-scripts/network) [![GitHub watchers](https://img.shields.io/github/watchers/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=blue)](https://github.com/eworm-de/routeros-scripts/watchers) -[![required RouterOS version](https://img.shields.io/badge/RouterOS-7.18-yellow?style=flat)](https://mikrotik.com/download/changelogs/) +[![required RouterOS version](https://img.shields.io/badge/RouterOS-7.15-yellow?style=flat)](https://mikrotik.com/download/changelogs/) [![Telegram group @routeros_scripts](https://img.shields.io/badge/Telegram-%40routeros__scripts-%2326A5E4?logo=telegram&style=flat)](https://t.me/routeros_scripts) [![donate with PayPal](https://img.shields.io/badge/Like_it%3F-Donate!-orange?logo=githubsponsors&logoColor=orange&style=flat)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J) From e2d3f0f073f1cd923892f4ac9af0d20dfb5902ff Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 11 Jun 2025 12:26:49 +0200 Subject: [PATCH 284/291] fw-addr-lists: delay on possible scripting subsystem crash This happens in :convert when a list is way too large. Let's use $LogPrintOnce here. If the scripting subsystem really crashes the message will be purged from $LogPrintOnceMessages anyway (as all global variables are lost). --- fw-addr-lists.rsc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fw-addr-lists.rsc b/fw-addr-lists.rsc index efd37db..0c45f7e 100644 --- a/fw-addr-lists.rsc +++ b/fw-addr-lists.rsc @@ -48,6 +48,12 @@ } $WaitFullyConnected; + :if ([ :len [ /log/find where topics=({"script"; "warning"}) \ + message=("\$LogPrintOnce: The message is already in log, scripting subsystem may have crashed before!") ] ] > 0) do={ + $LogPrintOnce warning $ScriptName ("Scripting subsystem may have crashed, possibly caused by us. Delaying!"); + :delay 5m; + } + :local ListComment ("managed by " . $ScriptName); :foreach FwListName,FwList in=$FwAddrLists do={ From de2a90d8413b832d3bb01337ef14d1866d23d981 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 11 Jun 2025 15:51:16 +0200 Subject: [PATCH 285/291] doc/fw-addr-lists: add a warning on possible subsystem crash --- doc/fw-addr-lists.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/fw-addr-lists.md b/doc/fw-addr-lists.md index d09383b..46b80c2 100644 --- a/doc/fw-addr-lists.md +++ b/doc/fw-addr-lists.md @@ -32,7 +32,10 @@ certificate is checked. > âš ī¸ **Warning**: The script does not limit the size of a list, but keep in > mind that huge lists can exhaust your device's resources (RAM and CPU), -> and may take a long time to process. +> and may take a long time to process. +> Even crashes for the complete scripting (and CLI) subsystem are possible. +> This should be logged accordingly with warnings when global functions are +> reloaded from scheduler. Requirements and installation ----------------------------- From 95f8af6234ab56c9a831d0f37f338d7b8b3e0cbe Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 20 Jun 2025 23:47:47 +0200 Subject: [PATCH 286/291] packages-update: convert to time before comparing... ... to avoid: packages-update: Script 'packages-update' exited with error: Script Error: cannot compare if truth value is more than or equal to ip address --- packages-update.rsc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages-update.rsc b/packages-update.rsc index 43f6749..d3140f2 100644 --- a/packages-update.rsc +++ b/packages-update.rsc @@ -41,7 +41,8 @@ /system/reboot; } - :local Interval [ $IfThenElse ($PackagesUpdateDeferReboot >= 1d) $PackagesUpdateDeferReboot 1d ]; + :local Interval [ $IfThenElse ([ :totime $PackagesUpdateDeferReboot ] >= 1d) \ + $PackagesUpdateDeferReboot 1d ]; :local StartTime [ :tostr [ :totime (10800 + [ $GetRandomNumber 7200 ]) ] ]; /system/scheduler/add name="_RebootForUpdate" start-time=$StartTime interval=$Interval \ on-event=("/system/scheduler/remove \"_RebootForUpdate\"; " . \ @@ -158,7 +159,7 @@ :error true; } } else={ - :if ($PackagesUpdateDeferReboot = true || $PackagesUpdateDeferReboot >= 1d) do={ + :if ($PackagesUpdateDeferReboot = true || [ :totime $PackagesUpdateDeferReboot ] >= 1d) do={ $Schedule $ScriptName; :set ExitOK true; :error true; From 64158498504635d98adac896f480d71d9bf8a2a9 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Sat, 21 Jun 2025 23:09:24 +0200 Subject: [PATCH 287/291] global-functions: $WaitForFile: (mostly) revert changes This (mostly) reverts commits 0e00a228d67d77fadc80eee2df04c2cec25b8db8 and e08bb2192dfd22b25652553f28304818a3602331. This is required for RouterOS 7.20beta4. That fixed recursive find for files, and (again, or still?) suffers timing (and thus racing) issues getting file properties. This breaks RouterOS 7.20beta2 again, so that specific version is not supported. Just update... --- global-functions.rsc | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index 50426b6..fd89f0f 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -1771,14 +1771,26 @@ :global MAX; :set FileName [ $CleanFilePath $FileName ]; - :local Delay ([ $MAX [ $EitherOr $WaitTime 2s ] 100ms ] / 10); + :local Delay ([ $MAX [ $EitherOr $WaitTime 2s ] 100ms ] / 9); :do { - :retry { + :retry { + :if ([ :len [ /file/find where name=$FileName ] ] = 0) do={ + :error false; + } + } delay=$Delay max=10; + } on-error={ + :return false; + } + + :while ([ :len [ /file/find where name=$FileName ] ] > 0) do={ + :do { /file/get $FileName; :return true; - } delay=$Delay max=10; - } on-error={ } + } on-error={ } + :delay $Delay; + :set Delay ($Delay * 3 / 2); + } :return false; } From 1307b8587e57deaf95146820b7f32bb9a713892d Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Sun, 22 Jun 2025 00:15:17 +0200 Subject: [PATCH 288/291] global-functions: $FileGet: mitigate race with file properties RouterOS is suffering a race condition, where a file exists, but its properties are not (yet) available. This is handled in $WaitForFile. This passes an interval of zero to $WaitForFile, as does not wait for the file to exist, but wants to avoid the race only. --- global-functions.rsc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/global-functions.rsc b/global-functions.rsc index fd89f0f..829cbf2 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -559,6 +559,12 @@ :set FileGet do={ :local FileName [ :tostr $1 ]; + :global WaitForFile; + + :if ([ $WaitForFile $FileName 0s ] = false) do={ + :return false; + } + :local FileVal false; :do { :set FileVal [ /file/get $FileName ]; From d46574b4fe5ea3f72ce804bd5fb38a5408f9cd94 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 25 Jun 2025 10:30:26 +0200 Subject: [PATCH 289/291] netwatch-dns: retry doh server... ... for more resilience on bad connectivity or saturated link. --- netwatch-dns.rsc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/netwatch-dns.rsc b/netwatch-dns.rsc index 4fa076a..2df26b0 100644 --- a/netwatch-dns.rsc +++ b/netwatch-dns.rsc @@ -119,11 +119,13 @@ :local Data false; :onerror Err { - :set Data ([ /tool/fetch check-certificate=yes-without-crl output=user \ - http-header-field=({ "accept: application/dns-message" }) \ - url=(($DohServer->"doh-url") . "?dns=" . [ :convert to=base64 ([ :rndstr length=2 ] . \ - "\01\00" . "\00\01" . "\00\00" . "\00\00" . "\00\00" . "\09doh-check\05eworm\02de\00" . \ - "\00\10" . "\00\01") ]) as-value ]->"data"); + :retry { + :set Data ([ /tool/fetch check-certificate=yes-without-crl output=user \ + http-header-field=({ "accept: application/dns-message" }) \ + url=(($DohServer->"doh-url") . "?dns=" . [ :convert to=base64 ([ :rndstr length=2 ] . \ + "\01\00" . "\00\01" . "\00\00" . "\00\00" . "\00\00" . "\09doh-check\05eworm\02de\00" . \ + "\00\10" . "\00\01") ]) as-value ]->"data"); + } delay=1s max=3; } do={ $LogPrint warning $ScriptName ("Request to DoH server " . ($DohServer->"doh-url") . \ " failed: " . $Err); From b068f86995c63278c91f9e92831f075fab5af2f1 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 25 Jun 2025 10:47:12 +0200 Subject: [PATCH 290/291] netwatch-dns: fix indention --- netwatch-dns.rsc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netwatch-dns.rsc b/netwatch-dns.rsc index 2df26b0..9e2f9bc 100644 --- a/netwatch-dns.rsc +++ b/netwatch-dns.rsc @@ -125,7 +125,7 @@ url=(($DohServer->"doh-url") . "?dns=" . [ :convert to=base64 ([ :rndstr length=2 ] . \ "\01\00" . "\00\01" . "\00\00" . "\00\00" . "\00\00" . "\09doh-check\05eworm\02de\00" . \ "\00\10" . "\00\01") ]) as-value ]->"data"); - } delay=1s max=3; + } delay=1s max=3; } do={ $LogPrint warning $ScriptName ("Request to DoH server " . ($DohServer->"doh-url") . \ " failed: " . $Err); From 89175e511fc965721fc19d88819c0fef13e383dc Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 7 Jul 2025 18:38:21 +0200 Subject: [PATCH 291/291] accesslist-duplicates: print without paging --- accesslist-duplicates.capsman.rsc | 2 +- accesslist-duplicates.local.rsc | 2 +- accesslist-duplicates.template.rsc | 6 +++--- accesslist-duplicates.wifi.rsc | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/accesslist-duplicates.capsman.rsc b/accesslist-duplicates.capsman.rsc index 5e6cf0a..1da0366 100644 --- a/accesslist-duplicates.capsman.rsc +++ b/accesslist-duplicates.capsman.rsc @@ -22,7 +22,7 @@ :foreach AccList in=[ /caps-man/access-list/find where mac-address!="00:00:00:00:00:00" ] do={ :local Mac [ /caps-man/access-list/get $AccList mac-address ]; :if ($Seen->$Mac = 1) do={ - /caps-man/access-list/print where mac-address=$Mac; + /caps-man/access-list/print without-paging where mac-address=$Mac; :local Remove [ :tonum [ /terminal/ask prompt="\nNumeric id to remove, any key to skip!" ] ]; :if ([ :typeof $Remove ] = "num") do={ diff --git a/accesslist-duplicates.local.rsc b/accesslist-duplicates.local.rsc index a6b4f41..03a9724 100644 --- a/accesslist-duplicates.local.rsc +++ b/accesslist-duplicates.local.rsc @@ -22,7 +22,7 @@ :foreach AccList in=[ /interface/wireless/access-list/find where mac-address!="00:00:00:00:00:00" ] do={ :local Mac [ /interface/wireless/access-list/get $AccList mac-address ]; :if ($Seen->$Mac = 1) do={ - /interface/wireless/access-list/print where mac-address=$Mac; + /interface/wireless/access-list/print without-paging where mac-address=$Mac; :local Remove [ :tonum [ /terminal/ask prompt="\nNumeric id to remove, any key to skip!" ] ]; :if ([ :typeof $Remove ] = "num") do={ diff --git a/accesslist-duplicates.template.rsc b/accesslist-duplicates.template.rsc index e51198d..bf23147 100644 --- a/accesslist-duplicates.template.rsc +++ b/accesslist-duplicates.template.rsc @@ -27,9 +27,9 @@ :local Mac [ /interface/wifi/access-list/get $AccList mac-address ]; :local Mac [ /interface/wireless/access-list/get $AccList mac-address ]; :if ($Seen->$Mac = 1) do={ - /caps-man/access-list/print where mac-address=$Mac; - /interface/wifi/access-list/print where mac-address=$Mac; - /interface/wireless/access-list/print where mac-address=$Mac; + /caps-man/access-list/print without-paging where mac-address=$Mac; + /interface/wifi/access-list/print without-paging where mac-address=$Mac; + /interface/wireless/access-list/print without-paging where mac-address=$Mac; :local Remove [ :tonum [ /terminal/ask prompt="\nNumeric id to remove, any key to skip!" ] ]; :if ([ :typeof $Remove ] = "num") do={ diff --git a/accesslist-duplicates.wifi.rsc b/accesslist-duplicates.wifi.rsc index cadacb6..528a73c 100644 --- a/accesslist-duplicates.wifi.rsc +++ b/accesslist-duplicates.wifi.rsc @@ -22,7 +22,7 @@ :foreach AccList in=[ /interface/wifi/access-list/find where mac-address!="00:00:00:00:00:00" ] do={ :local Mac [ /interface/wifi/access-list/get $AccList mac-address ]; :if ($Seen->$Mac = 1) do={ - /interface/wifi/access-list/print where mac-address=$Mac; + /interface/wifi/access-list/print without-paging where mac-address=$Mac; :local Remove [ :tonum [ /terminal/ask prompt="\nNumeric id to remove, any key to skip!" ] ]; :if ([ :typeof $Remove ] = "num") do={