diff --git a/accesslist-duplicates.capsman.rsc b/accesslist-duplicates.capsman.rsc index 9ea5c305..c7784f3b 100644 --- a/accesslist-duplicates.capsman.rsc +++ b/accesslist-duplicates.capsman.rsc @@ -10,6 +10,7 @@ # # !! 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,5 +33,5 @@ :set ($Seen->$Mac) 1; } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/accesslist-duplicates.local.rsc b/accesslist-duplicates.local.rsc index 0d62a19e..0eee485b 100644 --- a/accesslist-duplicates.local.rsc +++ b/accesslist-duplicates.local.rsc @@ -10,6 +10,7 @@ # # !! 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,5 +33,5 @@ :set ($Seen->$Mac) 1; } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/accesslist-duplicates.template.rsc b/accesslist-duplicates.template.rsc index 49a0308e..e780a475 100644 --- a/accesslist-duplicates.template.rsc +++ b/accesslist-duplicates.template.rsc @@ -11,6 +11,7 @@ # !! 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) \ @@ -41,5 +42,5 @@ :set ($Seen->$Mac) 1; } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/accesslist-duplicates.wifi.rsc b/accesslist-duplicates.wifi.rsc index ca0630c9..c0a8b4f9 100644 --- a/accesslist-duplicates.wifi.rsc +++ b/accesslist-duplicates.wifi.rsc @@ -10,6 +10,7 @@ # # !! 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,5 +33,5 @@ :set ($Seen->$Mac) 1; } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/backup-cloud.rsc b/backup-cloud.rsc index b6aeb6fc..e5f25d34 100644 --- a/backup-cloud.rsc +++ b/backup-cloud.rsc @@ -9,6 +9,7 @@ # 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) \ @@ -35,13 +36,15 @@ :if ([ $ScriptLock $ScriptName ] = false) do={ :set PackagesUpdateBackupFailure true; - :exit; + :set ExitOK true; + :error false; } :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; - :exit; + :set ExitOK true; + :error false; } $WaitFullyConnected; @@ -52,7 +55,8 @@ :if ([ $MkDir ("tmpfs/backup-cloud") ] = false) do={ $LogPrint error $ScriptName ("Failed creating directory!"); - :exit; + :set ExitOK true; + :error false; } :local I 5; @@ -96,5 +100,5 @@ } $RmDir "tmpfs/backup-cloud"; } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/backup-email.rsc b/backup-email.rsc index f26313ec..c12942a2 100644 --- a/backup-email.rsc +++ b/backup-email.rsc @@ -9,6 +9,7 @@ # 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) \ @@ -40,24 +41,28 @@ :if ([ :typeof $SendEMail2 ] = "nothing") do={ $LogPrint error $ScriptName ("The module for sending notifications via e-mail is not installed."); - :exit; + :set ExitOK true; + :error false; } :if ($BackupSendBinary != true && \ $BackupSendExport != true) do={ $LogPrint error $ScriptName ("Configured to send neither backup nor config export."); - :exit; + :set ExitOK true; + :error false; } :if ([ $ScriptLock $ScriptName ] = false) do={ :set PackagesUpdateBackupFailure true; - :exit; + :set ExitOK true; + :error false; } :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; - :exit; + :set ExitOK true; + :error false; } $WaitFullyConnected; @@ -77,7 +82,8 @@ :if ([ $MkDir $DirName ] = false) do={ $LogPrint error $ScriptName ("Failed creating directory!"); - :exit; + :set ExitOK true; + :error false; } # binary backup @@ -133,5 +139,5 @@ } # do not remove the files here, as the mail is still queued! } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/backup-partition.rsc b/backup-partition.rsc index 3aee1834..a9f11a59 100644 --- a/backup-partition.rsc +++ b/backup-partition.rsc @@ -10,6 +10,7 @@ # 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) \ @@ -44,19 +45,22 @@ :if ([ $ScriptLock $ScriptName ] = false) do={ :set PackagesUpdateBackupFailure true; - :exit; + :set ExitOK true; + :error false; } :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; - :exit; + :set ExitOK true; + :error false; } :if ([ :len [ /partitions/find ] ] < 2) do={ $LogPrint error $ScriptName ("Device does not have a fallback partition."); :set PackagesUpdateBackupFailure true; - :exit; + :set ExitOK true; + :error false; } :local ActiveRunning [ /partitions/find where active running ]; @@ -64,7 +68,8 @@ :if ([ :len $ActiveRunning ] < 1) do={ $LogPrint error $ScriptName ("Device is not running from active partition."); :set PackagesUpdateBackupFailure true; - :exit; + :set ExitOK true; + :error false; } :local FallbackToName [ /partitions/get $ActiveRunning fallback-to ]; @@ -73,7 +78,8 @@ :if ([ :len $FallbackTo ] < 1) do={ $LogPrint error $ScriptName ("There is no inactive partition named '" . $FallbackToName . "'."); :set PackagesUpdateBackupFailure true; - :exit; + :set ExitOK true; + :error false; } :if ([ /partitions/get $ActiveRunning version ] != [ /partitions/get $FallbackTo version]) do={ @@ -82,7 +88,8 @@ :if (([ /terminal/inkey timeout=60 ] % 32) = 25) do={ :if ([ $CopyTo $ScriptName $FallbackTo $FallbackToName ] = false) do={ :set PackagesUpdateBackupFailure true; - :exit; + :set ExitOK true; + :error false; } } } else={ @@ -94,7 +101,8 @@ ($NumInstalled & $BitMask) != ($NumLatest & $BitMask)) do={ :if ([ $CopyTo $ScriptName $FallbackTo $FallbackToName ] = false) do={ :set PackagesUpdateBackupFailure true; - :exit; + :set ExitOK true; + :error false; } } } @@ -112,8 +120,9 @@ $LogPrint error $ScriptName ("Failed saving configuration to partition '" . \ $FallbackToName . "': " . $Err); :set PackagesUpdateBackupFailure true; - :exit; + :set ExitOK true; + :error false; } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/backup-upload.rsc b/backup-upload.rsc index e8b37351..cae67bfa 100644 --- a/backup-upload.rsc +++ b/backup-upload.rsc @@ -10,6 +10,7 @@ # 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) \ @@ -46,18 +47,21 @@ :if ($BackupSendBinary != true && \ $BackupSendExport != true) do={ $LogPrint error $ScriptName ("Configured to send neither backup nor config export."); - :exit; + :set ExitOK true; + :error false; } :if ([ $ScriptLock $ScriptName ] = false) do={ :set PackagesUpdateBackupFailure true; - :exit; + :set ExitOK true; + :error false; } :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; - :exit; + :set ExitOK true; + :error false; } $WaitFullyConnected; @@ -77,7 +81,8 @@ :if ([ $MkDir $DirName ] = false) do={ $LogPrint error $ScriptName ("Failed creating directory!"); - :exit; + :set ExitOK true; + :error false; } # binary backup @@ -169,5 +174,5 @@ } $RmDir $DirName; } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/capsman-download-packages.capsman.rsc b/capsman-download-packages.capsman.rsc index 849f6a4b..838f41b9 100644 --- a/capsman-download-packages.capsman.rsc +++ b/capsman-download-packages.capsman.rsc @@ -11,6 +11,7 @@ # # !! 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,7 +28,8 @@ :global WaitFullyConnected; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } $WaitFullyConnected; @@ -37,14 +39,16 @@ :if ([ :len $PackagePath ] = 0) do={ $LogPrint warning $ScriptName ("The CAPsMAN package path is not defined, can not download packages."); - :exit; + :set ExitOK true; + :error false; } :if ([ $FileGet $PackagePath ] = false) do={ :if ([ $MkDir $PackagePath ] = false) do={ $LogPrint warning $ScriptName ("Creating directory at CAPsMAN package path (" . \ $PackagePath . ") failed!"); - :exit; + :set ExitOK true; + :error false; } $LogPrint info $ScriptName ("Created directory at CAPsMAN package path (" . $PackagePath . \ "). Please place your packages!"); @@ -85,5 +89,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/capsman-download-packages.template.rsc b/capsman-download-packages.template.rsc index 1d47d318..1d31eb5a 100644 --- a/capsman-download-packages.template.rsc +++ b/capsman-download-packages.template.rsc @@ -12,6 +12,7 @@ # !! 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,7 +29,8 @@ :global WaitFullyConnected; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } $WaitFullyConnected; @@ -39,14 +41,16 @@ :if ([ :len $PackagePath ] = 0) do={ $LogPrint warning $ScriptName ("The CAPsMAN package path is not defined, can not download packages."); - :exit; + :set ExitOK true; + :error false; } :if ([ $FileGet $PackagePath ] = false) do={ :if ([ $MkDir $PackagePath ] = false) do={ $LogPrint warning $ScriptName ("Creating directory at CAPsMAN package path (" . \ $PackagePath . ") failed!"); - :exit; + :set ExitOK true; + :error false; } $LogPrint info $ScriptName ("Created directory at CAPsMAN package path (" . $PackagePath . \ "). Please place your packages!"); @@ -96,5 +100,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/capsman-download-packages.wifi.rsc b/capsman-download-packages.wifi.rsc index 9a0aaa57..242bb0c8 100644 --- a/capsman-download-packages.wifi.rsc +++ b/capsman-download-packages.wifi.rsc @@ -11,6 +11,7 @@ # # !! 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,7 +28,8 @@ :global WaitFullyConnected; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } $WaitFullyConnected; @@ -37,14 +39,16 @@ :if ([ :len $PackagePath ] = 0) do={ $LogPrint warning $ScriptName ("The CAPsMAN package path is not defined, can not download packages."); - :exit; + :set ExitOK true; + :error false; } :if ([ $FileGet $PackagePath ] = false) do={ :if ([ $MkDir $PackagePath ] = false) do={ $LogPrint warning $ScriptName ("Creating directory at CAPsMAN package path (" . \ $PackagePath . ") failed!"); - :exit; + :set ExitOK true; + :error false; } $LogPrint info $ScriptName ("Created directory at CAPsMAN package path (" . $PackagePath . \ "). Please place your packages!"); @@ -87,5 +91,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/capsman-rolling-upgrade.capsman.rsc b/capsman-rolling-upgrade.capsman.rsc index 948e9449..bb1b17b1 100644 --- a/capsman-rolling-upgrade.capsman.rsc +++ b/capsman-rolling-upgrade.capsman.rsc @@ -12,6 +12,7 @@ # # !! 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,7 +23,8 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :local InstalledVersion [ /system/package/update/get installed-version ]; @@ -44,5 +46,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/capsman-rolling-upgrade.template.rsc b/capsman-rolling-upgrade.template.rsc index 3e769bba..919765a0 100644 --- a/capsman-rolling-upgrade.template.rsc +++ b/capsman-rolling-upgrade.template.rsc @@ -13,6 +13,7 @@ # !! 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,7 +24,8 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :local InstalledVersion [ /system/package/update/get installed-version ]; @@ -52,5 +54,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/capsman-rolling-upgrade.wifi.rsc b/capsman-rolling-upgrade.wifi.rsc index c49cf376..b0c9d034 100644 --- a/capsman-rolling-upgrade.wifi.rsc +++ b/capsman-rolling-upgrade.wifi.rsc @@ -12,6 +12,7 @@ # # !! 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,7 +23,8 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :local InstalledVersion [ /system/package/update/get installed-version ]; @@ -45,5 +47,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/certificate-renew-issued.rsc b/certificate-renew-issued.rsc index a0a78d87..fc8bff32 100644 --- a/certificate-renew-issued.rsc +++ b/certificate-renew-issued.rsc @@ -8,6 +8,7 @@ # 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) \ @@ -21,7 +22,8 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :foreach Cert in=[ /certificate/find where issued expires-after<3w ] do={ @@ -46,5 +48,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/check-certificates.rsc b/check-certificates.rsc index 9c350947..f54d3259 100644 --- a/check-certificates.rsc +++ b/check-certificates.rsc @@ -9,6 +9,7 @@ # 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) \ @@ -148,7 +149,8 @@ } :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } $WaitFullyConnected; @@ -247,5 +249,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/check-health.rsc b/check-health.rsc index f0f2909f..eea31701 100644 --- a/check-health.rsc +++ b/check-health.rsc @@ -8,6 +8,7 @@ # 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) \ @@ -36,7 +37,8 @@ } :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :local Resource [ /system/resource/get ]; @@ -75,7 +77,8 @@ :local Plugins [ /system/script/find where name~"^check-health\\.d/." ]; :if ([ :len $Plugins ] = 0) do={ $LogPrint debug $ScriptName ("No plugins installed."); - :exit; + :set ExitOK true; + :error true; } :global CheckHealthPlugins ({}); @@ -103,5 +106,5 @@ :set CheckHealthPlugins; } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/check-lte-firmware-upgrade.rsc b/check-lte-firmware-upgrade.rsc index 20268f5b..da268e4c 100644 --- a/check-lte-firmware-upgrade.rsc +++ b/check-lte-firmware-upgrade.rsc @@ -8,6 +8,7 @@ # 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) \ @@ -19,7 +20,8 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :if ([ :typeof $SentLteFirmwareUpgradeNotification ] != "array") do={ @@ -101,5 +103,5 @@ $CheckInterface $ScriptName $Interface; } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/check-perpetual-license.rsc b/check-perpetual-license.rsc index 1aa737d8..4326a2f5 100644 --- a/check-perpetual-license.rsc +++ b/check-perpetual-license.rsc @@ -8,6 +8,7 @@ # 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) \ @@ -24,7 +25,8 @@ :global WaitFullyConnected; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } $WaitFullyConnected; @@ -32,7 +34,8 @@ :local License [ /system/license/get ]; :if ([ :typeof ($License->"deadline-at") ] != "str") do={ $LogPrint info $ScriptName ("This device does not have a perpetual license."); - :exit; + :set ExitOK true; + :error true; } :if ([ :len ($License->"next-renewal-at") ] = 0 && ($License->"limited-upgrades") = true) do={ @@ -44,7 +47,8 @@ ", can no longer update RouterOS on " . $Identity . "...") }); :set SentCertificateNotification "expired"; } - :exit; + :set ExitOK true; + :error true; } :if ([ :totime ($License->"deadline-at") ] - 3w < [ :timestamp ]) do={ @@ -56,7 +60,8 @@ ($License->"deadline-at") . " on " . $Identity . "...") }); :set SentCertificateNotification "warning"; } - :exit; + :set ExitOK true; + :error true; } :if ([ :typeof $SentCertificateNotification ] = "str" && \ @@ -69,5 +74,5 @@ :set SentCertificateNotification; } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/check-routeros-update.rsc b/check-routeros-update.rsc index 8be3e917..98edb366 100644 --- a/check-routeros-update.rsc +++ b/check-routeros-update.rsc @@ -9,6 +9,7 @@ # 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) \ @@ -46,12 +47,14 @@ } :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :if ([ :len [ /system/scheduler/find where name="running-from-backup-partition" ] ] > 0) do={ $LogPrint warning $ScriptName ("Running from backup partition, refusing to act."); - :exit; + :set ExitOK true; + :error false; } $WaitFullyConnected; @@ -62,7 +65,8 @@ /system/scheduler/remove "_RebootForUpdate"; } else={ $LogPrint info $ScriptName ("A reboot for update is already scheduled."); - :exit; + :set ExitOK true; + :error false; } } @@ -74,12 +78,14 @@ :if ([ $ScriptFromTerminal $ScriptName ] = true) do={ $LogPrint info $ScriptName ("System is already up to date."); } - :exit; + :set ExitOK true; + :error true; } :if ([ :len ($Update->"latest-version") ] = 0) do={ $LogPrint info $ScriptName ("Received an empty version string from server."); - :exit; + :set ExitOK true; + :error false; } :local NumInstalled [ $VersionToNum ($Update->"installed-version") ]; @@ -91,7 +97,8 @@ :if ($NumLatest < [ $VersionToNum "7.0" ]) do={ $LogPrint warning $ScriptName ("The version '" . ($Update->"latest-version") . "' is not a valid version."); - :exit; + :set ExitOK true; + :error false; } :if ($NumInstalled < $NumLatest) do={ @@ -103,7 +110,8 @@ message=("Installing ALL versions automatically, including " . $Update->"latest-version" . \ "... Updating on " . $Identity . "..."); link=$Link; silent=true }); $DoUpdate $ScriptName; - :exit; + :set ExitOK true; + :error true; } :if ($SafeUpdatePatch = true && $NumInstalledFeature = $NumLatestFeature) do={ @@ -113,7 +121,8 @@ message=("Version " . $Update->"latest-version" . " is a patch update for " . $Update->"channel" . \ ", updating on " . $Identity . "..."); link=$Link; silent=true }); $DoUpdate $ScriptName; - :exit; + :set ExitOK true; + :error true; } :if ($SafeUpdateNeighbor = true) do={ @@ -128,7 +137,8 @@ message=("Seen a neighbor (" . $Neighbor . ") running version " . $Update->"latest-version" . \ " from " . $Update->"channel" . ", updating on " . $Identity . "..."); link=$Link; silent=true }); $DoUpdate $ScriptName; - :exit; + :set ExitOK true; + :error true; } } @@ -149,7 +159,8 @@ message=("Version " . $Update->"latest-version" . " is considered safe for " . $Update->"channel" . \ ", updating on " . $Identity . "..."); link=$Link; silent=true }); $DoUpdate $ScriptName; - :exit; + :set ExitOK true; + :error true; } } @@ -159,14 +170,16 @@ :if (([ /terminal/inkey timeout=60 ] % 32) = 25) do={ /system/package/update/set channel=stable; $LogPrint info $ScriptName ("Switched to channel 'stable', please re-run!"); - :exit; + :set ExitOK true; + :error true; } } :put ("Do you want to install RouterOS version " . $Update->"latest-version" . "? [y/N]"); :if (([ /terminal/inkey timeout=60 ] % 32) = 25) do={ $DoUpdate $ScriptName; - :exit; + :set ExitOK true; + :error true; } else={ :put "Canceled..."; } @@ -175,7 +188,8 @@ :if ($SentRouterosUpdateNotification = $Update->"latest-version") do={ $LogPrint info $ScriptName ("Already sent the RouterOS update notification for version " . \ $Update->"latest-version" . "."); - :exit; + :set ExitOK true; + :error true; } $SendNotification2 ({ origin=$ScriptName; \ @@ -190,7 +204,8 @@ :if ($SentRouterosUpdateNotification = $Update->"latest-version") do={ $LogPrint info $ScriptName ("Already sent the RouterOS downgrade notification for version " . \ $Update->"latest-version" . "."); - :exit; + :set ExitOK true; + :error true; } $SendNotification2 ({ origin=$ScriptName; \ @@ -203,5 +218,5 @@ :set SentRouterosUpdateNotification ($Update->"latest-version"); } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/collect-wireless-mac.capsman.rsc b/collect-wireless-mac.capsman.rsc index 65d56ef0..0ef08b0d 100644 --- a/collect-wireless-mac.capsman.rsc +++ b/collect-wireless-mac.capsman.rsc @@ -11,6 +11,7 @@ # # !! 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) \ @@ -29,7 +30,8 @@ :global SymbolForNotification; :if ([ $ScriptLock $ScriptName 10 ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :if ([ :len [ /caps-man/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={ @@ -94,5 +96,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/collect-wireless-mac.local.rsc b/collect-wireless-mac.local.rsc index 3897f344..263ef164 100644 --- a/collect-wireless-mac.local.rsc +++ b/collect-wireless-mac.local.rsc @@ -11,6 +11,7 @@ # # !! 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) \ @@ -29,7 +30,8 @@ :global SymbolForNotification; :if ([ $ScriptLock $ScriptName 10 ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :if ([ :len [ /interface/wireless/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={ @@ -95,5 +97,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/collect-wireless-mac.template.rsc b/collect-wireless-mac.template.rsc index a9cf82f1..37933250 100644 --- a/collect-wireless-mac.template.rsc +++ b/collect-wireless-mac.template.rsc @@ -12,6 +12,7 @@ # !! 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) \ @@ -30,7 +31,8 @@ :global SymbolForNotification; :if ([ $ScriptLock $ScriptName 10 ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :if ([ :len [ /caps-man/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={ @@ -112,5 +114,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/collect-wireless-mac.wifi.rsc b/collect-wireless-mac.wifi.rsc index 11f4eba2..342351b1 100644 --- a/collect-wireless-mac.wifi.rsc +++ b/collect-wireless-mac.wifi.rsc @@ -11,6 +11,7 @@ # # !! 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) \ @@ -29,7 +30,8 @@ :global SymbolForNotification; :if ([ $ScriptLock $ScriptName 10 ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :if ([ :len [ /interface/wifi/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={ @@ -94,5 +96,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/daily-psk.capsman.rsc b/daily-psk.capsman.rsc index 4043388e..284d4a11 100644 --- a/daily-psk.capsman.rsc +++ b/daily-psk.capsman.rsc @@ -11,6 +11,7 @@ # # !! 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) \ @@ -31,7 +32,8 @@ :global WaitFullyConnected; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } $WaitFullyConnected; @@ -90,5 +92,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/daily-psk.local.rsc b/daily-psk.local.rsc index d6d29055..7a07898c 100644 --- a/daily-psk.local.rsc +++ b/daily-psk.local.rsc @@ -11,6 +11,7 @@ # # !! 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) \ @@ -31,7 +32,8 @@ :global WaitFullyConnected; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } $WaitFullyConnected; @@ -89,5 +91,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/daily-psk.template.rsc b/daily-psk.template.rsc index 1b89d011..5105b63b 100644 --- a/daily-psk.template.rsc +++ b/daily-psk.template.rsc @@ -12,6 +12,7 @@ # !! 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) \ @@ -32,7 +33,8 @@ :global WaitFullyConnected; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } $WaitFullyConnected; @@ -105,5 +107,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/daily-psk.wifi.rsc b/daily-psk.wifi.rsc index c9bfc233..a2df10e4 100644 --- a/daily-psk.wifi.rsc +++ b/daily-psk.wifi.rsc @@ -11,6 +11,7 @@ # # !! 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) \ @@ -31,7 +32,8 @@ :global WaitFullyConnected; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } $WaitFullyConnected; @@ -90,5 +92,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/dhcp-lease-comment.capsman.rsc b/dhcp-lease-comment.capsman.rsc index 2136f643..5427a889 100644 --- a/dhcp-lease-comment.capsman.rsc +++ b/dhcp-lease-comment.capsman.rsc @@ -11,6 +11,7 @@ # # !! 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) \ @@ -21,7 +22,8 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={ @@ -37,5 +39,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/dhcp-lease-comment.local.rsc b/dhcp-lease-comment.local.rsc index d0e077e9..e25305e3 100644 --- a/dhcp-lease-comment.local.rsc +++ b/dhcp-lease-comment.local.rsc @@ -11,6 +11,7 @@ # # !! 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) \ @@ -21,7 +22,8 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={ @@ -37,5 +39,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/dhcp-lease-comment.template.rsc b/dhcp-lease-comment.template.rsc index 3a2d4dc7..3fcf6e01 100644 --- a/dhcp-lease-comment.template.rsc +++ b/dhcp-lease-comment.template.rsc @@ -12,6 +12,7 @@ # !! 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) \ @@ -22,7 +23,8 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={ @@ -42,5 +44,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/dhcp-lease-comment.wifi.rsc b/dhcp-lease-comment.wifi.rsc index c5d3cd4a..6b752bab 100644 --- a/dhcp-lease-comment.wifi.rsc +++ b/dhcp-lease-comment.wifi.rsc @@ -11,6 +11,7 @@ # # !! 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) \ @@ -21,7 +22,8 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={ @@ -37,5 +39,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/dhcp-to-dns.rsc b/dhcp-to-dns.rsc index dfb0399e..8c6ee30b 100644 --- a/dhcp-to-dns.rsc +++ b/dhcp-to-dns.rsc @@ -9,6 +9,7 @@ # 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) \ @@ -27,7 +28,8 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName 10 ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :local Ttl 5m; @@ -124,5 +126,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/firmware-upgrade-reboot.rsc b/firmware-upgrade-reboot.rsc index 0b56db77..93a264fc 100644 --- a/firmware-upgrade-reboot.rsc +++ b/firmware-upgrade-reboot.rsc @@ -8,6 +8,7 @@ # 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) \ @@ -19,18 +20,21 @@ :global VersionToNum; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :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" . "."); - :exit; + :set ExitOK true; + :error true; } :if ([ $VersionToNum ($RouterBoard->"current-firmware") ] > [ $VersionToNum ($RouterBoard->"upgrade-firmware") ]) do={ $LogPrint info $ScriptName ("Different firmware version is available, but it is a downgrade. Ignoring."); - :exit; + :set ExitOK true; + :error true; } :if ([ /system/routerboard/settings/get auto-upgrade ] = false) do={ @@ -52,5 +56,5 @@ $LogPrint info $ScriptName ("Firmware upgrade successful, rebooting."); /system/reboot; } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/fw-addr-lists.rsc b/fw-addr-lists.rsc index 62516f55..a9b3daf4 100644 --- a/fw-addr-lists.rsc +++ b/fw-addr-lists.rsc @@ -8,6 +8,7 @@ # 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) \ @@ -45,7 +46,8 @@ } :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } $WaitFullyConnected; @@ -111,40 +113,41 @@ } else={ :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) ]) ]; + :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; + :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; + :error true; } - :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 ] ]; + :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; + :error true; } - :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; - } + :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; + } + } on-error={ } } } @@ -229,5 +232,5 @@ " - removed: " . [ $HumanReadableNum $CntRemove 1000 ]); } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/global-functions.rsc b/global-functions.rsc index 3fc65fc7..2aad406e 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -474,8 +474,9 @@ # simple macro to print error message on unintentional error :set ExitError do={ - :local Name [ :tostr $1 ]; - :local Error [ :tostr $2 ]; + :local ExitOK [ :tostr $1 ]; + :local Name [ :tostr $2 ]; + :local Error [ :tostr $3 ]; :global IfThenElse; :global LogPrint; @@ -1287,103 +1288,105 @@ } } - :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; + :do { + :if ($ScriptInfo->"ignore" = true) do={ + $LogPrint debug $0 ("Ignoring script '" . $ScriptVal->"name" . "', as requested."); + :error true; } - :if ($ScriptVal->"source" = "#!rsc by RouterOS\n") do={ - $LogPrint warning $0 ("Removing dummy. Typo on installation?"); - /system/script/remove $Script; - :continue; - } + :local CheckSum ($CheckSums->($ScriptVal->"name")); :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."); + [ :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 $SourceNew ] = 0) do={ - $LogPrint debug $0 ("No update for script '" . $ScriptVal->"name" . "'."); - :continue; - } - - :local SourceCRLF [ :tocrlf $SourceNew ]; - :if ($SourceNew = $ScriptVal->"source" || $SourceCRLF = $ScriptVal->"source") do={ - $LogPrint debug $0 ("Script '" . $ScriptVal->"name" . "' did not change."); - :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; - } - - :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 ($ScriptInfo->"certificate") ] > 0) do={ + :if ([ $CertificateAvailable ($ScriptInfo->"certificate") "fetch" ] = false) do={ + $LogPrint warning $0 ("Downloading certificate failed, trying without."); + } } - } - :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; - } + :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={ + :error false; + } - $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 ($ScriptVal->"source" = "#!rsc by RouterOS\n") do={ + $LogPrint warning $0 ("Removing dummy. Typo on installation?"); + /system/script/remove $Script; + :error false; + } + :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; + } + + :if ([ :len $SourceNew ] = 0) do={ + $LogPrint debug $0 ("No update for script '" . $ScriptVal->"name" . "'."); + :error false; + } + + :local SourceCRLF [ :tocrlf $SourceNew ]; + :if ($SourceNew = $ScriptVal->"source" || $SourceCRLF = $ScriptVal->"source") do={ + $LogPrint debug $0 ("Script '" . $ScriptVal->"name" . "' did not change."); + :error false; + } + + :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; + } + + :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; + } + + :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!"); + :error false; + } + + :if ([ $ValidateSyntax $SourceNew ] = false) do={ + $LogPrint warning $0 ("Syntax validation for script '" . $ScriptVal->"name" . "' failed! Ignoring!"); + :error false; + } + + $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; + } + } on-error={ } } :if ($ReloadGlobal = true) do={ @@ -1500,7 +1503,7 @@ :set GlobalConfigMigration; } } do={ - :global ExitError; $ExitError $0 $Err; + :global ExitError; $ExitError false $0 $Err; } } # lock script against multiple invocation @@ -1646,7 +1649,7 @@ $SendNotification2 ({ origin=$0; subject=$1; message=$2; link=$3; silent=$4 }); } do={ - :global ExitError; $ExitError $0 $Err; + :global ExitError; $ExitError false $0 $Err; } } # send notification via NotificationFunctions - expects one array argument diff --git a/gps-track.rsc b/gps-track.rsc index a0e88a29..dae7d521 100644 --- a/gps-track.rsc +++ b/gps-track.rsc @@ -9,6 +9,7 @@ # 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) \ @@ -24,7 +25,8 @@ :global WaitFullyConnected; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } $WaitFullyConnected; @@ -47,5 +49,5 @@ $LogPrint debug $ScriptName ("GPS data not valid."); } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/hotspot-to-wpa-cleanup.capsman.rsc b/hotspot-to-wpa-cleanup.capsman.rsc index 60bd3715..99ff0029 100644 --- a/hotspot-to-wpa-cleanup.capsman.rsc +++ b/hotspot-to-wpa-cleanup.capsman.rsc @@ -12,6 +12,7 @@ # # !! 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) \ @@ -24,7 +25,8 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName 10 ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :local DHCPServers ({}); @@ -74,5 +76,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/hotspot-to-wpa-cleanup.template.rsc b/hotspot-to-wpa-cleanup.template.rsc index 90c3f029..113c1bb2 100644 --- a/hotspot-to-wpa-cleanup.template.rsc +++ b/hotspot-to-wpa-cleanup.template.rsc @@ -13,6 +13,7 @@ # !! 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) \ @@ -25,7 +26,8 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName 10 ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :local DHCPServers ({}); @@ -81,5 +83,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/hotspot-to-wpa-cleanup.wifi.rsc b/hotspot-to-wpa-cleanup.wifi.rsc index 7cf6a1b1..1a7ef364 100644 --- a/hotspot-to-wpa-cleanup.wifi.rsc +++ b/hotspot-to-wpa-cleanup.wifi.rsc @@ -12,6 +12,7 @@ # # !! 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) \ @@ -24,7 +25,8 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName 10 ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :local DHCPServers ({}); @@ -74,5 +76,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/hotspot-to-wpa.capsman.rsc b/hotspot-to-wpa.capsman.rsc index ff3a94b2..0751f8e5 100644 --- a/hotspot-to-wpa.capsman.rsc +++ b/hotspot-to-wpa.capsman.rsc @@ -11,6 +11,7 @@ # # !! 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) \ @@ -26,12 +27,14 @@ :local UserName $username; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :if ([ :typeof $MacAddress ] = "nothing" || [ :typeof $UserName ] = "nothing") do={ $LogPrint error $ScriptName ("This script is supposed to run from hotspot on login."); - :exit; + :set ExitOK true; + :error false; } :local Date [ /system/clock/get date ]; @@ -58,7 +61,8 @@ :if ($Template->"action" = "reject") do={ $LogPrint info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'."); - :exit; + :set ExitOK true; + :error true; } # allow login page to load @@ -97,5 +101,5 @@ :delay 2s; /caps-man/access-list/set $Entry action=accept; } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/hotspot-to-wpa.template.rsc b/hotspot-to-wpa.template.rsc index 3e8c8c03..ba044a09 100644 --- a/hotspot-to-wpa.template.rsc +++ b/hotspot-to-wpa.template.rsc @@ -12,6 +12,7 @@ # !! 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) \ @@ -27,12 +28,14 @@ :local UserName $username; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :if ([ :typeof $MacAddress ] = "nothing" || [ :typeof $UserName ] = "nothing") do={ $LogPrint error $ScriptName ("This script is supposed to run from hotspot on login."); - :exit; + :set ExitOK true; + :error false; } :local Date [ /system/clock/get date ]; @@ -65,7 +68,8 @@ :if ($Template->"action" = "reject") do={ $LogPrint info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'."); - :exit; + :set ExitOK true; + :error true; } # allow login page to load @@ -117,5 +121,5 @@ /caps-man/access-list/set $Entry action=accept; /interface/wifi/access-list/set $Entry action=accept; } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/hotspot-to-wpa.wifi.rsc b/hotspot-to-wpa.wifi.rsc index b3b1b79b..569d7827 100644 --- a/hotspot-to-wpa.wifi.rsc +++ b/hotspot-to-wpa.wifi.rsc @@ -11,6 +11,7 @@ # # !! 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) \ @@ -26,12 +27,14 @@ :local UserName $username; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :if ([ :typeof $MacAddress ] = "nothing" || [ :typeof $UserName ] = "nothing") do={ $LogPrint error $ScriptName ("This script is supposed to run from hotspot on login."); - :exit; + :set ExitOK true; + :error false; } :local Date [ /system/clock/get date ]; @@ -58,7 +61,8 @@ :if ($Template->"action" = "reject") do={ $LogPrint info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'."); - :exit; + :set ExitOK true; + :error true; } # allow login page to load @@ -94,5 +98,5 @@ :delay 2s; /interface/wifi/access-list/set $Entry action=accept; } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/ipsec-to-dns.rsc b/ipsec-to-dns.rsc index dabed25c..02391fe8 100644 --- a/ipsec-to-dns.rsc +++ b/ipsec-to-dns.rsc @@ -9,6 +9,7 @@ # 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) \ @@ -27,7 +28,8 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :local Zone \ @@ -78,5 +80,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/ipv6-update.rsc b/ipv6-update.rsc index dc7000ca..a4da6516 100644 --- a/ipv6-update.rsc +++ b/ipv6-update.rsc @@ -8,6 +8,7 @@ # 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) \ @@ -24,22 +25,26 @@ :local PdValid $"pd-valid"; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :if ([ :typeof $NaAddress ] = "str") do={ $LogPrint info $ScriptName ("An address (" . $NaAddress . ") was acquired, not a prefix. Ignoring."); - :exit; + :set ExitOK true; + :error false; } :if ([ :typeof $PdPrefix ] = "nothing" || [ :typeof $PdValid ] = "nothing") do={ $LogPrint error $ScriptName ("This script is supposed to run from ipv6 dhcp-client."); - :exit; + :set ExitOK true; + :error false; } :if ($PdValid != 1) do={ $LogPrint info $ScriptName ("The prefix " . $PdPrefix . " is no longer valid. Ignoring."); - :exit; + :set ExitOK true; + :error false; } :local Pool [ /ipv6/pool/get [ find where prefix=$PdPrefix ] name ]; @@ -98,5 +103,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/lease-script.rsc b/lease-script.rsc index ccd6a888..1b7935b8 100644 --- a/lease-script.rsc +++ b/lease-script.rsc @@ -8,6 +8,7 @@ # 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) \ @@ -25,19 +26,22 @@ [ :typeof $leaseServerName ] = "nothing" || \ [ :typeof $leaseBound ] = "nothing") do={ $LogPrint error $ScriptName ("This script is supposed to run from ip dhcp-server."); - :exit; + :set ExitOK true; + :error false; } $LogPrint debug $ScriptName ("DHCP Server " . $leaseServerName . " " . [ $IfThenElse ($leaseBound = 0) \ "de" "" ] . "assigned lease " . $leaseActIP . " to " . $leaseActMAC); :if ([ $ScriptLock $ScriptName 10 ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :if ([ :len [ /system/script/job/find where script=$ScriptName ] ] > 1) do={ $LogPrint debug $ScriptName ("More invocations are waiting, exiting early."); - :exit; + :set ExitOK true; + :error true; } :local RunOrder ({}); @@ -57,5 +61,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/log-forward.rsc b/log-forward.rsc index 97a0bff3..e89fdc18 100644 --- a/log-forward.rsc +++ b/log-forward.rsc @@ -8,6 +8,7 @@ # 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) \ @@ -32,7 +33,8 @@ :global SymbolForNotification; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :if ([ :typeof $LogForwardLast ] = "nothing") do={ @@ -46,7 +48,8 @@ :if ($LogForwardRateLimit > 30) do={ :set LogForwardRateLimit ($LogForwardRateLimit - 1); $LogPrint info $ScriptName ("Rate limit in action, not forwarding logs, if any!"); - :exit; + :set ExitOK true; + :error false; } :local Count 0; @@ -108,5 +111,5 @@ :set LogForwardLast $Max; } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/mod/bridge-port-to.rsc b/mod/bridge-port-to.rsc index 1046c80d..b14926bb 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 $0 $Err; + :global ExitError; $ExitError false $0 $Err; } } diff --git a/mod/bridge-port-vlan.rsc b/mod/bridge-port-vlan.rsc index 845bf09c..3d9567a9 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 $0 $Err; + :global ExitError; $ExitError false $0 $Err; } } diff --git a/mod/inspectvar.rsc b/mod/inspectvar.rsc index ce7fc780..d8c0bc79 100644 --- a/mod/inspectvar.rsc +++ b/mod/inspectvar.rsc @@ -17,7 +17,7 @@ :put [ :tocrlf [ $InspectVarReturn $1 ] ]; } do={ - :global ExitError; $ExitError $0 $Err; + :global ExitError; $ExitError false $0 $Err; } } # inspect variable and return formatted string diff --git a/mod/ipcalc.rsc b/mod/ipcalc.rsc index bd1a330e..a485468e 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 $0 $Err; + :global ExitError; $ExitError false $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 d28387f7..1ca76f62 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 $0 $Err; + :global ExitError; $ExitError false $0 $Err; } } # generate filter for log-forward @@ -274,7 +274,7 @@ $SendEMail2 ({ origin=$0; subject=$1; message=$2; link=$3 }); } do={ - :global ExitError; $ExitError $0 $Err; + :global ExitError; $ExitError false $0 $Err; } } # send notification via e-mail - expects one array argument diff --git a/mod/notification-gotify.rsc b/mod/notification-gotify.rsc index 121c1a9b..677d993c 100644 --- a/mod/notification-gotify.rsc +++ b/mod/notification-gotify.rsc @@ -54,7 +54,7 @@ :set GotifyQueue; } } do={ - :global ExitError; $ExitError $0 $Err; + :global ExitError; $ExitError false $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 $0 $Err; + :global ExitError; $ExitError false $0 $Err; } } # send notification via Gotify - expects one array argument diff --git a/mod/notification-matrix.rsc b/mod/notification-matrix.rsc index 80518a58..b78b1132 100644 --- a/mod/notification-matrix.rsc +++ b/mod/notification-matrix.rsc @@ -59,7 +59,7 @@ :set MatrixQueue; } } do={ - :global ExitError; $ExitError $0 $Err; + :global ExitError; $ExitError false $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 $0 $Err; + :global ExitError; $ExitError false $0 $Err; } } # send notification via Matrix - expects one array argument diff --git a/mod/notification-ntfy.rsc b/mod/notification-ntfy.rsc index e43de34a..ac1792d4 100644 --- a/mod/notification-ntfy.rsc +++ b/mod/notification-ntfy.rsc @@ -53,7 +53,7 @@ :set NtfyQueue; } } do={ - :global ExitError; $ExitError $0 $Err; + :global ExitError; $ExitError false $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 $0 $Err; + :global ExitError; $ExitError false $0 $Err; } } # send notification via ntfy - expects one array argument diff --git a/mod/notification-telegram.rsc b/mod/notification-telegram.rsc index 79012bbc..9e9ae57e 100644 --- a/mod/notification-telegram.rsc +++ b/mod/notification-telegram.rsc @@ -62,7 +62,7 @@ :set TelegramQueue; } } do={ - :global ExitError; $ExitError $0 $Err; + :global ExitError; $ExitError false $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 $0 $Err; + :global ExitError; $ExitError false $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 $0 $Err; + :global ExitError; $ExitError false $0 $Err; } } # send notification via telegram - expects one array argument diff --git a/mod/scriptrunonce.rsc b/mod/scriptrunonce.rsc index fb2bb429..598c7602 100644 --- a/mod/scriptrunonce.rsc +++ b/mod/scriptrunonce.rsc @@ -52,5 +52,5 @@ :return true; } } do={ - :global ExitError; $ExitError $0 $Err; + :global ExitError; $ExitError false $0 $Err; } } diff --git a/mod/ssh-keys-import.rsc b/mod/ssh-keys-import.rsc index 36ca9f8a..f858a545 100644 --- a/mod/ssh-keys-import.rsc +++ b/mod/ssh-keys-import.rsc @@ -67,7 +67,7 @@ :return false; } } do={ - :global ExitError; $ExitError $0 $Err; + :global ExitError; $ExitError false $0 $Err; } } # import keys from a file @@ -109,5 +109,5 @@ } } } do={ - :global ExitError; $ExitError $0 $Err; + :global ExitError; $ExitError false $0 $Err; } } diff --git a/mode-button.rsc b/mode-button.rsc index 4ea82c3a..81bdc05a 100644 --- a/mode-button.rsc +++ b/mode-button.rsc @@ -9,6 +9,7 @@ # 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) \ @@ -82,7 +83,7 @@ $LogPrint info $FuncName ("No action defined for " . $Count . " mode-button presses."); } } do={ - :global ExitError; $ExitError $0 $Err; + :global ExitError; $ExitError false $0 $Err; } } /system/scheduler/add name="_ModeButtonScheduler" \ on-event=":global ModeButtonScheduler; \$ModeButtonScheduler;" interval=3s; @@ -91,5 +92,5 @@ /system/scheduler/set $Scheduler start-time=[ /system/clock/get time ]; } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/netwatch-dns.rsc b/netwatch-dns.rsc index 99dc8a2a..7af659e6 100644 --- a/netwatch-dns.rsc +++ b/netwatch-dns.rsc @@ -139,5 +139,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError true [ :jobname ] $Err; } diff --git a/netwatch-notify.rsc b/netwatch-notify.rsc index e25b30d7..46a10ee0 100644 --- a/netwatch-notify.rsc +++ b/netwatch-notify.rsc @@ -8,6 +8,7 @@ # 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) \ @@ -79,7 +80,8 @@ } :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :local ScriptFromTerminalCached [ $ScriptFromTerminal $ScriptName ]; @@ -223,5 +225,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/ospf-to-leds.rsc b/ospf-to-leds.rsc index c2a38992..73a70c8b 100644 --- a/ospf-to-leds.rsc +++ b/ospf-to-leds.rsc @@ -8,6 +8,7 @@ # 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) \ @@ -19,7 +20,8 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :foreach Instance in=[ /routing/ospf/instance/find where comment~"^ospf-to-leds," ] do={ @@ -43,5 +45,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/packages-update.rsc b/packages-update.rsc index a0d40192..960e07ca 100644 --- a/packages-update.rsc +++ b/packages-update.rsc @@ -9,6 +9,7 @@ # 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) \ @@ -58,24 +59,28 @@ } :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :if ([ :len [ /system/scheduler/find where name="running-from-backup-partition" ] ] > 0) do={ $LogPrint warning $ScriptName ("Running from backup partition, refusing to act."); - :exit; + :set ExitOK true; + :error false; } :local Update [ /system/package/update/get ]; :if ([ :typeof ($Update->"latest-version") ] = "nothing") do={ $LogPrint warning $ScriptName ("Latest version is not known."); - :exit; + :set ExitOK true; + :error false; } :if ($Update->"installed-version" = $Update->"latest-version") do={ $LogPrint info $ScriptName ("Version " . $Update->"latest-version" . " is already installed."); - :exit; + :set ExitOK true; + :error true; } :local RunOrder ({}); @@ -106,11 +111,13 @@ $LogPrint info $ScriptName ("User requested to continue anyway."); } else={ $LogPrint info $ScriptName ("Canceled update..."); - :exit; + :set ExitOK true; + :error false; } } else={ $LogPrint warning $ScriptName ("Canceled non-interactive update."); - :exit; + :set ExitOK true; + :error false; } } } @@ -129,7 +136,8 @@ } } else={ $LogPrint warning $ScriptName ("Not installing downgrade automatically."); - :exit; + :set ExitOK true; + :error false; } } @@ -137,7 +145,8 @@ :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."); - :exit; + :set ExitOK true; + :error false; } } @@ -151,12 +160,14 @@ :put "Do you want to (s)chedule reboot or (r)eboot now? [s/R]"; :if (([ /terminal/inkey timeout=60 ] % 32) = 19) do={ $Schedule $ScriptName; - :exit; + :set ExitOK true; + :error true; } } else={ :if ($PackagesUpdateDeferReboot = true || [ :totime $PackagesUpdateDeferReboot ] >= 1d) do={ $Schedule $ScriptName; - :exit; + :set ExitOK true; + :error true; } } @@ -164,5 +175,5 @@ :delay 1s; /system/reboot; } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/ppp-on-up.rsc b/ppp-on-up.rsc index 6cc0755e..231d3d2d 100644 --- a/ppp-on-up.rsc +++ b/ppp-on-up.rsc @@ -8,6 +8,7 @@ # 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) \ @@ -20,7 +21,8 @@ :if ([ :typeof $Interface ] = "nothing") do={ $LogPrint error $ScriptName ("This script is supposed to run from ppp on-up script hook."); - :exit; + :set ExitOK true; + :error false; } :local IntName [ /interface/get $Interface name ]; @@ -38,5 +40,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/sms-action.rsc b/sms-action.rsc index c2bc5829..9750e967 100644 --- a/sms-action.rsc +++ b/sms-action.rsc @@ -8,6 +8,7 @@ # 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) \ @@ -23,7 +24,8 @@ :if ([ :typeof $Action ] = "nothing") do={ $LogPrint error $ScriptName ("This script is supposed to run from SMS hook with action=..."); - :exit; + :set ExitOK true; + :error false; } :local Code ($SmsAction->$Action); @@ -35,5 +37,5 @@ $LogPrint warning $ScriptName ("The code for action '" . $Action . "' failed syntax validation!"); } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/sms-forward.rsc b/sms-forward.rsc index 231e22a2..d4570ea1 100644 --- a/sms-forward.rsc +++ b/sms-forward.rsc @@ -9,6 +9,7 @@ # 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) \ @@ -28,12 +29,14 @@ :global WaitFullyConnected; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :if ([ /tool/sms/get receive-enabled ] = false) do={ $LogPrintOnce warning $ScriptName ("Receiving of SMS is not enabled."); - :exit; + :set ExitOK true; + :error false; } $WaitFullyConnected; @@ -42,7 +45,8 @@ :if ([ /interface/lte/get ($Settings->"port") running ] != true) do={ $LogPrint info $ScriptName ("The LTE interface is not in running state, skipping."); - :exit; + :set ExitOK true; + :error true; } # forward SMS in a loop @@ -103,5 +107,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/telegram-chat.rsc b/telegram-chat.rsc index aa5a001c..5b15227e 100644 --- a/telegram-chat.rsc +++ b/telegram-chat.rsc @@ -191,5 +191,5 @@ :set TelegramChatOffset ([ :pick $TelegramChatOffset 1 3 ], \ [ $IfThenElse ($UpdateID >= $TelegramChatOffset->2) ($UpdateID + 1) ($TelegramChatOffset->2) ]); } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError true [ :jobname ] $Err; } diff --git a/update-gre-address.rsc b/update-gre-address.rsc index 58c6cc20..15cfc143 100644 --- a/update-gre-address.rsc +++ b/update-gre-address.rsc @@ -9,6 +9,7 @@ # 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) \ @@ -20,7 +21,8 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } /interface/gre/set remote-address=0.0.0.0 disabled=yes [ find where !running !disabled ]; @@ -40,5 +42,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; } diff --git a/update-tunnelbroker.rsc b/update-tunnelbroker.rsc index e669eb13..f9eaf247 100644 --- a/update-tunnelbroker.rsc +++ b/update-tunnelbroker.rsc @@ -11,6 +11,7 @@ # 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) \ @@ -23,12 +24,14 @@ :global ScriptLock; :if ([ $ScriptLock $ScriptName ] = false) do={ - :exit; + :set ExitOK true; + :error false; } :if ([ $CertificateAvailable "Starfield Root Certificate Authority - G2" "fetch" ] = false) do={ $LogPrint error $ScriptName ("Downloading required certificate failed."); - :exit; + :set ExitOK true; + :error false; } :foreach Interface in=[ /interface/6to4/find where comment~"^tunnelbroker" !disabled ] do={ @@ -51,7 +54,8 @@ :if (!($Data ~ "^(good|nochg) ")) do={ $LogPrint error $ScriptName ("Failed sending the local address to tunnelbroker or unexpected response!"); - :exit; + :set ExitOK true; + :error false; } :local PublicAddress [ :pick $Data ([ :find $Data " " ] + 1) [ :find $Data "\n" ] ]; @@ -66,5 +70,5 @@ } } } do={ - :global ExitError; $ExitError [ :jobname ] $Err; + :global ExitError; $ExitError $ExitOK [ :jobname ] $Err; }