From e6542ba8ccaf939d06162e622575db321f6e81cf Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 14:54:32 +0100 Subject: [PATCH 01/51] accesslist-duplicates: drop unused variable $ExitOK --- accesslist-duplicates.capsman.rsc | 3 +-- accesslist-duplicates.local.rsc | 3 +-- accesslist-duplicates.template.rsc | 3 +-- accesslist-duplicates.wifi.rsc | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/accesslist-duplicates.capsman.rsc b/accesslist-duplicates.capsman.rsc index c7784f3b..d9017472 100644 --- a/accesslist-duplicates.capsman.rsc +++ b/accesslist-duplicates.capsman.rsc @@ -10,7 +10,6 @@ # # !! Do not edit this file, it is generated from template! -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -33,5 +32,5 @@ :set ($Seen->$Mac) 1; } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } diff --git a/accesslist-duplicates.local.rsc b/accesslist-duplicates.local.rsc index 0eee485b..614b4da6 100644 --- a/accesslist-duplicates.local.rsc +++ b/accesslist-duplicates.local.rsc @@ -10,7 +10,6 @@ # # !! Do not edit this file, it is generated from template! -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -33,5 +32,5 @@ :set ($Seen->$Mac) 1; } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } diff --git a/accesslist-duplicates.template.rsc b/accesslist-duplicates.template.rsc index e780a475..dad9fc63 100644 --- a/accesslist-duplicates.template.rsc +++ b/accesslist-duplicates.template.rsc @@ -11,7 +11,6 @@ # !! This is just a template to generate the real script! # !! Pattern '%TEMPL%' is replaced, paths are filtered. -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -42,5 +41,5 @@ :set ($Seen->$Mac) 1; } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } diff --git a/accesslist-duplicates.wifi.rsc b/accesslist-duplicates.wifi.rsc index c0a8b4f9..c935420f 100644 --- a/accesslist-duplicates.wifi.rsc +++ b/accesslist-duplicates.wifi.rsc @@ -10,7 +10,6 @@ # # !! Do not edit this file, it is generated from template! -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -33,5 +32,5 @@ :set ($Seen->$Mac) 1; } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From f1333087d2d27899e9cccc693cb8b75ecb115068 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 14:55:19 +0100 Subject: [PATCH 02/51] mode-button: drop unused variable $ExitOK --- mode-button.rsc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mode-button.rsc b/mode-button.rsc index 81bdc05a..b5c89c7a 100644 --- a/mode-button.rsc +++ b/mode-button.rsc @@ -9,7 +9,6 @@ # act on multiple mode and reset button presses # https://rsc.eworm.de/doc/mode-button.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -92,5 +91,5 @@ /system/scheduler/set $Scheduler start-time=[ /system/clock/get time ]; } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From 73f65c82bdee6365e4e4e03072925e054e696fdb Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Sat, 7 Jun 2025 22:38:55 +0200 Subject: [PATCH 03/51] INITIAL-COMMANDS: drop the compatibility workaround... ... and make it depend in RouterOS 7.19 and its builtin certificates. --- INITIAL-COMMANDS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/INITIAL-COMMANDS.md b/INITIAL-COMMANDS.md index c823826b..e033b576 100644 --- a/INITIAL-COMMANDS.md +++ b/INITIAL-COMMANDS.md @@ -4,7 +4,7 @@ Initial commands [![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.17-yellow?style=flat)](https://mikrotik.com/download/changelogs/) +[![required RouterOS version](https://img.shields.io/badge/RouterOS-7.19-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) @@ -26,7 +26,7 @@ Run the complete base installation: :if (!((($CertSettings->"builtin-trust-anchors") = "trusted" || \ ($CertSettings->"builtin-trust-store") ~ "fetch" || \ ($CertSettings->"builtin-trust-store") = "all") && \ - [[ :parse (":return [ :len [ /certificate/builtin/find where common-name=\"" . $CertCommonName . "\" ] ]") ]] > 0)) do={ + [ :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; From 996b8e2c5da51c17672fd91cc4c4e70276ca9c5b Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Sat, 7 Jun 2025 22:41:29 +0200 Subject: [PATCH 04/51] global-functions: $CertificateAvailable: drop the compatibility workaround... ... and make it depend in RouterOS 7.19 and its builtin certificates. --- README.md | 2 +- global-functions.rsc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6f7c03c8..5257b979 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ RouterOS Scripts [![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.17-yellow?style=flat)](https://mikrotik.com/download/changelogs/) +[![required RouterOS version](https://img.shields.io/badge/RouterOS-7.19-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) diff --git a/global-functions.rsc b/global-functions.rsc index fc60ff63..17c7bf49 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -4,7 +4,7 @@ # Michael Gisbers # https://rsc.eworm.de/COPYING.md # -# requires RouterOS, version=7.17 +# requires RouterOS, version=7.19 # requires device-mode, fetch, scheduler # # global functions @@ -131,7 +131,7 @@ :if ((($CertSettings->"builtin-trust-anchors") = "trusted" || \ ($CertSettings->"builtin-trust-store") ~ $UseFor || \ ($CertSettings->"builtin-trust-store") = "all") && \ - [[ :parse (":return [ :len [ /certificate/builtin/find where common-name=\"" . $CommonName . "\" ] ]") ]] > 0) do={ + [ :len [ /certificate/builtin/find where common-name=$CommonName ] ] > 0) do={ :return true; } From 4857b6ba8b98d11dace6103826192d9716da9474 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 12 Jan 2026 09:22:46 +0100 Subject: [PATCH 05/51] check-certificates: drop the compatibility workaround... ... and make it depend in RouterOS 7.19 and its builtin certificates. --- check-certificates.rsc | 7 ++----- doc/check-certificates.md | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/check-certificates.rsc b/check-certificates.rsc index 9aa11c10..f54d3259 100644 --- a/check-certificates.rsc +++ b/check-certificates.rsc @@ -3,7 +3,7 @@ # Copyright (c) 2013-2026 Christian Hesse # https://rsc.eworm.de/COPYING.md # -# requires RouterOS, version=7.17 +# requires RouterOS, version=7.19 # requires device-mode, fetch # # check for certificate validity @@ -117,10 +117,7 @@ :local Return ""; :for I from=0 to=5 do={ :set Return ($Return . [ $ParseKeyValueStore ($CertVal->"issuer") ]->"CN"); - :local CertSettings [ /certificate/settings/get ]; - :if (([ :len ($CertSettings->"builtin-trust-anchors") ] > 0 || \ - [ :len ($CertSettings->"builtin-trust-store") ] > 0) && \ - [[ :parse (":return [ :len [ /certificate/builtin/find where skid=\"" . ($CertVal->"akid") . "\" ] ]") ]] > 0) do={ + :if ([ :len [ /certificate/builtin/find where skid=($CertVal->"akid") ] ] > 0) do={ :return $Return; } :do { diff --git a/doc/check-certificates.md b/doc/check-certificates.md index 456d4b1f..1e69af46 100644 --- a/doc/check-certificates.md +++ b/doc/check-certificates.md @@ -4,7 +4,7 @@ Renew certificates and notify on expiration [![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.17-yellow?style=flat)](https://mikrotik.com/download/changelogs/) +[![required RouterOS version](https://img.shields.io/badge/RouterOS-7.19-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 46702c4ff61db57f3d061d811c5b85fe998b3669 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 13 Jan 2026 21:02:02 +0100 Subject: [PATCH 06/51] log-forward: use comparison for ids This was introduced with RouterOS 7.22beta1. Initializing $LogForwardLast with boolean value looks odd, but this is reuqired to match the very first message. --- doc/log-forward.md | 2 +- log-forward.rsc | 24 +++++++++++------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/doc/log-forward.md b/doc/log-forward.md index 25991fba..f51d61a5 100644 --- a/doc/log-forward.md +++ b/doc/log-forward.md @@ -4,7 +4,7 @@ Forward log messages via notification [![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.17-yellow?style=flat)](https://mikrotik.com/download/changelogs/) +[![required RouterOS version](https://img.shields.io/badge/RouterOS-7.22beta1-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) diff --git a/log-forward.rsc b/log-forward.rsc index ed2226f0..7a40a7a9 100644 --- a/log-forward.rsc +++ b/log-forward.rsc @@ -3,7 +3,7 @@ # Copyright (c) 2020-2026 Christian Hesse # https://rsc.eworm.de/COPYING.md # -# requires RouterOS, version=7.17 +# requires RouterOS, version=7.22beta1 # # forward log messages via notification # https://rsc.eworm.de/doc/log-forward.md @@ -24,7 +24,6 @@ :global LogForwardRateLimit; :global EitherOr; - :global HexToNum; :global IfThenElse; :global LogForwardFilterLogForwarding; :global LogPrint; @@ -38,6 +37,10 @@ :error false; } + :if ([ :typeof $LogForwardLast ] = "nothing") do={ + :set LogForwardLast false; + } + :if ([ :typeof $LogForwardRateLimit ] = "nothing") do={ :set LogForwardRateLimit 0; } @@ -51,7 +54,6 @@ :local Count 0; :local Duplicates false; - :local Last [ $IfThenElse ([ :len $LogForwardLast ] > 0) [ $HexToNum $LogForwardLast ] -1 ]; :local Messages ""; :local Warning false; :local MessageVal; @@ -63,19 +65,16 @@ :set LogForwardIncludeMessage [ $EitherOr $LogForwardIncludeMessage [] ]; :local LogAll [ /log/find ]; - :local MaxId ($LogAll->([ :len $LogAll ] - 1)); - :local MaxNum [ $HexToNum $MaxId ]; + :local Max ($LogAll->([ :len $LogAll ] - 1)); :local LogForwardFilterLogForwardingCached [ $EitherOr [ $LogForwardFilterLogForwarding ] ("\$^") ]; - :foreach Message in=[ /log/find where (!(message="") and \ - !(message~$LogForwardFilterLogForwardingCached) and \ - !(topics~$LogForwardFilter) and !(message~$LogForwardFilterMessage)) or \ - topics~$LogForwardInclude or message~$LogForwardIncludeMessage ] do={ + :foreach Message in=[ /log/find where .id>$LogForwardLast and .id<=$Max and \ + ((!(message="") and !(message~$LogForwardFilterLogForwardingCached) and \ + !(topics~$LogForwardFilter) and !(message~$LogForwardFilterMessage)) or \ + topics~$LogForwardInclude or message~$LogForwardIncludeMessage) ] do={ :set MessageVal [ /log/get $Message ]; :local Bullet "information"; - :local Current [ $HexToNum ($MessageVal->".id") ]; - :if ($Last < $Current && $Current <= $MaxNum) do={ :local DupCount ($MessageDups->($MessageVal->"message")); :if ($MessageVal->"topics" ~ "(warning)") do={ :set Warning true; @@ -93,7 +92,6 @@ } :set ($MessageDups->($MessageVal->"message")) ($DupCount + 1); :set Count ($Count + 1); - } } :if ($Count > 0) do={ @@ -111,7 +109,7 @@ :set LogForwardRateLimit [ $MAX 0 ($LogForwardRateLimit - 1) ]; } - :set LogForwardLast $MaxId; + :set LogForwardLast $Max; } do={ :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } From 75a0124e82dc6f33b801ba4a5a6a6649525f1732 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 13 Jan 2026 21:26:11 +0100 Subject: [PATCH 07/51] log-forward: fix indention --- log-forward.rsc | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/log-forward.rsc b/log-forward.rsc index 7a40a7a9..e89fdc18 100644 --- a/log-forward.rsc +++ b/log-forward.rsc @@ -75,23 +75,23 @@ :set MessageVal [ /log/get $Message ]; :local Bullet "information"; - :local DupCount ($MessageDups->($MessageVal->"message")); - :if ($MessageVal->"topics" ~ "(warning)") do={ - :set Warning true; - :set Bullet "large-orange-circle"; - } - :if ($MessageVal->"topics" ~ "(emergency|alert|critical|error)") do={ - :set Warning true; - :set Bullet "large-red-circle"; - } - :if ($DupCount < 3) do={ - :set Messages ($Messages . "\n" . [ $SymbolForNotification $Bullet ] . \ - $MessageVal->"time" . " " . [ :tostr ($MessageVal->"topics") ] . " " . $MessageVal->"message"); - } else={ - :set Duplicates true; - } - :set ($MessageDups->($MessageVal->"message")) ($DupCount + 1); - :set Count ($Count + 1); + :local DupCount ($MessageDups->($MessageVal->"message")); + :if ($MessageVal->"topics" ~ "(warning)") do={ + :set Warning true; + :set Bullet "large-orange-circle"; + } + :if ($MessageVal->"topics" ~ "(emergency|alert|critical|error)") do={ + :set Warning true; + :set Bullet "large-red-circle"; + } + :if ($DupCount < 3) do={ + :set Messages ($Messages . "\n" . [ $SymbolForNotification $Bullet ] . \ + $MessageVal->"time" . " " . [ :tostr ($MessageVal->"topics") ] . " " . $MessageVal->"message"); + } else={ + :set Duplicates true; + } + :set ($MessageDups->($MessageVal->"message")) ($DupCount + 1); + :set Count ($Count + 1); } :if ($Count > 0) do={ From 54a9ebd270bc82fca6d126e2e1283227f1a8e7fe Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 13 Jan 2026 21:33:26 +0100 Subject: [PATCH 08/51] global-functions: drop $HexToNum --- global-functions.rsc | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index 17c7bf49..2aad406e 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -47,7 +47,6 @@ :global GetRandom20CharHex; :global GetRandomNumber; :global Grep; -:global HexToNum; :global HumanReadableNum; :global IfThenElse; :global IsDefaultRouteReachable; @@ -717,19 +716,6 @@ :return []; } -# convert from hex (string) to num -:set HexToNum do={ - :local Input [ :tostr $1 ]; - - :global HexToNum; - - :if ([ :pick $Input 0 ] = "*") do={ - :return [ $HexToNum [ :pick $Input 1 [ :len $Input ] ] ]; - } - - :return [ :tonum ("0x" . $Input) ]; -} - # return human readable number :set HumanReadableNum do={ :local Input [ :tonum $1 ]; From f34feb2b1b3f3712b9b49debeed44805130ada77 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 15 Jan 2026 09:25:48 +0100 Subject: [PATCH 09/51] netwatch-dns: early exit with :exit --- netwatch-dns.rsc | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/netwatch-dns.rsc b/netwatch-dns.rsc index 06a15f95..9a40ecc0 100644 --- a/netwatch-dns.rsc +++ b/netwatch-dns.rsc @@ -3,13 +3,12 @@ # Copyright (c) 2022-2026 Christian Hesse # https://rsc.eworm.de/COPYING.md # -# requires RouterOS, version=7.17 +# requires RouterOS, version=7.22beta1 # requires device-mode, fetch # # monitor and manage dns/doh with netwatch # https://rsc.eworm.de/doc/netwatch-dns.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -26,15 +25,13 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :local SettleTime (5m30s - [ /system/resource/get uptime ]); :if ($SettleTime > 0s) do={ $LogPrint info $ScriptName ("System just booted, giving netwatch " . $SettleTime . " to settle."); - :set ExitOK true; - :error true; + :exit; } :local DnsServers ({}); @@ -89,8 +86,7 @@ :if ($DohCurrent = $HostInfo->"doh-url" && [ $IsDNSResolving ] = true) do={ $LogPrint debug $ScriptName ("Current DoH server is still up and resolving: " . $DohCurrent); - :set ExitOK true; - :error true; + :exit; } :set ($DohServers->[ :len $DohServers ]) $HostInfo; @@ -135,8 +131,7 @@ } /ip/dns/cache/flush; $LogPrint info $ScriptName ("Setting DoH server: " . ($DohServer->"doh-url")); - :set ExitOK true; - :error true; + :exit; } else={ $LogPrint warning $ScriptName ("Received unexpected response from DoH server: " . \ ($DohServer->"doh-url")); @@ -144,5 +139,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From f00174aab254074b2fb026d58f4dc76ae4ce7abe Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 15 Jan 2026 09:34:40 +0100 Subject: [PATCH 10/51] telegram-chat: early exit with :exit --- telegram-chat.rsc | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/telegram-chat.rsc b/telegram-chat.rsc index 53ab6c66..bac3a969 100644 --- a/telegram-chat.rsc +++ b/telegram-chat.rsc @@ -3,13 +3,12 @@ # Copyright (c) 2023-2026 Christian Hesse # https://rsc.eworm.de/COPYING.md # -# requires RouterOS, version=7.17 +# requires RouterOS, version=7.22beta1 # requires device-mode, fetch # # use Telegram to chat with your Router and send commands # https://rsc.eworm.de/doc/telegram-chat.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -48,8 +47,7 @@ :global WaitFullyConnected; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } $WaitFullyConnected; @@ -63,8 +61,7 @@ :if ([ $CertificateAvailable "Go Daddy Root Certificate Authority - G2" "fetch" ] = false) do={ $LogPrint warning $ScriptName ("Downloading required certificate failed."); - :set ExitOK true; - :error false; + :exit; } $RandomDelay $TelegramRandomDelay; @@ -89,8 +86,7 @@ :if ($Data = false) do={ $LogPrint warning $ScriptName ("Failed getting updates."); - :set ExitOK true; - :error false; + :exit; } :local JSON [ :deserialize from=json value=$Data ]; @@ -146,8 +142,7 @@ :local File ("tmpfs/telegram-chat/" . [ $GetRandom20CharAlNum 6 ]); :if ([ $MkDir "tmpfs/telegram-chat" ] = false) do={ $LogPrint error $ScriptName ("Failed creating directory!"); - :set ExitOK true; - :error false; + :exit; } $LogPrint info $ScriptName ("Running command from update " . $UpdateID . ": " . $Command); :execute script=(":do {\n" . $Command . "\n} on-error={ /file/add name=\"" . $File . ".failed\" };" . \ @@ -197,5 +192,5 @@ :set TelegramChatOffset ([ :pick $TelegramChatOffset 1 3 ], \ [ $IfThenElse ($UpdateID >= $TelegramChatOffset->2) ($UpdateID + 1) ($TelegramChatOffset->2) ]); } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From 9e8abb8e1484c5ef46dbc3e5d985fd3bf0862744 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 14:57:52 +0100 Subject: [PATCH 11/51] backup-cloud: early exit with :exit --- backup-cloud.rsc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/backup-cloud.rsc b/backup-cloud.rsc index e5f25d34..397ba9e9 100644 --- a/backup-cloud.rsc +++ b/backup-cloud.rsc @@ -9,7 +9,6 @@ # upload backup to MikroTik cloud # https://rsc.eworm.de/doc/backup-cloud.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -36,15 +35,13 @@ :if ([ $ScriptLock $ScriptName ] = false) do={ :set PackagesUpdateBackupFailure true; - :set ExitOK true; - :error false; + :exit; } :if ([ :len [ /system/scheduler/find where name="running-from-backup-partition" ] ] > 0) do={ $LogPrint warning $ScriptName ("Running from backup partition, refusing to act."); :set PackagesUpdateBackupFailure true; - :set ExitOK true; - :error false; + :exit; } $WaitFullyConnected; @@ -55,8 +52,7 @@ :if ([ $MkDir ("tmpfs/backup-cloud") ] = false) do={ $LogPrint error $ScriptName ("Failed creating directory!"); - :set ExitOK true; - :error false; + :exit; } :local I 5; @@ -100,5 +96,5 @@ } $RmDir "tmpfs/backup-cloud"; } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From d4da1512cf2d6d59841c7d6fec7a49520e729958 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 14:59:06 +0100 Subject: [PATCH 12/51] backup-email: early exit with :exit --- backup-email.rsc | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/backup-email.rsc b/backup-email.rsc index c12942a2..440a36fd 100644 --- a/backup-email.rsc +++ b/backup-email.rsc @@ -9,7 +9,6 @@ # create and email backup and config file # https://rsc.eworm.de/doc/backup-email.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -41,28 +40,24 @@ :if ([ :typeof $SendEMail2 ] = "nothing") do={ $LogPrint error $ScriptName ("The module for sending notifications via e-mail is not installed."); - :set ExitOK true; - :error false; + :exit; } :if ($BackupSendBinary != true && \ $BackupSendExport != true) do={ $LogPrint error $ScriptName ("Configured to send neither backup nor config export."); - :set ExitOK true; - :error false; + :exit; } :if ([ $ScriptLock $ScriptName ] = false) do={ :set PackagesUpdateBackupFailure true; - :set ExitOK true; - :error false; + :exit; } :if ([ :len [ /system/scheduler/find where name="running-from-backup-partition" ] ] > 0) do={ $LogPrint warning $ScriptName ("Running from backup partition, refusing to act."); :set PackagesUpdateBackupFailure true; - :set ExitOK true; - :error false; + :exit; } $WaitFullyConnected; @@ -82,8 +77,7 @@ :if ([ $MkDir $DirName ] = false) do={ $LogPrint error $ScriptName ("Failed creating directory!"); - :set ExitOK true; - :error false; + :exit; } # binary backup @@ -139,5 +133,5 @@ } # do not remove the files here, as the mail is still queued! } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From 12cff010b9cb56480949fc11fb0f1b36f0658b1b Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:00:40 +0100 Subject: [PATCH 13/51] backup-partition: early exit with :exit --- backup-partition.rsc | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/backup-partition.rsc b/backup-partition.rsc index a9f11a59..a4952564 100644 --- a/backup-partition.rsc +++ b/backup-partition.rsc @@ -10,7 +10,6 @@ # save configuration to fallback partition # https://rsc.eworm.de/doc/backup-partition.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -45,22 +44,19 @@ :if ([ $ScriptLock $ScriptName ] = false) do={ :set PackagesUpdateBackupFailure true; - :set ExitOK true; - :error false; + :exit; } :if ([ :len [ /system/scheduler/find where name="running-from-backup-partition" ] ] > 0) do={ $LogPrint warning $ScriptName ("Running from backup partition, refusing to act."); :set PackagesUpdateBackupFailure true; - :set ExitOK true; - :error false; + :exit; } :if ([ :len [ /partitions/find ] ] < 2) do={ $LogPrint error $ScriptName ("Device does not have a fallback partition."); :set PackagesUpdateBackupFailure true; - :set ExitOK true; - :error false; + :exit; } :local ActiveRunning [ /partitions/find where active running ]; @@ -68,8 +64,7 @@ :if ([ :len $ActiveRunning ] < 1) do={ $LogPrint error $ScriptName ("Device is not running from active partition."); :set PackagesUpdateBackupFailure true; - :set ExitOK true; - :error false; + :exit; } :local FallbackToName [ /partitions/get $ActiveRunning fallback-to ]; @@ -78,8 +73,7 @@ :if ([ :len $FallbackTo ] < 1) do={ $LogPrint error $ScriptName ("There is no inactive partition named '" . $FallbackToName . "'."); :set PackagesUpdateBackupFailure true; - :set ExitOK true; - :error false; + :exit; } :if ([ /partitions/get $ActiveRunning version ] != [ /partitions/get $FallbackTo version]) do={ @@ -88,8 +82,7 @@ :if (([ /terminal/inkey timeout=60 ] % 32) = 25) do={ :if ([ $CopyTo $ScriptName $FallbackTo $FallbackToName ] = false) do={ :set PackagesUpdateBackupFailure true; - :set ExitOK true; - :error false; + :exit; } } } else={ @@ -101,8 +94,7 @@ ($NumInstalled & $BitMask) != ($NumLatest & $BitMask)) do={ :if ([ $CopyTo $ScriptName $FallbackTo $FallbackToName ] = false) do={ :set PackagesUpdateBackupFailure true; - :set ExitOK true; - :error false; + :exit; } } } @@ -120,9 +112,8 @@ $LogPrint error $ScriptName ("Failed saving configuration to partition '" . \ $FallbackToName . "': " . $Err); :set PackagesUpdateBackupFailure true; - :set ExitOK true; - :error false; + :exit; } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From 49a7ce9f69cc1f35c2248603842691e3e82a2fa8 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:01:49 +0100 Subject: [PATCH 14/51] backup-upload: early exit with :exit --- backup-upload.rsc | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/backup-upload.rsc b/backup-upload.rsc index cae67bfa..ea58bcb0 100644 --- a/backup-upload.rsc +++ b/backup-upload.rsc @@ -10,7 +10,6 @@ # create and upload backup and config file # https://rsc.eworm.de/doc/backup-upload.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -47,21 +46,18 @@ :if ($BackupSendBinary != true && \ $BackupSendExport != true) do={ $LogPrint error $ScriptName ("Configured to send neither backup nor config export."); - :set ExitOK true; - :error false; + :exit; } :if ([ $ScriptLock $ScriptName ] = false) do={ :set PackagesUpdateBackupFailure true; - :set ExitOK true; - :error false; + :exit; } :if ([ :len [ /system/scheduler/find where name="running-from-backup-partition" ] ] > 0) do={ $LogPrint warning $ScriptName ("Running from backup partition, refusing to act."); :set PackagesUpdateBackupFailure true; - :set ExitOK true; - :error false; + :exit; } $WaitFullyConnected; @@ -81,8 +77,7 @@ :if ([ $MkDir $DirName ] = false) do={ $LogPrint error $ScriptName ("Failed creating directory!"); - :set ExitOK true; - :error false; + :exit; } # binary backup @@ -174,5 +169,5 @@ } $RmDir $DirName; } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From 8b6379ad4e75bb586305609c0721465671780e3f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:02:56 +0100 Subject: [PATCH 15/51] capsman-download-packages: early exit with :exit --- capsman-download-packages.capsman.rsc | 12 ++++-------- capsman-download-packages.template.rsc | 12 ++++-------- capsman-download-packages.wifi.rsc | 12 ++++-------- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/capsman-download-packages.capsman.rsc b/capsman-download-packages.capsman.rsc index 838f41b9..867ee63e 100644 --- a/capsman-download-packages.capsman.rsc +++ b/capsman-download-packages.capsman.rsc @@ -11,7 +11,6 @@ # # !! Do not edit this file, it is generated from template! -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -28,8 +27,7 @@ :global WaitFullyConnected; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } $WaitFullyConnected; @@ -39,16 +37,14 @@ :if ([ :len $PackagePath ] = 0) do={ $LogPrint warning $ScriptName ("The CAPsMAN package path is not defined, can not download packages."); - :set ExitOK true; - :error false; + :exit; } :if ([ $FileGet $PackagePath ] = false) do={ :if ([ $MkDir $PackagePath ] = false) do={ $LogPrint warning $ScriptName ("Creating directory at CAPsMAN package path (" . \ $PackagePath . ") failed!"); - :set ExitOK true; - :error false; + :exit; } $LogPrint info $ScriptName ("Created directory at CAPsMAN package path (" . $PackagePath . \ "). Please place your packages!"); @@ -89,5 +85,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } diff --git a/capsman-download-packages.template.rsc b/capsman-download-packages.template.rsc index 1d31eb5a..5b086518 100644 --- a/capsman-download-packages.template.rsc +++ b/capsman-download-packages.template.rsc @@ -12,7 +12,6 @@ # !! This is just a template to generate the real script! # !! Pattern '%TEMPL%' is replaced, paths are filtered. -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -29,8 +28,7 @@ :global WaitFullyConnected; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } $WaitFullyConnected; @@ -41,16 +39,14 @@ :if ([ :len $PackagePath ] = 0) do={ $LogPrint warning $ScriptName ("The CAPsMAN package path is not defined, can not download packages."); - :set ExitOK true; - :error false; + :exit; } :if ([ $FileGet $PackagePath ] = false) do={ :if ([ $MkDir $PackagePath ] = false) do={ $LogPrint warning $ScriptName ("Creating directory at CAPsMAN package path (" . \ $PackagePath . ") failed!"); - :set ExitOK true; - :error false; + :exit; } $LogPrint info $ScriptName ("Created directory at CAPsMAN package path (" . $PackagePath . \ "). Please place your packages!"); @@ -100,5 +96,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } diff --git a/capsman-download-packages.wifi.rsc b/capsman-download-packages.wifi.rsc index 242bb0c8..cf460ed1 100644 --- a/capsman-download-packages.wifi.rsc +++ b/capsman-download-packages.wifi.rsc @@ -11,7 +11,6 @@ # # !! Do not edit this file, it is generated from template! -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -28,8 +27,7 @@ :global WaitFullyConnected; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } $WaitFullyConnected; @@ -39,16 +37,14 @@ :if ([ :len $PackagePath ] = 0) do={ $LogPrint warning $ScriptName ("The CAPsMAN package path is not defined, can not download packages."); - :set ExitOK true; - :error false; + :exit; } :if ([ $FileGet $PackagePath ] = false) do={ :if ([ $MkDir $PackagePath ] = false) do={ $LogPrint warning $ScriptName ("Creating directory at CAPsMAN package path (" . \ $PackagePath . ") failed!"); - :set ExitOK true; - :error false; + :exit; } $LogPrint info $ScriptName ("Created directory at CAPsMAN package path (" . $PackagePath . \ "). Please place your packages!"); @@ -91,5 +87,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From b1cd1410cb1c7366f0e27a871838b8f037dbf09a Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:03:44 +0100 Subject: [PATCH 16/51] capsman-rolling-upgrade: early exit with :exit --- capsman-rolling-upgrade.capsman.rsc | 6 ++---- capsman-rolling-upgrade.template.rsc | 6 ++---- capsman-rolling-upgrade.wifi.rsc | 6 ++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/capsman-rolling-upgrade.capsman.rsc b/capsman-rolling-upgrade.capsman.rsc index bb1b17b1..dc5b09c5 100644 --- a/capsman-rolling-upgrade.capsman.rsc +++ b/capsman-rolling-upgrade.capsman.rsc @@ -12,7 +12,6 @@ # # !! Do not edit this file, it is generated from template! -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -23,8 +22,7 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :local InstalledVersion [ /system/package/update/get installed-version ]; @@ -46,5 +44,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } diff --git a/capsman-rolling-upgrade.template.rsc b/capsman-rolling-upgrade.template.rsc index 919765a0..e0186644 100644 --- a/capsman-rolling-upgrade.template.rsc +++ b/capsman-rolling-upgrade.template.rsc @@ -13,7 +13,6 @@ # !! This is just a template to generate the real script! # !! Pattern '%TEMPL%' is replaced, paths are filtered. -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -24,8 +23,7 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :local InstalledVersion [ /system/package/update/get installed-version ]; @@ -54,5 +52,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } diff --git a/capsman-rolling-upgrade.wifi.rsc b/capsman-rolling-upgrade.wifi.rsc index b0c9d034..b55a92fa 100644 --- a/capsman-rolling-upgrade.wifi.rsc +++ b/capsman-rolling-upgrade.wifi.rsc @@ -12,7 +12,6 @@ # # !! Do not edit this file, it is generated from template! -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -23,8 +22,7 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :local InstalledVersion [ /system/package/update/get installed-version ]; @@ -47,5 +45,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From 1a05b85bd74a7027ec463f0602bddb9dc8a7ded2 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:04:38 +0100 Subject: [PATCH 17/51] certificate-renew-issued: early exit with :exit --- certificate-renew-issued.rsc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/certificate-renew-issued.rsc b/certificate-renew-issued.rsc index fc8bff32..ef0410e9 100644 --- a/certificate-renew-issued.rsc +++ b/certificate-renew-issued.rsc @@ -8,7 +8,6 @@ # renew locally issued certificates # https://rsc.eworm.de/doc/certificate-renew-issued.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -22,8 +21,7 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :foreach Cert in=[ /certificate/find where issued expires-after<3w ] do={ @@ -48,5 +46,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From 860a439dc3f1ade9efab5787d42be8a80872e9f6 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:05:17 +0100 Subject: [PATCH 18/51] check-certificates: early exit with :exit --- check-certificates.rsc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/check-certificates.rsc b/check-certificates.rsc index f54d3259..fd9d31a7 100644 --- a/check-certificates.rsc +++ b/check-certificates.rsc @@ -9,7 +9,6 @@ # check for certificate validity # https://rsc.eworm.de/doc/check-certificates.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -149,8 +148,7 @@ } :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } $WaitFullyConnected; @@ -249,5 +247,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From 46cbbc0e153875c95e084c005e7e69007b0b4070 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:06:07 +0100 Subject: [PATCH 19/51] check-health: early exit with :exit --- check-health.rsc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/check-health.rsc b/check-health.rsc index eea31701..76a2d715 100644 --- a/check-health.rsc +++ b/check-health.rsc @@ -8,7 +8,6 @@ # check for RouterOS health state # https://rsc.eworm.de/doc/check-health.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -37,8 +36,7 @@ } :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :local Resource [ /system/resource/get ]; @@ -77,8 +75,7 @@ :local Plugins [ /system/script/find where name~"^check-health\\.d/." ]; :if ([ :len $Plugins ] = 0) do={ $LogPrint debug $ScriptName ("No plugins installed."); - :set ExitOK true; - :error true; + :exit; } :global CheckHealthPlugins ({}); @@ -106,5 +103,5 @@ :set CheckHealthPlugins; } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From 11e9631074294edbf02a37473efc40bee2a25964 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:06:43 +0100 Subject: [PATCH 20/51] check-lte-firmware-upgrade: early exit with :exit --- check-lte-firmware-upgrade.rsc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/check-lte-firmware-upgrade.rsc b/check-lte-firmware-upgrade.rsc index da268e4c..b986084f 100644 --- a/check-lte-firmware-upgrade.rsc +++ b/check-lte-firmware-upgrade.rsc @@ -8,7 +8,6 @@ # check for LTE firmware upgrade, send notification # https://rsc.eworm.de/doc/check-lte-firmware-upgrade.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -20,8 +19,7 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :if ([ :typeof $SentLteFirmwareUpgradeNotification ] != "array") do={ @@ -103,5 +101,5 @@ $CheckInterface $ScriptName $Interface; } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From a1f2b00a8b88ea6f532fcc992b5ba2225bfb81a0 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:07:40 +0100 Subject: [PATCH 21/51] check-perpetual-license: early exit with :exit --- check-perpetual-license.rsc | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/check-perpetual-license.rsc b/check-perpetual-license.rsc index 4326a2f5..9d1b7562 100644 --- a/check-perpetual-license.rsc +++ b/check-perpetual-license.rsc @@ -8,7 +8,6 @@ # check perpetual license on CHR # https://rsc.eworm.de/doc/check-perpetual-license.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -25,8 +24,7 @@ :global WaitFullyConnected; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } $WaitFullyConnected; @@ -34,8 +32,7 @@ :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; + :exit; } :if ([ :len ($License->"next-renewal-at") ] = 0 && ($License->"limited-upgrades") = true) do={ @@ -47,8 +44,7 @@ ", can no longer update RouterOS on " . $Identity . "...") }); :set SentCertificateNotification "expired"; } - :set ExitOK true; - :error true; + :exit; } :if ([ :totime ($License->"deadline-at") ] - 3w < [ :timestamp ]) do={ @@ -60,8 +56,7 @@ ($License->"deadline-at") . " on " . $Identity . "...") }); :set SentCertificateNotification "warning"; } - :set ExitOK true; - :error true; + :exit; } :if ([ :typeof $SentCertificateNotification ] = "str" && \ @@ -74,5 +69,5 @@ :set SentCertificateNotification; } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From ae2251052fccc8a1301a9c70b22cbeb7e5e6d47d Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:09:25 +0100 Subject: [PATCH 22/51] check-routeros-update: early exit with :exit --- check-routeros-update.rsc | 45 +++++++++++++-------------------------- 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/check-routeros-update.rsc b/check-routeros-update.rsc index 98edb366..23427ee6 100644 --- a/check-routeros-update.rsc +++ b/check-routeros-update.rsc @@ -9,7 +9,6 @@ # check for RouterOS update, send notification and/or install # https://rsc.eworm.de/doc/check-routeros-update.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -47,14 +46,12 @@ } :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :if ([ :len [ /system/scheduler/find where name="running-from-backup-partition" ] ] > 0) do={ $LogPrint warning $ScriptName ("Running from backup partition, refusing to act."); - :set ExitOK true; - :error false; + :exit; } $WaitFullyConnected; @@ -65,8 +62,7 @@ /system/scheduler/remove "_RebootForUpdate"; } else={ $LogPrint info $ScriptName ("A reboot for update is already scheduled."); - :set ExitOK true; - :error false; + :exit; } } @@ -78,14 +74,12 @@ :if ([ $ScriptFromTerminal $ScriptName ] = true) do={ $LogPrint info $ScriptName ("System is already up to date."); } - :set ExitOK true; - :error true; + :exit; } :if ([ :len ($Update->"latest-version") ] = 0) do={ $LogPrint info $ScriptName ("Received an empty version string from server."); - :set ExitOK true; - :error false; + :exit; } :local NumInstalled [ $VersionToNum ($Update->"installed-version") ]; @@ -97,8 +91,7 @@ :if ($NumLatest < [ $VersionToNum "7.0" ]) do={ $LogPrint warning $ScriptName ("The version '" . ($Update->"latest-version") . "' is not a valid version."); - :set ExitOK true; - :error false; + :exit; } :if ($NumInstalled < $NumLatest) do={ @@ -110,8 +103,7 @@ message=("Installing ALL versions automatically, including " . $Update->"latest-version" . \ "... Updating on " . $Identity . "..."); link=$Link; silent=true }); $DoUpdate $ScriptName; - :set ExitOK true; - :error true; + :exit; } :if ($SafeUpdatePatch = true && $NumInstalledFeature = $NumLatestFeature) do={ @@ -121,8 +113,7 @@ message=("Version " . $Update->"latest-version" . " is a patch update for " . $Update->"channel" . \ ", updating on " . $Identity . "..."); link=$Link; silent=true }); $DoUpdate $ScriptName; - :set ExitOK true; - :error true; + :exit; } :if ($SafeUpdateNeighbor = true) do={ @@ -137,8 +128,7 @@ message=("Seen a neighbor (" . $Neighbor . ") running version " . $Update->"latest-version" . \ " from " . $Update->"channel" . ", updating on " . $Identity . "..."); link=$Link; silent=true }); $DoUpdate $ScriptName; - :set ExitOK true; - :error true; + :exit; } } @@ -159,8 +149,7 @@ message=("Version " . $Update->"latest-version" . " is considered safe for " . $Update->"channel" . \ ", updating on " . $Identity . "..."); link=$Link; silent=true }); $DoUpdate $ScriptName; - :set ExitOK true; - :error true; + :exit; } } @@ -170,16 +159,14 @@ :if (([ /terminal/inkey timeout=60 ] % 32) = 25) do={ /system/package/update/set channel=stable; $LogPrint info $ScriptName ("Switched to channel 'stable', please re-run!"); - :set ExitOK true; - :error true; + :exit; } } :put ("Do you want to install RouterOS version " . $Update->"latest-version" . "? [y/N]"); :if (([ /terminal/inkey timeout=60 ] % 32) = 25) do={ $DoUpdate $ScriptName; - :set ExitOK true; - :error true; + :exit; } else={ :put "Canceled..."; } @@ -188,8 +175,7 @@ :if ($SentRouterosUpdateNotification = $Update->"latest-version") do={ $LogPrint info $ScriptName ("Already sent the RouterOS update notification for version " . \ $Update->"latest-version" . "."); - :set ExitOK true; - :error true; + :exit; } $SendNotification2 ({ origin=$ScriptName; \ @@ -204,8 +190,7 @@ :if ($SentRouterosUpdateNotification = $Update->"latest-version") do={ $LogPrint info $ScriptName ("Already sent the RouterOS downgrade notification for version " . \ $Update->"latest-version" . "."); - :set ExitOK true; - :error true; + :exit; } $SendNotification2 ({ origin=$ScriptName; \ @@ -218,5 +203,5 @@ :set SentRouterosUpdateNotification ($Update->"latest-version"); } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From d7bbeb6a03a282db018d28aae8ebb57570a7dbc3 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:10:22 +0100 Subject: [PATCH 23/51] collect-wireless-mac: early exit with :exit --- 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, 8 insertions(+), 16 deletions(-) diff --git a/collect-wireless-mac.capsman.rsc b/collect-wireless-mac.capsman.rsc index 0ef08b0d..6bf1222d 100644 --- a/collect-wireless-mac.capsman.rsc +++ b/collect-wireless-mac.capsman.rsc @@ -11,7 +11,6 @@ # # !! Do not edit this file, it is generated from template! -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -30,8 +29,7 @@ :global SymbolForNotification; :if ([ $ScriptLock $ScriptName 10 ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :if ([ :len [ /caps-man/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={ @@ -96,5 +94,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } diff --git a/collect-wireless-mac.local.rsc b/collect-wireless-mac.local.rsc index 263ef164..c7a92609 100644 --- a/collect-wireless-mac.local.rsc +++ b/collect-wireless-mac.local.rsc @@ -11,7 +11,6 @@ # # !! Do not edit this file, it is generated from template! -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -30,8 +29,7 @@ :global SymbolForNotification; :if ([ $ScriptLock $ScriptName 10 ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :if ([ :len [ /interface/wireless/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={ @@ -97,5 +95,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } diff --git a/collect-wireless-mac.template.rsc b/collect-wireless-mac.template.rsc index 37933250..9424bcac 100644 --- a/collect-wireless-mac.template.rsc +++ b/collect-wireless-mac.template.rsc @@ -12,7 +12,6 @@ # !! This is just a template to generate the real script! # !! Pattern '%TEMPL%' is replaced, paths are filtered. -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -31,8 +30,7 @@ :global SymbolForNotification; :if ([ $ScriptLock $ScriptName 10 ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :if ([ :len [ /caps-man/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={ @@ -114,5 +112,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } diff --git a/collect-wireless-mac.wifi.rsc b/collect-wireless-mac.wifi.rsc index 342351b1..0698587c 100644 --- a/collect-wireless-mac.wifi.rsc +++ b/collect-wireless-mac.wifi.rsc @@ -11,7 +11,6 @@ # # !! Do not edit this file, it is generated from template! -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -30,8 +29,7 @@ :global SymbolForNotification; :if ([ $ScriptLock $ScriptName 10 ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :if ([ :len [ /interface/wifi/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={ @@ -96,5 +94,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From 709acb964c469c545ba3ce0175ac032ab9fe74f6 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:11:17 +0100 Subject: [PATCH 24/51] daily-psk: early exit with :exit --- daily-psk.capsman.rsc | 6 ++---- daily-psk.local.rsc | 6 ++---- daily-psk.template.rsc | 6 ++---- daily-psk.wifi.rsc | 6 ++---- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/daily-psk.capsman.rsc b/daily-psk.capsman.rsc index 284d4a11..fd0176ed 100644 --- a/daily-psk.capsman.rsc +++ b/daily-psk.capsman.rsc @@ -11,7 +11,6 @@ # # !! Do not edit this file, it is generated from template! -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -32,8 +31,7 @@ :global WaitFullyConnected; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } $WaitFullyConnected; @@ -92,5 +90,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } diff --git a/daily-psk.local.rsc b/daily-psk.local.rsc index 7a07898c..6d7f26f4 100644 --- a/daily-psk.local.rsc +++ b/daily-psk.local.rsc @@ -11,7 +11,6 @@ # # !! Do not edit this file, it is generated from template! -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -32,8 +31,7 @@ :global WaitFullyConnected; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } $WaitFullyConnected; @@ -91,5 +89,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } diff --git a/daily-psk.template.rsc b/daily-psk.template.rsc index 5105b63b..4b04f84f 100644 --- a/daily-psk.template.rsc +++ b/daily-psk.template.rsc @@ -12,7 +12,6 @@ # !! This is just a template to generate the real script! # !! Pattern '%TEMPL%' is replaced, paths are filtered. -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -33,8 +32,7 @@ :global WaitFullyConnected; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } $WaitFullyConnected; @@ -107,5 +105,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } diff --git a/daily-psk.wifi.rsc b/daily-psk.wifi.rsc index a2df10e4..2e4f4d7f 100644 --- a/daily-psk.wifi.rsc +++ b/daily-psk.wifi.rsc @@ -11,7 +11,6 @@ # # !! Do not edit this file, it is generated from template! -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -32,8 +31,7 @@ :global WaitFullyConnected; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } $WaitFullyConnected; @@ -92,5 +90,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From 88a40824756832605962f44b2e65c316ab62c52c Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:11:57 +0100 Subject: [PATCH 25/51] dhcp-lease-comment: early exit with :exit --- 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, 8 insertions(+), 16 deletions(-) diff --git a/dhcp-lease-comment.capsman.rsc b/dhcp-lease-comment.capsman.rsc index 5427a889..bde5e21b 100644 --- a/dhcp-lease-comment.capsman.rsc +++ b/dhcp-lease-comment.capsman.rsc @@ -11,7 +11,6 @@ # # !! Do not edit this file, it is generated from template! -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -22,8 +21,7 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={ @@ -39,5 +37,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } diff --git a/dhcp-lease-comment.local.rsc b/dhcp-lease-comment.local.rsc index e25305e3..69b450b6 100644 --- a/dhcp-lease-comment.local.rsc +++ b/dhcp-lease-comment.local.rsc @@ -11,7 +11,6 @@ # # !! Do not edit this file, it is generated from template! -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -22,8 +21,7 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={ @@ -39,5 +37,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } diff --git a/dhcp-lease-comment.template.rsc b/dhcp-lease-comment.template.rsc index 3fcf6e01..3d03d04e 100644 --- a/dhcp-lease-comment.template.rsc +++ b/dhcp-lease-comment.template.rsc @@ -12,7 +12,6 @@ # !! This is just a template to generate the real script! # !! Pattern '%TEMPL%' is replaced, paths are filtered. -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -23,8 +22,7 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={ @@ -44,5 +42,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } diff --git a/dhcp-lease-comment.wifi.rsc b/dhcp-lease-comment.wifi.rsc index 6b752bab..d2c70dd7 100644 --- a/dhcp-lease-comment.wifi.rsc +++ b/dhcp-lease-comment.wifi.rsc @@ -11,7 +11,6 @@ # # !! Do not edit this file, it is generated from template! -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -22,8 +21,7 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={ @@ -39,5 +37,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From c255b5bfa896820bd00a86cd724da1af1368da25 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:12:42 +0100 Subject: [PATCH 26/51] dhcp-to-dns: early exit with :exit --- dhcp-to-dns.rsc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dhcp-to-dns.rsc b/dhcp-to-dns.rsc index 8c6ee30b..efb65c4c 100644 --- a/dhcp-to-dns.rsc +++ b/dhcp-to-dns.rsc @@ -9,7 +9,6 @@ # check DHCP leases and add/remove/update DNS entries # https://rsc.eworm.de/doc/dhcp-to-dns.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -28,8 +27,7 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName 10 ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :local Ttl 5m; @@ -126,5 +124,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From e3bfd3be012418099d7747d5d3dd42fc91abb535 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:13:25 +0100 Subject: [PATCH 27/51] firmware-upgrade-reboot: early exit with :exit --- firmware-upgrade-reboot.rsc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/firmware-upgrade-reboot.rsc b/firmware-upgrade-reboot.rsc index 93a264fc..0e32cf02 100644 --- a/firmware-upgrade-reboot.rsc +++ b/firmware-upgrade-reboot.rsc @@ -8,7 +8,6 @@ # install firmware upgrade, and reboot # https://rsc.eworm.de/doc/firmware-upgrade-reboot.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -20,21 +19,18 @@ :global VersionToNum; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :local RouterBoard [ /system/routerboard/get ]; :if ($RouterBoard->"current-firmware" = $RouterBoard->"upgrade-firmware") do={ $LogPrint info $ScriptName ("Current and upgrade firmware match with version " . \ $RouterBoard->"current-firmware" . "."); - :set ExitOK true; - :error true; + :exit; } :if ([ $VersionToNum ($RouterBoard->"current-firmware") ] > [ $VersionToNum ($RouterBoard->"upgrade-firmware") ]) do={ $LogPrint info $ScriptName ("Different firmware version is available, but it is a downgrade. Ignoring."); - :set ExitOK true; - :error true; + :exit; } :if ([ /system/routerboard/settings/get auto-upgrade ] = false) do={ @@ -56,5 +52,5 @@ $LogPrint info $ScriptName ("Firmware upgrade successful, rebooting."); /system/reboot; } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From 74f2e1af7c1315474cacfe7498df41bc7a2de625 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:14:54 +0100 Subject: [PATCH 28/51] fw-addr-lists: early exit with :exit --- fw-addr-lists.rsc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fw-addr-lists.rsc b/fw-addr-lists.rsc index a9b3daf4..492ad535 100644 --- a/fw-addr-lists.rsc +++ b/fw-addr-lists.rsc @@ -8,7 +8,6 @@ # download, import and update firewall address-lists # https://rsc.eworm.de/doc/fw-addr-lists.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -46,8 +45,7 @@ } :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } $WaitFullyConnected; @@ -232,5 +230,5 @@ " - removed: " . [ $HumanReadableNum $CntRemove 1000 ]); } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From 51077a8d0aceb1dac9b7a25c96d2959654dd5c88 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:14:06 +0100 Subject: [PATCH 29/51] gps-track: early exit with :exit --- gps-track.rsc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gps-track.rsc b/gps-track.rsc index dae7d521..c0cd0ba4 100644 --- a/gps-track.rsc +++ b/gps-track.rsc @@ -9,7 +9,6 @@ # track gps data by sending json data to http server # https://rsc.eworm.de/doc/gps-track.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -25,8 +24,7 @@ :global WaitFullyConnected; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } $WaitFullyConnected; @@ -49,5 +47,5 @@ $LogPrint debug $ScriptName ("GPS data not valid."); } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From b76cd6df023ffa00c8175a3be598e0da7e8bec78 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:16:29 +0100 Subject: [PATCH 30/51] hotspot-to-wpa: early exit with :exit --- hotspot-to-wpa.capsman.rsc | 12 ++++-------- hotspot-to-wpa.template.rsc | 12 ++++-------- hotspot-to-wpa.wifi.rsc | 12 ++++-------- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/hotspot-to-wpa.capsman.rsc b/hotspot-to-wpa.capsman.rsc index 0751f8e5..2a79147d 100644 --- a/hotspot-to-wpa.capsman.rsc +++ b/hotspot-to-wpa.capsman.rsc @@ -11,7 +11,6 @@ # # !! Do not edit this file, it is generated from template! -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -27,14 +26,12 @@ :local UserName $username; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :if ([ :typeof $MacAddress ] = "nothing" || [ :typeof $UserName ] = "nothing") do={ $LogPrint error $ScriptName ("This script is supposed to run from hotspot on login."); - :set ExitOK true; - :error false; + :exit; } :local Date [ /system/clock/get date ]; @@ -61,8 +58,7 @@ :if ($Template->"action" = "reject") do={ $LogPrint info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'."); - :set ExitOK true; - :error true; + :exit; } # allow login page to load @@ -101,5 +97,5 @@ :delay 2s; /caps-man/access-list/set $Entry action=accept; } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } diff --git a/hotspot-to-wpa.template.rsc b/hotspot-to-wpa.template.rsc index ba044a09..c7b94378 100644 --- a/hotspot-to-wpa.template.rsc +++ b/hotspot-to-wpa.template.rsc @@ -12,7 +12,6 @@ # !! This is just a template to generate the real script! # !! Pattern '%TEMPL%' is replaced, paths are filtered. -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -28,14 +27,12 @@ :local UserName $username; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :if ([ :typeof $MacAddress ] = "nothing" || [ :typeof $UserName ] = "nothing") do={ $LogPrint error $ScriptName ("This script is supposed to run from hotspot on login."); - :set ExitOK true; - :error false; + :exit; } :local Date [ /system/clock/get date ]; @@ -68,8 +65,7 @@ :if ($Template->"action" = "reject") do={ $LogPrint info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'."); - :set ExitOK true; - :error true; + :exit; } # allow login page to load @@ -121,5 +117,5 @@ /caps-man/access-list/set $Entry action=accept; /interface/wifi/access-list/set $Entry action=accept; } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } diff --git a/hotspot-to-wpa.wifi.rsc b/hotspot-to-wpa.wifi.rsc index 569d7827..3a99bd1b 100644 --- a/hotspot-to-wpa.wifi.rsc +++ b/hotspot-to-wpa.wifi.rsc @@ -11,7 +11,6 @@ # # !! Do not edit this file, it is generated from template! -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -27,14 +26,12 @@ :local UserName $username; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :if ([ :typeof $MacAddress ] = "nothing" || [ :typeof $UserName ] = "nothing") do={ $LogPrint error $ScriptName ("This script is supposed to run from hotspot on login."); - :set ExitOK true; - :error false; + :exit; } :local Date [ /system/clock/get date ]; @@ -61,8 +58,7 @@ :if ($Template->"action" = "reject") do={ $LogPrint info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'."); - :set ExitOK true; - :error true; + :exit; } # allow login page to load @@ -98,5 +94,5 @@ :delay 2s; /interface/wifi/access-list/set $Entry action=accept; } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From 9c628f5a7a66bb5e4b6599601f2b07c08afd5bd1 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:17:06 +0100 Subject: [PATCH 31/51] hotspot-to-wpa-cleanup: early exit with :exit --- hotspot-to-wpa-cleanup.capsman.rsc | 6 ++---- hotspot-to-wpa-cleanup.template.rsc | 6 ++---- hotspot-to-wpa-cleanup.wifi.rsc | 6 ++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/hotspot-to-wpa-cleanup.capsman.rsc b/hotspot-to-wpa-cleanup.capsman.rsc index 99ff0029..49a61a28 100644 --- a/hotspot-to-wpa-cleanup.capsman.rsc +++ b/hotspot-to-wpa-cleanup.capsman.rsc @@ -12,7 +12,6 @@ # # !! Do not edit this file, it is generated from template! -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -25,8 +24,7 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName 10 ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :local DHCPServers ({}); @@ -76,5 +74,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } diff --git a/hotspot-to-wpa-cleanup.template.rsc b/hotspot-to-wpa-cleanup.template.rsc index 113c1bb2..8bf782e4 100644 --- a/hotspot-to-wpa-cleanup.template.rsc +++ b/hotspot-to-wpa-cleanup.template.rsc @@ -13,7 +13,6 @@ # !! This is just a template to generate the real script! # !! Pattern '%TEMPL%' is replaced, paths are filtered. -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -26,8 +25,7 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName 10 ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :local DHCPServers ({}); @@ -83,5 +81,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } diff --git a/hotspot-to-wpa-cleanup.wifi.rsc b/hotspot-to-wpa-cleanup.wifi.rsc index 1a7ef364..404f4a4c 100644 --- a/hotspot-to-wpa-cleanup.wifi.rsc +++ b/hotspot-to-wpa-cleanup.wifi.rsc @@ -12,7 +12,6 @@ # # !! Do not edit this file, it is generated from template! -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -25,8 +24,7 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName 10 ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :local DHCPServers ({}); @@ -76,5 +74,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From c0f08d4799dafa82d647b6e287013f7cdd48850f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:17:52 +0100 Subject: [PATCH 32/51] ipsec-to-dns: early exit with :exit --- ipsec-to-dns.rsc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ipsec-to-dns.rsc b/ipsec-to-dns.rsc index 02391fe8..913a6e9d 100644 --- a/ipsec-to-dns.rsc +++ b/ipsec-to-dns.rsc @@ -9,7 +9,6 @@ # and add/remove/update DNS entries from IPSec mode-config # https://rsc.eworm.de/doc/ipsec-to-dns.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -28,8 +27,7 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :local Zone \ @@ -80,5 +78,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From 02d4adbe44c55dc4a97d0fe71d4ecbc591212787 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:18:44 +0100 Subject: [PATCH 33/51] ipv6-update: early exit with :exit --- ipv6-update.rsc | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/ipv6-update.rsc b/ipv6-update.rsc index a4da6516..35314121 100644 --- a/ipv6-update.rsc +++ b/ipv6-update.rsc @@ -8,7 +8,6 @@ # update firewall and dns settings on IPv6 prefix change # https://rsc.eworm.de/doc/ipv6-update.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -25,26 +24,22 @@ :local PdValid $"pd-valid"; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :if ([ :typeof $NaAddress ] = "str") do={ $LogPrint info $ScriptName ("An address (" . $NaAddress . ") was acquired, not a prefix. Ignoring."); - :set ExitOK true; - :error false; + :exit; } :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; + :exit; } :if ($PdValid != 1) do={ $LogPrint info $ScriptName ("The prefix " . $PdPrefix . " is no longer valid. Ignoring."); - :set ExitOK true; - :error false; + :exit; } :local Pool [ /ipv6/pool/get [ find where prefix=$PdPrefix ] name ]; @@ -103,5 +98,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From f77c0f4a370c416e1d2b4cb5bc790d273a693c99 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:19:58 +0100 Subject: [PATCH 34/51] lease-script: early exit with :exit --- lease-script.rsc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lease-script.rsc b/lease-script.rsc index 1b7935b8..021f478e 100644 --- a/lease-script.rsc +++ b/lease-script.rsc @@ -8,7 +8,6 @@ # run scripts on DHCP lease # https://rsc.eworm.de/doc/lease-script.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -26,22 +25,19 @@ [ :typeof $leaseServerName ] = "nothing" || \ [ :typeof $leaseBound ] = "nothing") do={ $LogPrint error $ScriptName ("This script is supposed to run from ip dhcp-server."); - :set ExitOK true; - :error false; + :exit; } $LogPrint debug $ScriptName ("DHCP Server " . $leaseServerName . " " . [ $IfThenElse ($leaseBound = 0) \ "de" "" ] . "assigned lease " . $leaseActIP . " to " . $leaseActMAC); :if ([ $ScriptLock $ScriptName 10 ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :if ([ :len [ /system/script/job/find where script=$ScriptName ] ] > 1) do={ $LogPrint debug $ScriptName ("More invocations are waiting, exiting early."); - :set ExitOK true; - :error true; + :exit; } :local RunOrder ({}); @@ -61,5 +57,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From 8329bded23dc789fe3d45e8039ecd687493843ba Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:20:53 +0100 Subject: [PATCH 35/51] log-forward: early exit with :exit --- log-forward.rsc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/log-forward.rsc b/log-forward.rsc index e89fdc18..6ad1d586 100644 --- a/log-forward.rsc +++ b/log-forward.rsc @@ -8,7 +8,6 @@ # forward log messages via notification # https://rsc.eworm.de/doc/log-forward.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -33,8 +32,7 @@ :global SymbolForNotification; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :if ([ :typeof $LogForwardLast ] = "nothing") do={ @@ -48,8 +46,7 @@ :if ($LogForwardRateLimit > 30) do={ :set LogForwardRateLimit ($LogForwardRateLimit - 1); $LogPrint info $ScriptName ("Rate limit in action, not forwarding logs, if any!"); - :set ExitOK true; - :error false; + :exit; } :local Count 0; @@ -111,5 +108,5 @@ :set LogForwardLast $Max; } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From eeb449e882cd446b0cfaf997b1b0136f54e5f589 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:21:27 +0100 Subject: [PATCH 36/51] netwatch-notify: early exit with :exit --- netwatch-notify.rsc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/netwatch-notify.rsc b/netwatch-notify.rsc index 46a10ee0..ad3a1aa7 100644 --- a/netwatch-notify.rsc +++ b/netwatch-notify.rsc @@ -8,7 +8,6 @@ # monitor netwatch and send notifications # https://rsc.eworm.de/doc/netwatch-notify.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -80,8 +79,7 @@ } :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :local ScriptFromTerminalCached [ $ScriptFromTerminal $ScriptName ]; @@ -225,5 +223,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From d2e6adf5299e0f329a3b6b0ff427dcfdd07680ca Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:22:02 +0100 Subject: [PATCH 37/51] ospf-to-leds: early exit with :exit --- ospf-to-leds.rsc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ospf-to-leds.rsc b/ospf-to-leds.rsc index 73a70c8b..9d1265b5 100644 --- a/ospf-to-leds.rsc +++ b/ospf-to-leds.rsc @@ -8,7 +8,6 @@ # visualize ospf instance state via leds # https://rsc.eworm.de/doc/ospf-to-leds.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -20,8 +19,7 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :foreach Instance in=[ /routing/ospf/instance/find where comment~"^ospf-to-leds," ] do={ @@ -45,5 +43,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From 25abe5797c48507886edc61446f0aa0f31f153ba Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:23:27 +0100 Subject: [PATCH 38/51] packages-update: early exit with :exit --- packages-update.rsc | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/packages-update.rsc b/packages-update.rsc index 960e07ca..6ac7ecf5 100644 --- a/packages-update.rsc +++ b/packages-update.rsc @@ -9,7 +9,6 @@ # download packages and reboot for installation # https://rsc.eworm.de/doc/packages-update.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -59,28 +58,24 @@ } :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :if ([ :len [ /system/scheduler/find where name="running-from-backup-partition" ] ] > 0) do={ $LogPrint warning $ScriptName ("Running from backup partition, refusing to act."); - :set ExitOK true; - :error false; + :exit; } :local Update [ /system/package/update/get ]; :if ([ :typeof ($Update->"latest-version") ] = "nothing") do={ $LogPrint warning $ScriptName ("Latest version is not known."); - :set ExitOK true; - :error false; + :exit; } :if ($Update->"installed-version" = $Update->"latest-version") do={ $LogPrint info $ScriptName ("Version " . $Update->"latest-version" . " is already installed."); - :set ExitOK true; - :error true; + :exit; } :local RunOrder ({}); @@ -111,13 +106,11 @@ $LogPrint info $ScriptName ("User requested to continue anyway."); } else={ $LogPrint info $ScriptName ("Canceled update..."); - :set ExitOK true; - :error false; + :exit; } } else={ $LogPrint warning $ScriptName ("Canceled non-interactive update."); - :set ExitOK true; - :error false; + :exit; } } } @@ -136,8 +129,7 @@ } } else={ $LogPrint warning $ScriptName ("Not installing downgrade automatically."); - :set ExitOK true; - :error false; + :exit; } } @@ -145,8 +137,7 @@ :local PkgName [ /system/package/get $Package name ]; :if ([ $DownloadPackage $PkgName ($Update->"latest-version") ] = false) do={ $LogPrint error $ScriptName ("Download for package " . $PkgName . " failed, update aborted."); - :set ExitOK true; - :error false; + :exit; } } @@ -160,14 +151,12 @@ :put "Do you want to (s)chedule reboot or (r)eboot now? [s/R]"; :if (([ /terminal/inkey timeout=60 ] % 32) = 19) do={ $Schedule $ScriptName; - :set ExitOK true; - :error true; + :exit; } } else={ :if ($PackagesUpdateDeferReboot = true || [ :totime $PackagesUpdateDeferReboot ] >= 1d) do={ $Schedule $ScriptName; - :set ExitOK true; - :error true; + :exit; } } @@ -175,5 +164,5 @@ :delay 1s; /system/reboot; } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From 07671470f434e7c3382076b8416aba93f79a0214 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:24:01 +0100 Subject: [PATCH 39/51] ppp-on-up: early exit with :exit --- ppp-on-up.rsc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ppp-on-up.rsc b/ppp-on-up.rsc index 231d3d2d..572686a3 100644 --- a/ppp-on-up.rsc +++ b/ppp-on-up.rsc @@ -8,7 +8,6 @@ # run scripts on ppp up # https://rsc.eworm.de/doc/ppp-on-up.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -21,8 +20,7 @@ :if ([ :typeof $Interface ] = "nothing") do={ $LogPrint error $ScriptName ("This script is supposed to run from ppp on-up script hook."); - :set ExitOK true; - :error false; + :exit; } :local IntName [ /interface/get $Interface name ]; @@ -40,5 +38,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From 878087d855e33435c17cdb2ed941a8b391db64c3 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:24:32 +0100 Subject: [PATCH 40/51] sms-action: early exit with :exit --- sms-action.rsc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sms-action.rsc b/sms-action.rsc index 9750e967..6a6470af 100644 --- a/sms-action.rsc +++ b/sms-action.rsc @@ -8,7 +8,6 @@ # run action on received SMS # https://rsc.eworm.de/doc/sms-action.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -24,8 +23,7 @@ :if ([ :typeof $Action ] = "nothing") do={ $LogPrint error $ScriptName ("This script is supposed to run from SMS hook with action=..."); - :set ExitOK true; - :error false; + :exit; } :local Code ($SmsAction->$Action); @@ -37,5 +35,5 @@ $LogPrint warning $ScriptName ("The code for action '" . $Action . "' failed syntax validation!"); } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From a14d2da314004ae44b6011968b8cfc3fe961cedc Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:25:19 +0100 Subject: [PATCH 41/51] sms-forward: early exit with :exit --- sms-forward.rsc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/sms-forward.rsc b/sms-forward.rsc index d4570ea1..934040f2 100644 --- a/sms-forward.rsc +++ b/sms-forward.rsc @@ -9,7 +9,6 @@ # forward SMS to e-mail # https://rsc.eworm.de/doc/sms-forward.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -29,14 +28,12 @@ :global WaitFullyConnected; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :if ([ /tool/sms/get receive-enabled ] = false) do={ $LogPrintOnce warning $ScriptName ("Receiving of SMS is not enabled."); - :set ExitOK true; - :error false; + :exit; } $WaitFullyConnected; @@ -45,8 +42,7 @@ :if ([ /interface/lte/get ($Settings->"port") running ] != true) do={ $LogPrint info $ScriptName ("The LTE interface is not in running state, skipping."); - :set ExitOK true; - :error true; + :exit; } # forward SMS in a loop @@ -107,5 +103,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From 9fe72867cbebb93308ce96a25c8b1e38a426c3d2 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:25:51 +0100 Subject: [PATCH 42/51] update-gre-address: early exit with :exit --- update-gre-address.rsc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/update-gre-address.rsc b/update-gre-address.rsc index 15cfc143..407a0b4b 100644 --- a/update-gre-address.rsc +++ b/update-gre-address.rsc @@ -9,7 +9,6 @@ # ipsec remote peer # https://rsc.eworm.de/doc/update-gre-address.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -21,8 +20,7 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } /interface/gre/set remote-address=0.0.0.0 disabled=yes [ find where !running !disabled ]; @@ -42,5 +40,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From 4dee3a9d6275dace5734e5dfa41d6f74f49256f3 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:26:36 +0100 Subject: [PATCH 43/51] update-tunnelbroker: early exit with :exit --- update-tunnelbroker.rsc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/update-tunnelbroker.rsc b/update-tunnelbroker.rsc index f9eaf247..2fa07606 100644 --- a/update-tunnelbroker.rsc +++ b/update-tunnelbroker.rsc @@ -11,7 +11,6 @@ # update local address of tunnelbroker interface # https://rsc.eworm.de/doc/update-tunnelbroker.md -:local ExitOK false; :onerror Err { :global GlobalConfigReady; :global GlobalFunctionsReady; :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ @@ -24,14 +23,12 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } :if ([ $CertificateAvailable "Starfield Root Certificate Authority - G2" "fetch" ] = false) do={ $LogPrint error $ScriptName ("Downloading required certificate failed."); - :set ExitOK true; - :error false; + :exit; } :foreach Interface in=[ /interface/6to4/find where comment~"^tunnelbroker" !disabled ] do={ @@ -54,8 +51,7 @@ :if (!($Data ~ "^(good|nochg) ")) do={ $LogPrint error $ScriptName ("Failed sending the local address to tunnelbroker or unexpected response!"); - :set ExitOK true; - :error false; + :exit; } :local PublicAddress [ :pick $Data ([ :find $Data " " ] + 1) [ :find $Data "\n" ] ]; @@ -70,5 +66,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitError; $ExitError false [ :jobname ] $Err; } From 104639264a5b253db67395db3812323bd5f5074c Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:29:59 +0100 Subject: [PATCH 44/51] global-functions: $ExitError: drop argument $ExitOK... ... as the is no longer required with early exit with :exit. --- accesslist-duplicates.capsman.rsc | 2 +- accesslist-duplicates.local.rsc | 2 +- accesslist-duplicates.template.rsc | 2 +- accesslist-duplicates.wifi.rsc | 2 +- backup-cloud.rsc | 2 +- backup-email.rsc | 2 +- backup-partition.rsc | 2 +- backup-upload.rsc | 2 +- capsman-download-packages.capsman.rsc | 2 +- capsman-download-packages.template.rsc | 2 +- capsman-download-packages.wifi.rsc | 2 +- capsman-rolling-upgrade.capsman.rsc | 2 +- capsman-rolling-upgrade.template.rsc | 2 +- capsman-rolling-upgrade.wifi.rsc | 2 +- certificate-renew-issued.rsc | 2 +- check-certificates.rsc | 2 +- check-health.rsc | 2 +- check-lte-firmware-upgrade.rsc | 2 +- check-perpetual-license.rsc | 2 +- check-routeros-update.rsc | 2 +- collect-wireless-mac.capsman.rsc | 2 +- collect-wireless-mac.local.rsc | 2 +- collect-wireless-mac.template.rsc | 2 +- collect-wireless-mac.wifi.rsc | 2 +- daily-psk.capsman.rsc | 2 +- daily-psk.local.rsc | 2 +- daily-psk.template.rsc | 2 +- daily-psk.wifi.rsc | 2 +- dhcp-lease-comment.capsman.rsc | 2 +- dhcp-lease-comment.local.rsc | 2 +- dhcp-lease-comment.template.rsc | 2 +- dhcp-lease-comment.wifi.rsc | 2 +- dhcp-to-dns.rsc | 2 +- firmware-upgrade-reboot.rsc | 2 +- fw-addr-lists.rsc | 2 +- global-functions.rsc | 9 ++++----- gps-track.rsc | 2 +- hotspot-to-wpa-cleanup.capsman.rsc | 2 +- hotspot-to-wpa-cleanup.template.rsc | 2 +- hotspot-to-wpa-cleanup.wifi.rsc | 2 +- hotspot-to-wpa.capsman.rsc | 2 +- hotspot-to-wpa.template.rsc | 2 +- hotspot-to-wpa.wifi.rsc | 2 +- ipsec-to-dns.rsc | 2 +- ipv6-update.rsc | 2 +- lease-script.rsc | 2 +- log-forward.rsc | 2 +- mod/bridge-port-to.rsc | 2 +- mod/bridge-port-vlan.rsc | 2 +- mod/inspectvar.rsc | 2 +- mod/ipcalc.rsc | 2 +- mod/notification-email.rsc | 4 ++-- mod/notification-gotify.rsc | 4 ++-- mod/notification-matrix.rsc | 4 ++-- mod/notification-ntfy.rsc | 4 ++-- mod/notification-telegram.rsc | 6 +++--- mod/scriptrunonce.rsc | 2 +- mod/ssh-keys-import.rsc | 4 ++-- mode-button.rsc | 4 ++-- netwatch-dns.rsc | 2 +- netwatch-notify.rsc | 2 +- ospf-to-leds.rsc | 2 +- packages-update.rsc | 2 +- ppp-on-up.rsc | 2 +- sms-action.rsc | 2 +- sms-forward.rsc | 2 +- telegram-chat.rsc | 2 +- update-gre-address.rsc | 2 +- update-tunnelbroker.rsc | 2 +- 69 files changed, 80 insertions(+), 81 deletions(-) diff --git a/accesslist-duplicates.capsman.rsc b/accesslist-duplicates.capsman.rsc index d9017472..9ea5c305 100644 --- a/accesslist-duplicates.capsman.rsc +++ b/accesslist-duplicates.capsman.rsc @@ -32,5 +32,5 @@ :set ($Seen->$Mac) 1; } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/accesslist-duplicates.local.rsc b/accesslist-duplicates.local.rsc index 614b4da6..0d62a19e 100644 --- a/accesslist-duplicates.local.rsc +++ b/accesslist-duplicates.local.rsc @@ -32,5 +32,5 @@ :set ($Seen->$Mac) 1; } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/accesslist-duplicates.template.rsc b/accesslist-duplicates.template.rsc index dad9fc63..49a0308e 100644 --- a/accesslist-duplicates.template.rsc +++ b/accesslist-duplicates.template.rsc @@ -41,5 +41,5 @@ :set ($Seen->$Mac) 1; } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/accesslist-duplicates.wifi.rsc b/accesslist-duplicates.wifi.rsc index c935420f..ca0630c9 100644 --- a/accesslist-duplicates.wifi.rsc +++ b/accesslist-duplicates.wifi.rsc @@ -32,5 +32,5 @@ :set ($Seen->$Mac) 1; } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/backup-cloud.rsc b/backup-cloud.rsc index 397ba9e9..b6aeb6fc 100644 --- a/backup-cloud.rsc +++ b/backup-cloud.rsc @@ -96,5 +96,5 @@ } $RmDir "tmpfs/backup-cloud"; } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/backup-email.rsc b/backup-email.rsc index 440a36fd..f26313ec 100644 --- a/backup-email.rsc +++ b/backup-email.rsc @@ -133,5 +133,5 @@ } # do not remove the files here, as the mail is still queued! } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/backup-partition.rsc b/backup-partition.rsc index a4952564..3aee1834 100644 --- a/backup-partition.rsc +++ b/backup-partition.rsc @@ -115,5 +115,5 @@ :exit; } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/backup-upload.rsc b/backup-upload.rsc index ea58bcb0..e8b37351 100644 --- a/backup-upload.rsc +++ b/backup-upload.rsc @@ -169,5 +169,5 @@ } $RmDir $DirName; } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/capsman-download-packages.capsman.rsc b/capsman-download-packages.capsman.rsc index 867ee63e..849f6a4b 100644 --- a/capsman-download-packages.capsman.rsc +++ b/capsman-download-packages.capsman.rsc @@ -85,5 +85,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/capsman-download-packages.template.rsc b/capsman-download-packages.template.rsc index 5b086518..1d47d318 100644 --- a/capsman-download-packages.template.rsc +++ b/capsman-download-packages.template.rsc @@ -96,5 +96,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/capsman-download-packages.wifi.rsc b/capsman-download-packages.wifi.rsc index cf460ed1..9a0aaa57 100644 --- a/capsman-download-packages.wifi.rsc +++ b/capsman-download-packages.wifi.rsc @@ -87,5 +87,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/capsman-rolling-upgrade.capsman.rsc b/capsman-rolling-upgrade.capsman.rsc index dc5b09c5..948e9449 100644 --- a/capsman-rolling-upgrade.capsman.rsc +++ b/capsman-rolling-upgrade.capsman.rsc @@ -44,5 +44,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/capsman-rolling-upgrade.template.rsc b/capsman-rolling-upgrade.template.rsc index e0186644..3e769bba 100644 --- a/capsman-rolling-upgrade.template.rsc +++ b/capsman-rolling-upgrade.template.rsc @@ -52,5 +52,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/capsman-rolling-upgrade.wifi.rsc b/capsman-rolling-upgrade.wifi.rsc index b55a92fa..c49cf376 100644 --- a/capsman-rolling-upgrade.wifi.rsc +++ b/capsman-rolling-upgrade.wifi.rsc @@ -45,5 +45,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/certificate-renew-issued.rsc b/certificate-renew-issued.rsc index ef0410e9..a0a78d87 100644 --- a/certificate-renew-issued.rsc +++ b/certificate-renew-issued.rsc @@ -46,5 +46,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/check-certificates.rsc b/check-certificates.rsc index fd9d31a7..9c350947 100644 --- a/check-certificates.rsc +++ b/check-certificates.rsc @@ -247,5 +247,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/check-health.rsc b/check-health.rsc index 76a2d715..f0f2909f 100644 --- a/check-health.rsc +++ b/check-health.rsc @@ -103,5 +103,5 @@ :set CheckHealthPlugins; } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/check-lte-firmware-upgrade.rsc b/check-lte-firmware-upgrade.rsc index b986084f..20268f5b 100644 --- a/check-lte-firmware-upgrade.rsc +++ b/check-lte-firmware-upgrade.rsc @@ -101,5 +101,5 @@ $CheckInterface $ScriptName $Interface; } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/check-perpetual-license.rsc b/check-perpetual-license.rsc index 9d1b7562..1aa737d8 100644 --- a/check-perpetual-license.rsc +++ b/check-perpetual-license.rsc @@ -69,5 +69,5 @@ :set SentCertificateNotification; } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/check-routeros-update.rsc b/check-routeros-update.rsc index 23427ee6..8be3e917 100644 --- a/check-routeros-update.rsc +++ b/check-routeros-update.rsc @@ -203,5 +203,5 @@ :set SentRouterosUpdateNotification ($Update->"latest-version"); } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/collect-wireless-mac.capsman.rsc b/collect-wireless-mac.capsman.rsc index 6bf1222d..65d56ef0 100644 --- a/collect-wireless-mac.capsman.rsc +++ b/collect-wireless-mac.capsman.rsc @@ -94,5 +94,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/collect-wireless-mac.local.rsc b/collect-wireless-mac.local.rsc index c7a92609..3897f344 100644 --- a/collect-wireless-mac.local.rsc +++ b/collect-wireless-mac.local.rsc @@ -95,5 +95,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/collect-wireless-mac.template.rsc b/collect-wireless-mac.template.rsc index 9424bcac..a9cf82f1 100644 --- a/collect-wireless-mac.template.rsc +++ b/collect-wireless-mac.template.rsc @@ -112,5 +112,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/collect-wireless-mac.wifi.rsc b/collect-wireless-mac.wifi.rsc index 0698587c..11f4eba2 100644 --- a/collect-wireless-mac.wifi.rsc +++ b/collect-wireless-mac.wifi.rsc @@ -94,5 +94,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/daily-psk.capsman.rsc b/daily-psk.capsman.rsc index fd0176ed..4043388e 100644 --- a/daily-psk.capsman.rsc +++ b/daily-psk.capsman.rsc @@ -90,5 +90,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/daily-psk.local.rsc b/daily-psk.local.rsc index 6d7f26f4..d6d29055 100644 --- a/daily-psk.local.rsc +++ b/daily-psk.local.rsc @@ -89,5 +89,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/daily-psk.template.rsc b/daily-psk.template.rsc index 4b04f84f..1b89d011 100644 --- a/daily-psk.template.rsc +++ b/daily-psk.template.rsc @@ -105,5 +105,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/daily-psk.wifi.rsc b/daily-psk.wifi.rsc index 2e4f4d7f..c9bfc233 100644 --- a/daily-psk.wifi.rsc +++ b/daily-psk.wifi.rsc @@ -90,5 +90,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/dhcp-lease-comment.capsman.rsc b/dhcp-lease-comment.capsman.rsc index bde5e21b..2136f643 100644 --- a/dhcp-lease-comment.capsman.rsc +++ b/dhcp-lease-comment.capsman.rsc @@ -37,5 +37,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/dhcp-lease-comment.local.rsc b/dhcp-lease-comment.local.rsc index 69b450b6..d0e077e9 100644 --- a/dhcp-lease-comment.local.rsc +++ b/dhcp-lease-comment.local.rsc @@ -37,5 +37,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/dhcp-lease-comment.template.rsc b/dhcp-lease-comment.template.rsc index 3d03d04e..3a2d4dc7 100644 --- a/dhcp-lease-comment.template.rsc +++ b/dhcp-lease-comment.template.rsc @@ -42,5 +42,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/dhcp-lease-comment.wifi.rsc b/dhcp-lease-comment.wifi.rsc index d2c70dd7..c5d3cd4a 100644 --- a/dhcp-lease-comment.wifi.rsc +++ b/dhcp-lease-comment.wifi.rsc @@ -37,5 +37,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/dhcp-to-dns.rsc b/dhcp-to-dns.rsc index efb65c4c..dfb0399e 100644 --- a/dhcp-to-dns.rsc +++ b/dhcp-to-dns.rsc @@ -124,5 +124,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/firmware-upgrade-reboot.rsc b/firmware-upgrade-reboot.rsc index 0e32cf02..0b56db77 100644 --- a/firmware-upgrade-reboot.rsc +++ b/firmware-upgrade-reboot.rsc @@ -52,5 +52,5 @@ $LogPrint info $ScriptName ("Firmware upgrade successful, rebooting."); /system/reboot; } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/fw-addr-lists.rsc b/fw-addr-lists.rsc index 492ad535..029ea7d8 100644 --- a/fw-addr-lists.rsc +++ b/fw-addr-lists.rsc @@ -230,5 +230,5 @@ " - removed: " . [ $HumanReadableNum $CntRemove 1000 ]); } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/global-functions.rsc b/global-functions.rsc index 2aad406e..f1c54d5e 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -474,9 +474,8 @@ # simple macro to print error message on unintentional error :set ExitError do={ - :local ExitOK [ :tostr $1 ]; - :local Name [ :tostr $2 ]; - :local Error [ :tostr $3 ]; + :local Name [ :tostr $1 ]; + :local Error [ :tostr $2 ]; :global IfThenElse; :global LogPrint; @@ -1503,7 +1502,7 @@ :set GlobalConfigMigration; } } do={ - :global ExitError; $ExitError false $0 $Err; + :global ExitError; $ExitError $0 $Err; } } # lock script against multiple invocation @@ -1649,7 +1648,7 @@ $SendNotification2 ({ origin=$0; subject=$1; message=$2; link=$3; silent=$4 }); } do={ - :global ExitError; $ExitError false $0 $Err; + :global ExitError; $ExitError $0 $Err; } } # send notification via NotificationFunctions - expects one array argument diff --git a/gps-track.rsc b/gps-track.rsc index c0cd0ba4..a0e88a29 100644 --- a/gps-track.rsc +++ b/gps-track.rsc @@ -47,5 +47,5 @@ $LogPrint debug $ScriptName ("GPS data not valid."); } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/hotspot-to-wpa-cleanup.capsman.rsc b/hotspot-to-wpa-cleanup.capsman.rsc index 49a61a28..60bd3715 100644 --- a/hotspot-to-wpa-cleanup.capsman.rsc +++ b/hotspot-to-wpa-cleanup.capsman.rsc @@ -74,5 +74,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/hotspot-to-wpa-cleanup.template.rsc b/hotspot-to-wpa-cleanup.template.rsc index 8bf782e4..90c3f029 100644 --- a/hotspot-to-wpa-cleanup.template.rsc +++ b/hotspot-to-wpa-cleanup.template.rsc @@ -81,5 +81,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/hotspot-to-wpa-cleanup.wifi.rsc b/hotspot-to-wpa-cleanup.wifi.rsc index 404f4a4c..7cf6a1b1 100644 --- a/hotspot-to-wpa-cleanup.wifi.rsc +++ b/hotspot-to-wpa-cleanup.wifi.rsc @@ -74,5 +74,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/hotspot-to-wpa.capsman.rsc b/hotspot-to-wpa.capsman.rsc index 2a79147d..ff3a94b2 100644 --- a/hotspot-to-wpa.capsman.rsc +++ b/hotspot-to-wpa.capsman.rsc @@ -97,5 +97,5 @@ :delay 2s; /caps-man/access-list/set $Entry action=accept; } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/hotspot-to-wpa.template.rsc b/hotspot-to-wpa.template.rsc index c7b94378..3e8c8c03 100644 --- a/hotspot-to-wpa.template.rsc +++ b/hotspot-to-wpa.template.rsc @@ -117,5 +117,5 @@ /caps-man/access-list/set $Entry action=accept; /interface/wifi/access-list/set $Entry action=accept; } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/hotspot-to-wpa.wifi.rsc b/hotspot-to-wpa.wifi.rsc index 3a99bd1b..b3b1b79b 100644 --- a/hotspot-to-wpa.wifi.rsc +++ b/hotspot-to-wpa.wifi.rsc @@ -94,5 +94,5 @@ :delay 2s; /interface/wifi/access-list/set $Entry action=accept; } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/ipsec-to-dns.rsc b/ipsec-to-dns.rsc index 913a6e9d..dabed25c 100644 --- a/ipsec-to-dns.rsc +++ b/ipsec-to-dns.rsc @@ -78,5 +78,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/ipv6-update.rsc b/ipv6-update.rsc index 35314121..dc7000ca 100644 --- a/ipv6-update.rsc +++ b/ipv6-update.rsc @@ -98,5 +98,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/lease-script.rsc b/lease-script.rsc index 021f478e..ccd6a888 100644 --- a/lease-script.rsc +++ b/lease-script.rsc @@ -57,5 +57,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/log-forward.rsc b/log-forward.rsc index 6ad1d586..97a0bff3 100644 --- a/log-forward.rsc +++ b/log-forward.rsc @@ -108,5 +108,5 @@ :set LogForwardLast $Max; } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/mod/bridge-port-to.rsc b/mod/bridge-port-to.rsc index b14926bb..1046c80d 100644 --- a/mod/bridge-port-to.rsc +++ b/mod/bridge-port-to.rsc @@ -66,5 +66,5 @@ /interface/ethernet/enable $InterfaceReEnable; } } do={ - :global ExitError; $ExitError false $0 $Err; + :global ExitError; $ExitError $0 $Err; } } diff --git a/mod/bridge-port-vlan.rsc b/mod/bridge-port-vlan.rsc index 3d9567a9..845bf09c 100644 --- a/mod/bridge-port-vlan.rsc +++ b/mod/bridge-port-vlan.rsc @@ -75,5 +75,5 @@ /interface/ethernet/enable $InterfaceReEnable; } } do={ - :global ExitError; $ExitError false $0 $Err; + :global ExitError; $ExitError $0 $Err; } } diff --git a/mod/inspectvar.rsc b/mod/inspectvar.rsc index d8c0bc79..ce7fc780 100644 --- a/mod/inspectvar.rsc +++ b/mod/inspectvar.rsc @@ -17,7 +17,7 @@ :put [ :tocrlf [ $InspectVarReturn $1 ] ]; } do={ - :global ExitError; $ExitError false $0 $Err; + :global ExitError; $ExitError $0 $Err; } } # inspect variable and return formatted string diff --git a/mod/ipcalc.rsc b/mod/ipcalc.rsc index a485468e..bd1a330e 100644 --- a/mod/ipcalc.rsc +++ b/mod/ipcalc.rsc @@ -28,7 +28,7 @@ [ $FormatLine "HostMax" ($Values->"hostmax") ] . "\n" . \ [ $FormatLine "Broadcast" ($Values->"broadcast") ]) ]; } do={ - :global ExitError; $ExitError false $0 $Err; + :global ExitError; $ExitError $0 $Err; } } # calculate and return netmask, network, min host, max host and broadcast diff --git a/mod/notification-email.rsc b/mod/notification-email.rsc index 1ca76f62..d28387f7 100644 --- a/mod/notification-email.rsc +++ b/mod/notification-email.rsc @@ -146,7 +146,7 @@ /system/scheduler/set interval=(($SchedVal->"run-count") . "m") \ comment="Waiting for retry..." $Scheduler; } do={ - :global ExitError; $ExitError false $0 $Err; + :global ExitError; $ExitError $0 $Err; } } # generate filter for log-forward @@ -274,7 +274,7 @@ $SendEMail2 ({ origin=$0; subject=$1; message=$2; link=$3 }); } do={ - :global ExitError; $ExitError false $0 $Err; + :global ExitError; $ExitError $0 $Err; } } # send notification via e-mail - expects one array argument diff --git a/mod/notification-gotify.rsc b/mod/notification-gotify.rsc index 677d993c..121c1a9b 100644 --- a/mod/notification-gotify.rsc +++ b/mod/notification-gotify.rsc @@ -54,7 +54,7 @@ :set GotifyQueue; } } do={ - :global ExitError; $ExitError false $0 $Err; + :global ExitError; $ExitError $0 $Err; } } # send notification via Gotify - expects one array argument @@ -126,7 +126,7 @@ $SendGotify2 ({ origin=$0; subject=$1; message=$2; link=$3; silent=$4 }); } do={ - :global ExitError; $ExitError false $0 $Err; + :global ExitError; $ExitError $0 $Err; } } # send notification via Gotify - expects one array argument diff --git a/mod/notification-matrix.rsc b/mod/notification-matrix.rsc index b78b1132..80518a58 100644 --- a/mod/notification-matrix.rsc +++ b/mod/notification-matrix.rsc @@ -59,7 +59,7 @@ :set MatrixQueue; } } do={ - :global ExitError; $ExitError false $0 $Err; + :global ExitError; $ExitError $0 $Err; } } # send notification via Matrix - expects one array argument @@ -172,7 +172,7 @@ $SendMatrix2 ({ origin=$0; subject=$1; message=$2; link=$3 }); } do={ - :global ExitError; $ExitError false $0 $Err; + :global ExitError; $ExitError $0 $Err; } } # send notification via Matrix - expects one array argument diff --git a/mod/notification-ntfy.rsc b/mod/notification-ntfy.rsc index ac1792d4..e43de34a 100644 --- a/mod/notification-ntfy.rsc +++ b/mod/notification-ntfy.rsc @@ -53,7 +53,7 @@ :set NtfyQueue; } } do={ - :global ExitError; $ExitError false $0 $Err; + :global ExitError; $ExitError $0 $Err; } } # send notification via ntfy - expects one array argument @@ -148,7 +148,7 @@ $SendNtfy2 ({ origin=$0; subject=$1; message=$2; link=$3; silent=$4 }); } do={ - :global ExitError; $ExitError false $0 $Err; + :global ExitError; $ExitError $0 $Err; } } # send notification via ntfy - expects one array argument diff --git a/mod/notification-telegram.rsc b/mod/notification-telegram.rsc index 9e9ae57e..79012bbc 100644 --- a/mod/notification-telegram.rsc +++ b/mod/notification-telegram.rsc @@ -62,7 +62,7 @@ :set TelegramQueue; } } do={ - :global ExitError; $ExitError false $0 $Err; + :global ExitError; $ExitError $0 $Err; } } # get the chat id @@ -101,7 +101,7 @@ $LogPrint info $0 ("The thread id is: " . ($Message->"message_thread_id")); } } do={ - :global ExitError; $ExitError false $0 $Err; + :global ExitError; $ExitError $0 $Err; } } # send notification via telegram - expects one array argument @@ -237,7 +237,7 @@ $SendTelegram2 ({ origin=$0; subject=$1; message=$2; link=$3; silent=$4 }); } do={ - :global ExitError; $ExitError false $0 $Err; + :global ExitError; $ExitError $0 $Err; } } # send notification via telegram - expects one array argument diff --git a/mod/scriptrunonce.rsc b/mod/scriptrunonce.rsc index 598c7602..fb2bb429 100644 --- a/mod/scriptrunonce.rsc +++ b/mod/scriptrunonce.rsc @@ -52,5 +52,5 @@ :return true; } } do={ - :global ExitError; $ExitError false $0 $Err; + :global ExitError; $ExitError $0 $Err; } } diff --git a/mod/ssh-keys-import.rsc b/mod/ssh-keys-import.rsc index 16a02859..2732691c 100644 --- a/mod/ssh-keys-import.rsc +++ b/mod/ssh-keys-import.rsc @@ -68,7 +68,7 @@ :return false; } } do={ - :global ExitError; $ExitError false $0 $Err; + :global ExitError; $ExitError $0 $Err; } } # import keys from a file @@ -110,5 +110,5 @@ } } } do={ - :global ExitError; $ExitError false $0 $Err; + :global ExitError; $ExitError $0 $Err; } } diff --git a/mode-button.rsc b/mode-button.rsc index b5c89c7a..4ea82c3a 100644 --- a/mode-button.rsc +++ b/mode-button.rsc @@ -82,7 +82,7 @@ $LogPrint info $FuncName ("No action defined for " . $Count . " mode-button presses."); } } do={ - :global ExitError; $ExitError false $0 $Err; + :global ExitError; $ExitError $0 $Err; } } /system/scheduler/add name="_ModeButtonScheduler" \ on-event=":global ModeButtonScheduler; \$ModeButtonScheduler;" interval=3s; @@ -91,5 +91,5 @@ /system/scheduler/set $Scheduler start-time=[ /system/clock/get time ]; } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/netwatch-dns.rsc b/netwatch-dns.rsc index 9a40ecc0..99dc8a2a 100644 --- a/netwatch-dns.rsc +++ b/netwatch-dns.rsc @@ -139,5 +139,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/netwatch-notify.rsc b/netwatch-notify.rsc index ad3a1aa7..e25b30d7 100644 --- a/netwatch-notify.rsc +++ b/netwatch-notify.rsc @@ -223,5 +223,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/ospf-to-leds.rsc b/ospf-to-leds.rsc index 9d1265b5..c2a38992 100644 --- a/ospf-to-leds.rsc +++ b/ospf-to-leds.rsc @@ -43,5 +43,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/packages-update.rsc b/packages-update.rsc index 6ac7ecf5..a0d40192 100644 --- a/packages-update.rsc +++ b/packages-update.rsc @@ -164,5 +164,5 @@ :delay 1s; /system/reboot; } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/ppp-on-up.rsc b/ppp-on-up.rsc index 572686a3..6cc0755e 100644 --- a/ppp-on-up.rsc +++ b/ppp-on-up.rsc @@ -38,5 +38,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/sms-action.rsc b/sms-action.rsc index 6a6470af..c2bc5829 100644 --- a/sms-action.rsc +++ b/sms-action.rsc @@ -35,5 +35,5 @@ $LogPrint warning $ScriptName ("The code for action '" . $Action . "' failed syntax validation!"); } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/sms-forward.rsc b/sms-forward.rsc index 934040f2..231e22a2 100644 --- a/sms-forward.rsc +++ b/sms-forward.rsc @@ -103,5 +103,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/telegram-chat.rsc b/telegram-chat.rsc index bac3a969..5f44ca3c 100644 --- a/telegram-chat.rsc +++ b/telegram-chat.rsc @@ -192,5 +192,5 @@ :set TelegramChatOffset ([ :pick $TelegramChatOffset 1 3 ], \ [ $IfThenElse ($UpdateID >= $TelegramChatOffset->2) ($UpdateID + 1) ($TelegramChatOffset->2) ]); } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/update-gre-address.rsc b/update-gre-address.rsc index 407a0b4b..58c6cc20 100644 --- a/update-gre-address.rsc +++ b/update-gre-address.rsc @@ -40,5 +40,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } diff --git a/update-tunnelbroker.rsc b/update-tunnelbroker.rsc index 2fa07606..e669eb13 100644 --- a/update-tunnelbroker.rsc +++ b/update-tunnelbroker.rsc @@ -66,5 +66,5 @@ } } } do={ - :global ExitError; $ExitError false [ :jobname ] $Err; + :global ExitError; $ExitError [ :jobname ] $Err; } From 6772085430b98588ca1d9f4185a31aec99078e26 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 15 Jan 2026 09:28:38 +0100 Subject: [PATCH 45/51] telegram-chat: use :continue in loop --- telegram-chat.rsc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/telegram-chat.rsc b/telegram-chat.rsc index 5f44ca3c..aa5a001c 100644 --- a/telegram-chat.rsc +++ b/telegram-chat.rsc @@ -115,7 +115,6 @@ } :if ($Trusted = true) do={ - :local Done false; :if ($Command = "?") do={ $LogPrint info $ScriptName ("Sending notice for update " . $UpdateID . "."); $SendTelegram2 ({ origin=$ScriptName; chatid=($Chat->"id"); silent=true; \ @@ -123,9 +122,9 @@ subject=([ $SymbolForNotification "speech-balloon" ] . "Telegram Chat"); \ message=([ $IfThenElse ([ :len ($From->"first_name") ] > 0) ("Hello " . ($From->"first_name") . "!\n\n") ] . \ "Online" . [ $IfThenElse $TelegramChatActive " (and active!)" ] . ", awaiting your commands!") }); - :set Done true; + :continue; } - :if ($Done = false && [ :pick $Command 0 1 ] = "!") do={ + :if ([ :pick $Command 0 1 ] = "!") do={ :if ($Command ~ ("^! *(" . [ $EscapeForRegEx $Identity ] . "|@" . $TelegramChatGroups . ")\$")) do={ :set TelegramChatActive true; } else={ @@ -133,9 +132,9 @@ } $LogPrint info $ScriptName ("Now " . [ $IfThenElse $TelegramChatActive "active" "passive" ] . \ " from update " . $UpdateID . "!"); - :set Done true; + :continue; } - :if ($Done = false && ($IsMyReply = 1 || ($IsAnyReply = false && \ + :if (($IsMyReply = 1 || ($IsAnyReply = false && \ $TelegramChatActive = true)) && [ :len $Command ] > 0) do={ :if ([ $ValidateSyntax $Command ] = true) do={ :local State ""; From 617a86a93214b3c72f17928721f5c4935549591d Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 15 Jan 2026 10:29:17 +0100 Subject: [PATCH 46/51] mod/ssh-keys-import: drop old property The property name changed in RouterOS 7.21beta2, so bump required version to 7.21. --- mod/ssh-keys-import.rsc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mod/ssh-keys-import.rsc b/mod/ssh-keys-import.rsc index 2732691c..36ca9f8a 100644 --- a/mod/ssh-keys-import.rsc +++ b/mod/ssh-keys-import.rsc @@ -3,7 +3,7 @@ # Copyright (c) 2020-2026 Christian Hesse # https://rsc.eworm.de/COPYING.md # -# requires RouterOS, version=7.17 +# requires RouterOS, version=7.21 # # import ssh keys for public key authentication # https://rsc.eworm.de/doc/mod/ssh-keys-import.md @@ -40,9 +40,8 @@ :local FingerPrintMD5 [ :convert from=base64 transform=md5 to=hex ($KeyVal->1) ]; - :local RegEx ("\\bmd5=" . $FingerPrintMD5 . "\\b"); :if ([ :len [ /user/ssh-keys/find where user=$User \ - (key-owner~$RegEx or info~$RegEx) ] ] > 0) do={ + info~("\\bmd5=" . $FingerPrintMD5 . "\\b") ] ] > 0) do={ $LogPrint warning $0 ("The ssh public key (MD5:" . $FingerPrintMD5 . \ ") is already available for user '" . $User . "'."); :return false; From 511f1cc0f523882f970e6ea388fc6c590fa573ab Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 15 Jan 2026 10:32:21 +0100 Subject: [PATCH 47/51] doc/mod/ssh-keys-import: update for RouterOS 7.21 --- doc/mod/ssh-keys-import.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/mod/ssh-keys-import.md b/doc/mod/ssh-keys-import.md index 434caa51..c6530ec2 100644 --- a/doc/mod/ssh-keys-import.md +++ b/doc/mod/ssh-keys-import.md @@ -4,7 +4,7 @@ Import ssh keys for public key authentication [![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.17-yellow?style=flat)](https://mikrotik.com/download/changelogs/) +[![required RouterOS version](https://img.shields.io/badge/RouterOS-7.21-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) @@ -38,9 +38,8 @@ import that key: $SSHKeysImport "ssh-rsa AAAAB3Nza...QYZk8= user" admin; The third part of the key (`user` in this example) is inherited as -`info` in RouterOS (or `key-owner` with RouterOS 7.20.x and before). Also -the `MD5` fingerprint is recorded, this helps to audit and verify the -available keys. +`info` in RouterOS. Also the `MD5` fingerprint is recorded, this helps +to audit and verify the available keys. > ℹ️️ **Info**: Use `ssh-keygen` to show a fingerprint of an existing public > key file: `ssh-keygen -l -E md5 -f ~/.ssh/id_ed25519.pub` From 58672a7fef73589403301d04c9f2c20642558ec4 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:38:00 +0100 Subject: [PATCH 48/51] fw-addr-lists: use :continue in loop --- fw-addr-lists.rsc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fw-addr-lists.rsc b/fw-addr-lists.rsc index 029ea7d8..85bb9aee 100644 --- a/fw-addr-lists.rsc +++ b/fw-addr-lists.rsc @@ -111,7 +111,7 @@ } else={ :set Address ([ :pick $Line 0 [ $FindDelim $Line ] ] . ($List->"cidr")); } - :do { + :local Branch; :if ($Address ~ "^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}(/[0-9]{1,2})?\$") do={ :local Net $Address; @@ -124,7 +124,7 @@ } :set Branch [ $GetBranch $Address ]; :set ($IPv4Addresses->$Branch->$Address) $TimeOut; - :error true; + :continue; } :if ($Address ~ "^[0-9a-zA-Z]*:[0-9a-zA-Z:\\.]+(/[0-9]{1,3})?\$") do={ :local Net $Address; @@ -137,15 +137,14 @@ :set Address (([ :toip6 $Net ] & [ $NetMask6 $CIDR ]) . "/" . $CIDR); :set Branch [ $GetBranch $Address ]; :set ($IPv6Addresses->$Branch->$Address) $TimeOut; - :error true; + :continue; } :if ($Address ~ "^[\\.a-zA-Z0-9-]+\\.[a-zA-Z]{2,}\$") do={ :set Branch [ $GetBranch $Address ]; :set ($IPv4Addresses->$Branch->$Address) $TimeOut; :set ($IPv6Addresses->$Branch->$Address) $TimeOut; - :error true; + :continue; } - } on-error={ } } } From 8097ebb1fc7b702329c04908b1ff03c41fac88c1 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:38:50 +0100 Subject: [PATCH 49/51] fw-addr-lists: fix indention --- fw-addr-lists.rsc | 62 +++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/fw-addr-lists.rsc b/fw-addr-lists.rsc index 85bb9aee..62516f55 100644 --- a/fw-addr-lists.rsc +++ b/fw-addr-lists.rsc @@ -112,39 +112,39 @@ :set Address ([ :pick $Line 0 [ $FindDelim $Line ] ] . ($List->"cidr")); } - :local Branch; - :if ($Address ~ "^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}(/[0-9]{1,2})?\$") do={ - :local Net $Address; - :local CIDR 32; - :local Slash [ :find $Address "/" ]; - :if ([ :typeof $Slash ] = "num") do={ - :set Net [ :toip [ :pick $Address 0 $Slash ] ] - :set CIDR [ :pick $Address ($Slash + 1) [ :len $Address ] ]; - :set Address [ :tostr (([ :toip $Net ] & [ $NetMask4 $CIDR ]) . [ $IfThenElse ($CIDR < 32) ("/" . $CIDR) ]) ]; - } - :set Branch [ $GetBranch $Address ]; - :set ($IPv4Addresses->$Branch->$Address) $TimeOut; - :continue; + :local Branch; + :if ($Address ~ "^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}(/[0-9]{1,2})?\$") do={ + :local Net $Address; + :local CIDR 32; + :local Slash [ :find $Address "/" ]; + :if ([ :typeof $Slash ] = "num") do={ + :set Net [ :toip [ :pick $Address 0 $Slash ] ] + :set CIDR [ :pick $Address ($Slash + 1) [ :len $Address ] ]; + :set Address [ :tostr (([ :toip $Net ] & [ $NetMask4 $CIDR ]) . [ $IfThenElse ($CIDR < 32) ("/" . $CIDR) ]) ]; } - :if ($Address ~ "^[0-9a-zA-Z]*:[0-9a-zA-Z:\\.]+(/[0-9]{1,3})?\$") do={ - :local Net $Address; - :local CIDR 128; - :local Slash [ :find $Address "/" ]; - :if ([ :typeof $Slash ] = "num") do={ - :set Net [ :toip6 [ :pick $Address 0 $Slash ] ] - :set CIDR [ :pick $Address ($Slash + 1) [ :len $Address ] ]; - } - :set Address (([ :toip6 $Net ] & [ $NetMask6 $CIDR ]) . "/" . $CIDR); - :set Branch [ $GetBranch $Address ]; - :set ($IPv6Addresses->$Branch->$Address) $TimeOut; - :continue; - } - :if ($Address ~ "^[\\.a-zA-Z0-9-]+\\.[a-zA-Z]{2,}\$") do={ - :set Branch [ $GetBranch $Address ]; - :set ($IPv4Addresses->$Branch->$Address) $TimeOut; - :set ($IPv6Addresses->$Branch->$Address) $TimeOut; - :continue; + :set Branch [ $GetBranch $Address ]; + :set ($IPv4Addresses->$Branch->$Address) $TimeOut; + :continue; + } + :if ($Address ~ "^[0-9a-zA-Z]*:[0-9a-zA-Z:\\.]+(/[0-9]{1,3})?\$") do={ + :local Net $Address; + :local CIDR 128; + :local Slash [ :find $Address "/" ]; + :if ([ :typeof $Slash ] = "num") do={ + :set Net [ :toip6 [ :pick $Address 0 $Slash ] ] + :set CIDR [ :pick $Address ($Slash + 1) [ :len $Address ] ]; } + :set Address (([ :toip6 $Net ] & [ $NetMask6 $CIDR ]) . "/" . $CIDR); + :set Branch [ $GetBranch $Address ]; + :set ($IPv6Addresses->$Branch->$Address) $TimeOut; + :continue; + } + :if ($Address ~ "^[\\.a-zA-Z0-9-]+\\.[a-zA-Z]{2,}\$") do={ + :set Branch [ $GetBranch $Address ]; + :set ($IPv4Addresses->$Branch->$Address) $TimeOut; + :set ($IPv6Addresses->$Branch->$Address) $TimeOut; + :continue; + } } } From 83d6335379b9ab744aa9781d897f58cf184750b6 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 16:08:37 +0100 Subject: [PATCH 50/51] global-functions: $ScriptInstallUpdate: use :continue in loop --- global-functions.rsc | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index f1c54d5e..7ceb7ee4 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -1287,17 +1287,16 @@ } } - :do { :if ($ScriptInfo->"ignore" = true) do={ $LogPrint debug $0 ("Ignoring script '" . $ScriptVal->"name" . "', as requested."); - :error true; + :continue; } :local CheckSum ($CheckSums->($ScriptVal->"name")); :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; + :continue; } :if ([ :len ($ScriptInfo->"certificate") ] > 0) do={ @@ -1319,44 +1318,44 @@ } do={ $LogPrint warning $0 ("Failed fetching script '" . $ScriptVal->"name" . "': " . $Err); :if ($Err != "Fetch failed with status 404") do={ - :error false; + :continue; } :if ($ScriptVal->"source" = "#!rsc by RouterOS\n") do={ $LogPrint warning $0 ("Removing dummy. Typo on installation?"); /system/script/remove $Script; - :error false; + :continue; } :if ([ :len ($ScriptInfo->"base-url") ] = 0 && [ :len ($ScriptInfo->"url-suffix") ] = 0 && \ [ :len $CheckSum ] = 0) do={ $LogPrintOnce warning $0 \ ("Added the script manually? Skip updates with 'ignore=true' in comment."); } - :error false; + :continue; } :if ([ :len $SourceNew ] = 0) do={ $LogPrint debug $0 ("No update for script '" . $ScriptVal->"name" . "'."); - :error false; + :continue; } :local SourceCRLF [ :tocrlf $SourceNew ]; :if ($SourceNew = $ScriptVal->"source" || $SourceCRLF = $ScriptVal->"source") do={ $LogPrint debug $0 ("Script '" . $ScriptVal->"name" . "' did not change."); - :error false; + :continue; } :if ([ :pick $SourceNew 0 18 ] != "#!rsc by RouterOS\n") do={ $LogPrint warning $0 ("Looks like new script '" . $ScriptVal->"name" . \ "' is not valid (missing shebang). Ignoring!"); - :error false; + :continue; } :local RequiredROS ([ $ParseKeyValueStore [ $Grep $SourceNew ("\23 requires RouterOS, ") ] ]->"version"); :if ([ $RequiredRouterOS $0 [ $EitherOr $RequiredROS "0.0" ] false ] = false) do={ $LogPrintOnce warning $0 ("The script '" . $ScriptVal->"name" . "' requires RouterOS " . \ $RequiredROS . ", which is not met by your installation. Ignoring!"); - :error false; + :continue; } :local RequiredDM [ $ParseKeyValueStore [ $Grep $SourceNew ("\23 requires device-mode, ") ] ]; @@ -1369,12 +1368,12 @@ :if ([ :len $MissingDM ] > 0) do={ $LogPrintOnce warning $0 ("The script '" . $ScriptVal->"name" . "' requires disabled " . \ "device-mode features (" . [ :tostr $MissingDM ] . "). Ignoring!"); - :error false; + :continue; } :if ([ $ValidateSyntax $SourceNew ] = false) do={ $LogPrint warning $0 ("Syntax validation for script '" . $ScriptVal->"name" . "' failed! Ignoring!"); - :error false; + :continue; } $LogPrint info $0 ("Updating script: " . $ScriptVal->"name"); @@ -1385,7 +1384,6 @@ $ScriptVal->"name" ~ ("^mod/.")) do={ :set ReloadGlobal true; } - } on-error={ } } :if ($ReloadGlobal = true) do={ From 67aea8d5e481e5c7596329fb574a74e34c683aea Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 16:09:41 +0100 Subject: [PATCH 51/51] global-functions: $ScriptInstallUpdate: fix indention --- global-functions.rsc | 168 +++++++++++++++++++++---------------------- 1 file changed, 84 insertions(+), 84 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index 7ceb7ee4..3fc65fc7 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -1287,103 +1287,103 @@ } } - :if ($ScriptInfo->"ignore" = true) do={ - $LogPrint debug $0 ("Ignoring script '" . $ScriptVal->"name" . "', as requested."); + :if ($ScriptInfo->"ignore" = true) do={ + $LogPrint debug $0 ("Ignoring script '" . $ScriptVal->"name" . "', as requested."); + :continue; + } + + :local CheckSum ($CheckSums->($ScriptVal->"name")); + :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."); + :continue; + } + + :if ([ :len ($ScriptInfo->"certificate") ] > 0) do={ + :if ([ $CertificateAvailable ($ScriptInfo->"certificate") "fetch" ] = false) do={ + $LogPrint warning $0 ("Downloading certificate failed, trying without."); + } + } + + :onerror Err { + :local BaseUrl [ $EitherOr ($ScriptInfo->"base-url") $ScriptUpdatesBaseUrl ]; + :local UrlSuffix [ $EitherOr ($ScriptInfo->"url-suffix") $ScriptUpdatesUrlSuffix ]; + :local Url ($BaseUrl . $ScriptVal->"name" . ".rsc" . $UrlSuffix); + $LogPrint debug $0 ("Fetching script '" . $ScriptVal->"name" . "' from url: " . $Url); + :local Result [ /tool/fetch check-certificate=yes-without-crl \ + http-header-field=({ [ $FetchUserAgentStr $0 ] }) $Url output=user as-value ]; + :if ($Result->"status" = "finished") do={ + :set SourceNew [ :tolf ($Result->"data") ]; + } + } do={ + $LogPrint warning $0 ("Failed fetching script '" . $ScriptVal->"name" . "': " . $Err); + :if ($Err != "Fetch failed with status 404") do={ :continue; } - :local CheckSum ($CheckSums->($ScriptVal->"name")); + :if ($ScriptVal->"source" = "#!rsc by RouterOS\n") do={ + $LogPrint warning $0 ("Removing dummy. Typo on installation?"); + /system/script/remove $Script; + :continue; + } :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."); - :continue; + [ :len $CheckSum ] = 0) do={ + $LogPrintOnce warning $0 \ + ("Added the script manually? Skip updates with 'ignore=true' in comment."); } + :continue; + } - :if ([ :len ($ScriptInfo->"certificate") ] > 0) do={ - :if ([ $CertificateAvailable ($ScriptInfo->"certificate") "fetch" ] = false) do={ - $LogPrint warning $0 ("Downloading certificate failed, trying without."); - } - } + :if ([ :len $SourceNew ] = 0) do={ + $LogPrint debug $0 ("No update for script '" . $ScriptVal->"name" . "'."); + :continue; + } - :onerror Err { - :local BaseUrl [ $EitherOr ($ScriptInfo->"base-url") $ScriptUpdatesBaseUrl ]; - :local UrlSuffix [ $EitherOr ($ScriptInfo->"url-suffix") $ScriptUpdatesUrlSuffix ]; - :local Url ($BaseUrl . $ScriptVal->"name" . ".rsc" . $UrlSuffix); - $LogPrint debug $0 ("Fetching script '" . $ScriptVal->"name" . "' from url: " . $Url); - :local Result [ /tool/fetch check-certificate=yes-without-crl \ - http-header-field=({ [ $FetchUserAgentStr $0 ] }) $Url output=user as-value ]; - :if ($Result->"status" = "finished") do={ - :set SourceNew [ :tolf ($Result->"data") ]; - } - } do={ - $LogPrint warning $0 ("Failed fetching script '" . $ScriptVal->"name" . "': " . $Err); - :if ($Err != "Fetch failed with status 404") do={ - :continue; - } + :local SourceCRLF [ :tocrlf $SourceNew ]; + :if ($SourceNew = $ScriptVal->"source" || $SourceCRLF = $ScriptVal->"source") do={ + $LogPrint debug $0 ("Script '" . $ScriptVal->"name" . "' did not change."); + :continue; + } - :if ($ScriptVal->"source" = "#!rsc by RouterOS\n") do={ - $LogPrint warning $0 ("Removing dummy. Typo on installation?"); - /system/script/remove $Script; - :continue; - } - :if ([ :len ($ScriptInfo->"base-url") ] = 0 && [ :len ($ScriptInfo->"url-suffix") ] = 0 && \ - [ :len $CheckSum ] = 0) do={ - $LogPrintOnce warning $0 \ - ("Added the script manually? Skip updates with 'ignore=true' in comment."); - } - :continue; - } + :if ([ :pick $SourceNew 0 18 ] != "#!rsc by RouterOS\n") do={ + $LogPrint warning $0 ("Looks like new script '" . $ScriptVal->"name" . \ + "' is not valid (missing shebang). Ignoring!"); + :continue; + } - :if ([ :len $SourceNew ] = 0) do={ - $LogPrint debug $0 ("No update for script '" . $ScriptVal->"name" . "'."); - :continue; - } + :local RequiredROS ([ $ParseKeyValueStore [ $Grep $SourceNew ("\23 requires RouterOS, ") ] ]->"version"); + :if ([ $RequiredRouterOS $0 [ $EitherOr $RequiredROS "0.0" ] false ] = false) do={ + $LogPrintOnce warning $0 ("The script '" . $ScriptVal->"name" . "' requires RouterOS " . \ + $RequiredROS . ", which is not met by your installation. Ignoring!"); + :continue; + } - :local SourceCRLF [ :tocrlf $SourceNew ]; - :if ($SourceNew = $ScriptVal->"source" || $SourceCRLF = $ScriptVal->"source") do={ - $LogPrint debug $0 ("Script '" . $ScriptVal->"name" . "' did not change."); - :continue; + :local RequiredDM [ $ParseKeyValueStore [ $Grep $SourceNew ("\23 requires device-mode, ") ] ]; + :local MissingDM ({}); + :foreach Feature,Value in=$RequiredDM do={ + :if ([ :typeof ($DeviceMode->$Feature) ] = "bool" && ($DeviceMode->$Feature) = false) do={ + :set MissingDM ($MissingDM, $Feature); } + } + :if ([ :len $MissingDM ] > 0) do={ + $LogPrintOnce warning $0 ("The script '" . $ScriptVal->"name" . "' requires disabled " . \ + "device-mode features (" . [ :tostr $MissingDM ] . "). Ignoring!"); + :continue; + } - :if ([ :pick $SourceNew 0 18 ] != "#!rsc by RouterOS\n") do={ - $LogPrint warning $0 ("Looks like new script '" . $ScriptVal->"name" . \ - "' is not valid (missing shebang). Ignoring!"); - :continue; - } + :if ([ $ValidateSyntax $SourceNew ] = false) do={ + $LogPrint warning $0 ("Syntax validation for script '" . $ScriptVal->"name" . "' failed! Ignoring!"); + :continue; + } - :local RequiredROS ([ $ParseKeyValueStore [ $Grep $SourceNew ("\23 requires RouterOS, ") ] ]->"version"); - :if ([ $RequiredRouterOS $0 [ $EitherOr $RequiredROS "0.0" ] false ] = false) do={ - $LogPrintOnce warning $0 ("The script '" . $ScriptVal->"name" . "' requires RouterOS " . \ - $RequiredROS . ", which is not met by your installation. Ignoring!"); - :continue; - } - - :local RequiredDM [ $ParseKeyValueStore [ $Grep $SourceNew ("\23 requires device-mode, ") ] ]; - :local MissingDM ({}); - :foreach Feature,Value in=$RequiredDM do={ - :if ([ :typeof ($DeviceMode->$Feature) ] = "bool" && ($DeviceMode->$Feature) = false) do={ - :set MissingDM ($MissingDM, $Feature); - } - } - :if ([ :len $MissingDM ] > 0) do={ - $LogPrintOnce warning $0 ("The script '" . $ScriptVal->"name" . "' requires disabled " . \ - "device-mode features (" . [ :tostr $MissingDM ] . "). Ignoring!"); - :continue; - } - - :if ([ $ValidateSyntax $SourceNew ] = false) do={ - $LogPrint warning $0 ("Syntax validation for script '" . $ScriptVal->"name" . "' failed! Ignoring!"); - :continue; - } - - $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" || \ - $ScriptVal->"name" = "global-functions" || \ - $ScriptVal->"name" ~ ("^mod/.")) do={ - :set ReloadGlobal true; - } + $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" || \ + $ScriptVal->"name" = "global-functions" || \ + $ScriptVal->"name" ~ ("^mod/.")) do={ + :set ReloadGlobal true; + } } :if ($ReloadGlobal = true) do={