From ea75c11bb2ef8892ba57cf4a117d8d6ee2ea485c Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 14:57:52 +0100 Subject: [PATCH 01/36] 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 b4925f33..7c3df8e4 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From 98eb30e4a06426b33865d5a3a221ead0604afdd9 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 14:59:06 +0100 Subject: [PATCH 02/36] 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 fcafff45..54717cbc 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From 869264727652baf06792938c377ddd79c6e28b1d Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:00:40 +0100 Subject: [PATCH 03/36] 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 78f4cce1..2e34a8c8 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From e97236f5e32c79a18d5327073ea7ef970f65cdd7 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:01:49 +0100 Subject: [PATCH 04/36] 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 bded570c..3c25b12d 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From 478aec6a6d766b590ba73d4efdc92c24db5eac78 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:02:56 +0100 Subject: [PATCH 05/36] 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 8cedf01b..c89d299e 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } diff --git a/capsman-download-packages.template.rsc b/capsman-download-packages.template.rsc index ffb622ba..eeb6fb69 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } diff --git a/capsman-download-packages.wifi.rsc b/capsman-download-packages.wifi.rsc index 1aefee63..45d39956 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From 95620dee853c9b0b573452935aed74e396e73f65 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:03:44 +0100 Subject: [PATCH 06/36] 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 caa768d8..8794f99d 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } diff --git a/capsman-rolling-upgrade.template.rsc b/capsman-rolling-upgrade.template.rsc index d38cdda9..d4e6d6be 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } diff --git a/capsman-rolling-upgrade.wifi.rsc b/capsman-rolling-upgrade.wifi.rsc index 330ec04d..e8ed3b1f 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From d906ae5611d1090dd20e165163a09654c15059d6 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:04:38 +0100 Subject: [PATCH 07/36] 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 e78669f4..6b2c9941 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From 3fdcace9a26715e9ad80c5e080d08e25149f652c Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:05:17 +0100 Subject: [PATCH 08/36] 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 e10c82ae..5df5b285 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) \ @@ -158,8 +157,7 @@ } :if ([ $ScriptLock $ScriptName ] = false) do={ - :set ExitOK true; - :error false; + :exit; } $WaitFullyConnected; @@ -258,5 +256,5 @@ } } } do={ - :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; + :global ExitOnError; $ExitOnError [ :jobname ] $Err; } From d36d5dec994ef98b33c9f1bb49a07f509f791a4f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:06:07 +0100 Subject: [PATCH 09/36] 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 51438966..200b76ab 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From 4e0cdef89b29d40cba755b487dd84b9c23149da3 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:06:43 +0100 Subject: [PATCH 10/36] 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 2087075e..4f856dfb 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From 99da24a4eeaddb15ccf5183feaa953093aa1d799 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:07:40 +0100 Subject: [PATCH 11/36] 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 21d63cad..fb1017e6 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From 662b11b3279a74846043f83bf3b6eba4f7886a85 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:09:25 +0100 Subject: [PATCH 12/36] 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 bf3acd98..9bd7dedf 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From 4a5fbbdc292b4e3ae7f4a7b967a80ef6160bf9ab Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:10:22 +0100 Subject: [PATCH 13/36] 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 8bb33d87..2b2dac41 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } diff --git a/collect-wireless-mac.local.rsc b/collect-wireless-mac.local.rsc index 9d41d420..f74bd687 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } diff --git a/collect-wireless-mac.template.rsc b/collect-wireless-mac.template.rsc index 837726e3..da3799f2 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } diff --git a/collect-wireless-mac.wifi.rsc b/collect-wireless-mac.wifi.rsc index d07ff357..88e21dd5 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From 4ba61997504d9fe5f6612f21d5d1c1d71e99a184 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:11:17 +0100 Subject: [PATCH 14/36] 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 2cee46ed..6a0d2827 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } diff --git a/daily-psk.local.rsc b/daily-psk.local.rsc index fbf6dafe..7ea42792 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } diff --git a/daily-psk.template.rsc b/daily-psk.template.rsc index 81244b86..dc0539a8 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } diff --git a/daily-psk.wifi.rsc b/daily-psk.wifi.rsc index 636e9f43..b4953c9f 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From 65f0d47134d0fbff5860cfea01eb093a00ed7210 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:11:57 +0100 Subject: [PATCH 15/36] 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 7fd00a09..76be221d 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } diff --git a/dhcp-lease-comment.local.rsc b/dhcp-lease-comment.local.rsc index 7ed6823a..fb685b8e 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } diff --git a/dhcp-lease-comment.template.rsc b/dhcp-lease-comment.template.rsc index c901de40..7d3d4e7b 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } diff --git a/dhcp-lease-comment.wifi.rsc b/dhcp-lease-comment.wifi.rsc index d481def8..a96eff74 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From 7d7e31ca679ce2650b57ba983ed2ec2645b5d31d Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:12:42 +0100 Subject: [PATCH 16/36] 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 94c7492e..fad99f88 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From 99e27f2c2391e132002f56254884dc8ccb8b3906 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:13:25 +0100 Subject: [PATCH 17/36] 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 7c64909d..ac8a7d69 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From c6cfd846953ab426412b90228d325fbc3d7f67c4 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:14:54 +0100 Subject: [PATCH 18/36] 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 ac15c652..3d295eb3 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From e7a020a92e521325365828eec83018790f2715e0 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:14:06 +0100 Subject: [PATCH 19/36] 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 ce55c049..e6027e72 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From 337bd7da6d7714c5b82e50a8126fbef2e47c35e6 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:16:29 +0100 Subject: [PATCH 20/36] 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 60945a1a..808cabfe 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } diff --git a/hotspot-to-wpa.template.rsc b/hotspot-to-wpa.template.rsc index 7c56cc10..f9acdbc0 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } diff --git a/hotspot-to-wpa.wifi.rsc b/hotspot-to-wpa.wifi.rsc index 68ed4c2e..c62caa73 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From d25dafa9659a4da92a29eea4a6bc435a543a87f9 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:17:06 +0100 Subject: [PATCH 21/36] 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 35275313..b551d8f1 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } diff --git a/hotspot-to-wpa-cleanup.template.rsc b/hotspot-to-wpa-cleanup.template.rsc index 398f194f..5f174af2 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } diff --git a/hotspot-to-wpa-cleanup.wifi.rsc b/hotspot-to-wpa-cleanup.wifi.rsc index 17b9e545..d783f995 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From ed28dc047350c38449094cd897195f9e4856b27d Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:17:52 +0100 Subject: [PATCH 22/36] 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 a08405fb..77db9367 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From 4f7d4186e15d0ade4449efe68af2bdab8a90f4a1 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:18:44 +0100 Subject: [PATCH 23/36] 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 c87410cc..188cc23e 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From aa0b90d6119fbf0b72bf87564213168598fb01e4 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:19:58 +0100 Subject: [PATCH 24/36] 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 991e6fac..3cbf8ab0 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From bff777acbf18ce05c54e69e8ca5429d4baebad04 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:20:53 +0100 Subject: [PATCH 25/36] 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..018c729e 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From bc5940e5bd91cc8295c7a7c33438c78107321a10 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 15 Jan 2026 09:25:48 +0100 Subject: [PATCH 26/36] netwatch-dns: early exit with :exit --- netwatch-dns.rsc | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/netwatch-dns.rsc b/netwatch-dns.rsc index 9531d4ad..e57bb74a 100644 --- a/netwatch-dns.rsc +++ b/netwatch-dns.rsc @@ -9,7 +9,6 @@ # 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From fd0eab13b5744b83b792c511aab84cfb6091b650 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:21:27 +0100 Subject: [PATCH 27/36] 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 d9ab5446..3998c402 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From 88e3228957c684e07b1eba3d8de846192d8743c8 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:22:02 +0100 Subject: [PATCH 28/36] 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 784fcdd8..209b503f 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From e89811cb5c4690216b57376d31dab55f97ccd80a Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:23:27 +0100 Subject: [PATCH 29/36] 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 304a3683..15fc4926 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From 71e9afc1b347aac669f9b8a0c0042bed1d6e59b3 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:24:01 +0100 Subject: [PATCH 30/36] 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 79b83861..c91d720a 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From 14a694e9997f6b24bbbf3d2167c6d36734caae64 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:24:32 +0100 Subject: [PATCH 31/36] 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 12d4cc20..b5263882 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From c7a5ed21b5a5bb2e93f3993f070547c148742d5c Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:25:19 +0100 Subject: [PATCH 32/36] 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 9f3d2558..52456479 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From 6b1e4b72001622bff7e7fad6862a0c88587da865 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 15 Jan 2026 09:34:40 +0100 Subject: [PATCH 33/36] telegram-chat: early exit with :exit --- telegram-chat.rsc | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/telegram-chat.rsc b/telegram-chat.rsc index c0fa5c16..0daa0714 100644 --- a/telegram-chat.rsc +++ b/telegram-chat.rsc @@ -9,7 +9,6 @@ # 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From 29b2640da7dcbd3ae5950981bcd3cee65d64b713 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:25:51 +0100 Subject: [PATCH 34/36] 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 b8f0134f..7b3111fa 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From 2dce1acd9bc4e9aea53bcfbf3b24041adfc9e1c4 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 19 Jan 2026 15:26:36 +0100 Subject: [PATCH 35/36] 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 215dafa0..7b809f12 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 ExitOnError; $ExitOnError [ :jobname ] $Err; } From 792d584923256073d01746672031c97dce9c4c88 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 20 Jan 2026 10:55:45 +0100 Subject: [PATCH 36/36] global-functions: deprecate $ExitError --- global-functions.d/deprecated.rsc | 14 ++++++++++++++ global-functions.rsc | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/global-functions.d/deprecated.rsc b/global-functions.d/deprecated.rsc index d03c7d36..3a74ebcf 100644 --- a/global-functions.d/deprecated.rsc +++ b/global-functions.d/deprecated.rsc @@ -8,8 +8,22 @@ # deprecated global functions # https://rsc.eworm.de/ +:global ExitError; :global HexToNum; +# wrapper for $ExitOnError with additional parameter +:set ExitError do={ + :local ExitOK [ :tostr $1 ]; + :local Name [ :tostr $2 ]; + :local Error [ :tostr $3 ]; + + :global ExitOnError; + + :if ($ExitOK = "false") do={ + $ExitOnError $Name $Error; + } +} + # convert from hex (string) to num :set HexToNum do={ :local Input [ :tostr $1 ]; diff --git a/global-functions.rsc b/global-functions.rsc index 79a7be8a..3237c14f 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -36,7 +36,6 @@ :global DownloadPackage; :global EitherOr; :global EscapeForRegEx; -:global ExitError; :global ExitOnError; :global FetchHuge; :global FetchUserAgentStr; @@ -483,19 +482,6 @@ :return $Return; } -# wrapper for $ExitOnError with additional parameter -:set ExitError do={ - :local ExitOK [ :tostr $1 ]; - :local Name [ :tostr $2 ]; - :local Error [ :tostr $3 ]; - - :global ExitOnError; - - :if ($ExitOK = "false") do={ - $ExitOnError $Name $Error; - } -} - # simple macro to print error message on unintentional error :set ExitOnError do={ :local Name [ :tostr $1 ];