Merge branch 'early-exit-with-exit' into next

This commit is contained in:
Christian Hesse 2026-01-19 20:59:14 +01:00
commit 5ec47c8e6a
69 changed files with 207 additions and 386 deletions

View file

@ -32,5 +32,5 @@
:set ($Seen->$Mac) 1; :set ($Seen->$Mac) 1;
} }
} do={ } do={
:global ExitError; $ExitError false [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -32,5 +32,5 @@
:set ($Seen->$Mac) 1; :set ($Seen->$Mac) 1;
} }
} do={ } do={
:global ExitError; $ExitError false [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -41,5 +41,5 @@
:set ($Seen->$Mac) 1; :set ($Seen->$Mac) 1;
} }
} do={ } do={
:global ExitError; $ExitError false [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -32,5 +32,5 @@
:set ($Seen->$Mac) 1; :set ($Seen->$Mac) 1;
} }
} do={ } do={
:global ExitError; $ExitError false [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -9,7 +9,6 @@
# upload backup to MikroTik cloud # upload backup to MikroTik cloud
# https://rsc.eworm.de/doc/backup-cloud.md # https://rsc.eworm.de/doc/backup-cloud.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -36,15 +35,13 @@
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set PackagesUpdateBackupFailure true; :set PackagesUpdateBackupFailure true;
:set ExitOK true; :exit;
:error false;
} }
:if ([ :len [ /system/scheduler/find where name="running-from-backup-partition" ] ] > 0) do={ :if ([ :len [ /system/scheduler/find where name="running-from-backup-partition" ] ] > 0) do={
$LogPrint warning $ScriptName ("Running from backup partition, refusing to act."); $LogPrint warning $ScriptName ("Running from backup partition, refusing to act.");
:set PackagesUpdateBackupFailure true; :set PackagesUpdateBackupFailure true;
:set ExitOK true; :exit;
:error false;
} }
$WaitFullyConnected; $WaitFullyConnected;
@ -55,8 +52,7 @@
:if ([ $MkDir ("tmpfs/backup-cloud") ] = false) do={ :if ([ $MkDir ("tmpfs/backup-cloud") ] = false) do={
$LogPrint error $ScriptName ("Failed creating directory!"); $LogPrint error $ScriptName ("Failed creating directory!");
:set ExitOK true; :exit;
:error false;
} }
:local I 5; :local I 5;
@ -100,5 +96,5 @@
} }
$RmDir "tmpfs/backup-cloud"; $RmDir "tmpfs/backup-cloud";
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -9,7 +9,6 @@
# create and email backup and config file # create and email backup and config file
# https://rsc.eworm.de/doc/backup-email.md # https://rsc.eworm.de/doc/backup-email.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -41,28 +40,24 @@
:if ([ :typeof $SendEMail2 ] = "nothing") do={ :if ([ :typeof $SendEMail2 ] = "nothing") do={
$LogPrint error $ScriptName ("The module for sending notifications via e-mail is not installed."); $LogPrint error $ScriptName ("The module for sending notifications via e-mail is not installed.");
:set ExitOK true; :exit;
:error false;
} }
:if ($BackupSendBinary != true && \ :if ($BackupSendBinary != true && \
$BackupSendExport != true) do={ $BackupSendExport != true) do={
$LogPrint error $ScriptName ("Configured to send neither backup nor config export."); $LogPrint error $ScriptName ("Configured to send neither backup nor config export.");
:set ExitOK true; :exit;
:error false;
} }
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set PackagesUpdateBackupFailure true; :set PackagesUpdateBackupFailure true;
:set ExitOK true; :exit;
:error false;
} }
:if ([ :len [ /system/scheduler/find where name="running-from-backup-partition" ] ] > 0) do={ :if ([ :len [ /system/scheduler/find where name="running-from-backup-partition" ] ] > 0) do={
$LogPrint warning $ScriptName ("Running from backup partition, refusing to act."); $LogPrint warning $ScriptName ("Running from backup partition, refusing to act.");
:set PackagesUpdateBackupFailure true; :set PackagesUpdateBackupFailure true;
:set ExitOK true; :exit;
:error false;
} }
$WaitFullyConnected; $WaitFullyConnected;
@ -82,8 +77,7 @@
:if ([ $MkDir $DirName ] = false) do={ :if ([ $MkDir $DirName ] = false) do={
$LogPrint error $ScriptName ("Failed creating directory!"); $LogPrint error $ScriptName ("Failed creating directory!");
:set ExitOK true; :exit;
:error false;
} }
# binary backup # binary backup
@ -139,5 +133,5 @@
} }
# do not remove the files here, as the mail is still queued! # do not remove the files here, as the mail is still queued!
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -10,7 +10,6 @@
# save configuration to fallback partition # save configuration to fallback partition
# https://rsc.eworm.de/doc/backup-partition.md # https://rsc.eworm.de/doc/backup-partition.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -45,22 +44,19 @@
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set PackagesUpdateBackupFailure true; :set PackagesUpdateBackupFailure true;
:set ExitOK true; :exit;
:error false;
} }
:if ([ :len [ /system/scheduler/find where name="running-from-backup-partition" ] ] > 0) do={ :if ([ :len [ /system/scheduler/find where name="running-from-backup-partition" ] ] > 0) do={
$LogPrint warning $ScriptName ("Running from backup partition, refusing to act."); $LogPrint warning $ScriptName ("Running from backup partition, refusing to act.");
:set PackagesUpdateBackupFailure true; :set PackagesUpdateBackupFailure true;
:set ExitOK true; :exit;
:error false;
} }
:if ([ :len [ /partitions/find ] ] < 2) do={ :if ([ :len [ /partitions/find ] ] < 2) do={
$LogPrint error $ScriptName ("Device does not have a fallback partition."); $LogPrint error $ScriptName ("Device does not have a fallback partition.");
:set PackagesUpdateBackupFailure true; :set PackagesUpdateBackupFailure true;
:set ExitOK true; :exit;
:error false;
} }
:local ActiveRunning [ /partitions/find where active running ]; :local ActiveRunning [ /partitions/find where active running ];
@ -68,8 +64,7 @@
:if ([ :len $ActiveRunning ] < 1) do={ :if ([ :len $ActiveRunning ] < 1) do={
$LogPrint error $ScriptName ("Device is not running from active partition."); $LogPrint error $ScriptName ("Device is not running from active partition.");
:set PackagesUpdateBackupFailure true; :set PackagesUpdateBackupFailure true;
:set ExitOK true; :exit;
:error false;
} }
:local FallbackToName [ /partitions/get $ActiveRunning fallback-to ]; :local FallbackToName [ /partitions/get $ActiveRunning fallback-to ];
@ -78,8 +73,7 @@
:if ([ :len $FallbackTo ] < 1) do={ :if ([ :len $FallbackTo ] < 1) do={
$LogPrint error $ScriptName ("There is no inactive partition named '" . $FallbackToName . "'."); $LogPrint error $ScriptName ("There is no inactive partition named '" . $FallbackToName . "'.");
:set PackagesUpdateBackupFailure true; :set PackagesUpdateBackupFailure true;
:set ExitOK true; :exit;
:error false;
} }
:if ([ /partitions/get $ActiveRunning version ] != [ /partitions/get $FallbackTo version]) do={ :if ([ /partitions/get $ActiveRunning version ] != [ /partitions/get $FallbackTo version]) do={
@ -88,8 +82,7 @@
:if (([ /terminal/inkey timeout=60 ] % 32) = 25) do={ :if (([ /terminal/inkey timeout=60 ] % 32) = 25) do={
:if ([ $CopyTo $ScriptName $FallbackTo $FallbackToName ] = false) do={ :if ([ $CopyTo $ScriptName $FallbackTo $FallbackToName ] = false) do={
:set PackagesUpdateBackupFailure true; :set PackagesUpdateBackupFailure true;
:set ExitOK true; :exit;
:error false;
} }
} }
} else={ } else={
@ -101,8 +94,7 @@
($NumInstalled & $BitMask) != ($NumLatest & $BitMask)) do={ ($NumInstalled & $BitMask) != ($NumLatest & $BitMask)) do={
:if ([ $CopyTo $ScriptName $FallbackTo $FallbackToName ] = false) do={ :if ([ $CopyTo $ScriptName $FallbackTo $FallbackToName ] = false) do={
:set PackagesUpdateBackupFailure true; :set PackagesUpdateBackupFailure true;
:set ExitOK true; :exit;
:error false;
} }
} }
} }
@ -120,9 +112,8 @@
$LogPrint error $ScriptName ("Failed saving configuration to partition '" . \ $LogPrint error $ScriptName ("Failed saving configuration to partition '" . \
$FallbackToName . "': " . $Err); $FallbackToName . "': " . $Err);
:set PackagesUpdateBackupFailure true; :set PackagesUpdateBackupFailure true;
:set ExitOK true; :exit;
:error false;
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -10,7 +10,6 @@
# create and upload backup and config file # create and upload backup and config file
# https://rsc.eworm.de/doc/backup-upload.md # https://rsc.eworm.de/doc/backup-upload.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -47,21 +46,18 @@
:if ($BackupSendBinary != true && \ :if ($BackupSendBinary != true && \
$BackupSendExport != true) do={ $BackupSendExport != true) do={
$LogPrint error $ScriptName ("Configured to send neither backup nor config export."); $LogPrint error $ScriptName ("Configured to send neither backup nor config export.");
:set ExitOK true; :exit;
:error false;
} }
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set PackagesUpdateBackupFailure true; :set PackagesUpdateBackupFailure true;
:set ExitOK true; :exit;
:error false;
} }
:if ([ :len [ /system/scheduler/find where name="running-from-backup-partition" ] ] > 0) do={ :if ([ :len [ /system/scheduler/find where name="running-from-backup-partition" ] ] > 0) do={
$LogPrint warning $ScriptName ("Running from backup partition, refusing to act."); $LogPrint warning $ScriptName ("Running from backup partition, refusing to act.");
:set PackagesUpdateBackupFailure true; :set PackagesUpdateBackupFailure true;
:set ExitOK true; :exit;
:error false;
} }
$WaitFullyConnected; $WaitFullyConnected;
@ -81,8 +77,7 @@
:if ([ $MkDir $DirName ] = false) do={ :if ([ $MkDir $DirName ] = false) do={
$LogPrint error $ScriptName ("Failed creating directory!"); $LogPrint error $ScriptName ("Failed creating directory!");
:set ExitOK true; :exit;
:error false;
} }
# binary backup # binary backup
@ -174,5 +169,5 @@
} }
$RmDir $DirName; $RmDir $DirName;
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -11,7 +11,6 @@
# #
# !! Do not edit this file, it is generated from template! # !! Do not edit this file, it is generated from template!
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -28,8 +27,7 @@
:global WaitFullyConnected; :global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
$WaitFullyConnected; $WaitFullyConnected;
@ -39,16 +37,14 @@
:if ([ :len $PackagePath ] = 0) do={ :if ([ :len $PackagePath ] = 0) do={
$LogPrint warning $ScriptName ("The CAPsMAN package path is not defined, can not download packages."); $LogPrint warning $ScriptName ("The CAPsMAN package path is not defined, can not download packages.");
:set ExitOK true; :exit;
:error false;
} }
:if ([ $FileGet $PackagePath ] = false) do={ :if ([ $FileGet $PackagePath ] = false) do={
:if ([ $MkDir $PackagePath ] = false) do={ :if ([ $MkDir $PackagePath ] = false) do={
$LogPrint warning $ScriptName ("Creating directory at CAPsMAN package path (" . \ $LogPrint warning $ScriptName ("Creating directory at CAPsMAN package path (" . \
$PackagePath . ") failed!"); $PackagePath . ") failed!");
:set ExitOK true; :exit;
:error false;
} }
$LogPrint info $ScriptName ("Created directory at CAPsMAN package path (" . $PackagePath . \ $LogPrint info $ScriptName ("Created directory at CAPsMAN package path (" . $PackagePath . \
"). Please place your packages!"); "). Please place your packages!");
@ -89,5 +85,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -12,7 +12,6 @@
# !! This is just a template to generate the real script! # !! This is just a template to generate the real script!
# !! Pattern '%TEMPL%' is replaced, paths are filtered. # !! Pattern '%TEMPL%' is replaced, paths are filtered.
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -29,8 +28,7 @@
:global WaitFullyConnected; :global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
$WaitFullyConnected; $WaitFullyConnected;
@ -41,16 +39,14 @@
:if ([ :len $PackagePath ] = 0) do={ :if ([ :len $PackagePath ] = 0) do={
$LogPrint warning $ScriptName ("The CAPsMAN package path is not defined, can not download packages."); $LogPrint warning $ScriptName ("The CAPsMAN package path is not defined, can not download packages.");
:set ExitOK true; :exit;
:error false;
} }
:if ([ $FileGet $PackagePath ] = false) do={ :if ([ $FileGet $PackagePath ] = false) do={
:if ([ $MkDir $PackagePath ] = false) do={ :if ([ $MkDir $PackagePath ] = false) do={
$LogPrint warning $ScriptName ("Creating directory at CAPsMAN package path (" . \ $LogPrint warning $ScriptName ("Creating directory at CAPsMAN package path (" . \
$PackagePath . ") failed!"); $PackagePath . ") failed!");
:set ExitOK true; :exit;
:error false;
} }
$LogPrint info $ScriptName ("Created directory at CAPsMAN package path (" . $PackagePath . \ $LogPrint info $ScriptName ("Created directory at CAPsMAN package path (" . $PackagePath . \
"). Please place your packages!"); "). Please place your packages!");
@ -100,5 +96,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -11,7 +11,6 @@
# #
# !! Do not edit this file, it is generated from template! # !! Do not edit this file, it is generated from template!
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -28,8 +27,7 @@
:global WaitFullyConnected; :global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
$WaitFullyConnected; $WaitFullyConnected;
@ -39,16 +37,14 @@
:if ([ :len $PackagePath ] = 0) do={ :if ([ :len $PackagePath ] = 0) do={
$LogPrint warning $ScriptName ("The CAPsMAN package path is not defined, can not download packages."); $LogPrint warning $ScriptName ("The CAPsMAN package path is not defined, can not download packages.");
:set ExitOK true; :exit;
:error false;
} }
:if ([ $FileGet $PackagePath ] = false) do={ :if ([ $FileGet $PackagePath ] = false) do={
:if ([ $MkDir $PackagePath ] = false) do={ :if ([ $MkDir $PackagePath ] = false) do={
$LogPrint warning $ScriptName ("Creating directory at CAPsMAN package path (" . \ $LogPrint warning $ScriptName ("Creating directory at CAPsMAN package path (" . \
$PackagePath . ") failed!"); $PackagePath . ") failed!");
:set ExitOK true; :exit;
:error false;
} }
$LogPrint info $ScriptName ("Created directory at CAPsMAN package path (" . $PackagePath . \ $LogPrint info $ScriptName ("Created directory at CAPsMAN package path (" . $PackagePath . \
"). Please place your packages!"); "). Please place your packages!");
@ -91,5 +87,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -12,7 +12,6 @@
# #
# !! Do not edit this file, it is generated from template! # !! Do not edit this file, it is generated from template!
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -23,8 +22,7 @@
:global ScriptLock; :global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:local InstalledVersion [ /system/package/update/get installed-version ]; :local InstalledVersion [ /system/package/update/get installed-version ];
@ -46,5 +44,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -13,7 +13,6 @@
# !! This is just a template to generate the real script! # !! This is just a template to generate the real script!
# !! Pattern '%TEMPL%' is replaced, paths are filtered. # !! Pattern '%TEMPL%' is replaced, paths are filtered.
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -24,8 +23,7 @@
:global ScriptLock; :global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:local InstalledVersion [ /system/package/update/get installed-version ]; :local InstalledVersion [ /system/package/update/get installed-version ];
@ -54,5 +52,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -12,7 +12,6 @@
# #
# !! Do not edit this file, it is generated from template! # !! Do not edit this file, it is generated from template!
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -23,8 +22,7 @@
:global ScriptLock; :global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:local InstalledVersion [ /system/package/update/get installed-version ]; :local InstalledVersion [ /system/package/update/get installed-version ];
@ -47,5 +45,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -8,7 +8,6 @@
# renew locally issued certificates # renew locally issued certificates
# https://rsc.eworm.de/doc/certificate-renew-issued.md # https://rsc.eworm.de/doc/certificate-renew-issued.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -22,8 +21,7 @@
:global ScriptLock; :global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:foreach Cert in=[ /certificate/find where issued expires-after<3w ] do={ :foreach Cert in=[ /certificate/find where issued expires-after<3w ] do={
@ -48,5 +46,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -9,7 +9,6 @@
# check for certificate validity # check for certificate validity
# https://rsc.eworm.de/doc/check-certificates.md # https://rsc.eworm.de/doc/check-certificates.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -150,8 +149,7 @@
} }
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
$WaitFullyConnected; $WaitFullyConnected;
@ -250,5 +248,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -8,7 +8,6 @@
# check for RouterOS health state # check for RouterOS health state
# https://rsc.eworm.de/doc/check-health.md # https://rsc.eworm.de/doc/check-health.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -37,8 +36,7 @@
} }
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:local Resource [ /system/resource/get ]; :local Resource [ /system/resource/get ];
@ -77,8 +75,7 @@
:local Plugins [ /system/script/find where name~"^check-health\\.d/." ]; :local Plugins [ /system/script/find where name~"^check-health\\.d/." ];
:if ([ :len $Plugins ] = 0) do={ :if ([ :len $Plugins ] = 0) do={
$LogPrint debug $ScriptName ("No plugins installed."); $LogPrint debug $ScriptName ("No plugins installed.");
:set ExitOK true; :exit;
:error true;
} }
:global CheckHealthPlugins ({}); :global CheckHealthPlugins ({});
@ -106,5 +103,5 @@
:set CheckHealthPlugins; :set CheckHealthPlugins;
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -8,7 +8,6 @@
# check for LTE firmware upgrade, send notification # check for LTE firmware upgrade, send notification
# https://rsc.eworm.de/doc/check-lte-firmware-upgrade.md # https://rsc.eworm.de/doc/check-lte-firmware-upgrade.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -20,8 +19,7 @@
:global ScriptLock; :global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:if ([ :typeof $SentLteFirmwareUpgradeNotification ] != "array") do={ :if ([ :typeof $SentLteFirmwareUpgradeNotification ] != "array") do={
@ -103,5 +101,5 @@
$CheckInterface $ScriptName $Interface; $CheckInterface $ScriptName $Interface;
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -8,7 +8,6 @@
# check perpetual license on CHR # check perpetual license on CHR
# https://rsc.eworm.de/doc/check-perpetual-license.md # https://rsc.eworm.de/doc/check-perpetual-license.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -25,8 +24,7 @@
:global WaitFullyConnected; :global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
$WaitFullyConnected; $WaitFullyConnected;
@ -34,8 +32,7 @@
:local License [ /system/license/get ]; :local License [ /system/license/get ];
:if ([ :typeof ($License->"deadline-at") ] != "str") do={ :if ([ :typeof ($License->"deadline-at") ] != "str") do={
$LogPrint info $ScriptName ("This device does not have a perpetual license."); $LogPrint info $ScriptName ("This device does not have a perpetual license.");
:set ExitOK true; :exit;
:error true;
} }
:if ([ :len ($License->"next-renewal-at") ] = 0 && ($License->"limited-upgrades") = true) do={ :if ([ :len ($License->"next-renewal-at") ] = 0 && ($License->"limited-upgrades") = true) do={
@ -47,8 +44,7 @@
", can no longer update RouterOS on " . $Identity . "...") }); ", can no longer update RouterOS on " . $Identity . "...") });
:set SentCertificateNotification "expired"; :set SentCertificateNotification "expired";
} }
:set ExitOK true; :exit;
:error true;
} }
:if ([ :totime ($License->"deadline-at") ] - 3w < [ :timestamp ]) do={ :if ([ :totime ($License->"deadline-at") ] - 3w < [ :timestamp ]) do={
@ -60,8 +56,7 @@
($License->"deadline-at") . " on " . $Identity . "...") }); ($License->"deadline-at") . " on " . $Identity . "...") });
:set SentCertificateNotification "warning"; :set SentCertificateNotification "warning";
} }
:set ExitOK true; :exit;
:error true;
} }
:if ([ :typeof $SentCertificateNotification ] = "str" && \ :if ([ :typeof $SentCertificateNotification ] = "str" && \
@ -74,5 +69,5 @@
:set SentCertificateNotification; :set SentCertificateNotification;
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -9,7 +9,6 @@
# check for RouterOS update, send notification and/or install # check for RouterOS update, send notification and/or install
# https://rsc.eworm.de/doc/check-routeros-update.md # https://rsc.eworm.de/doc/check-routeros-update.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -47,14 +46,12 @@
} }
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:if ([ :len [ /system/scheduler/find where name="running-from-backup-partition" ] ] > 0) do={ :if ([ :len [ /system/scheduler/find where name="running-from-backup-partition" ] ] > 0) do={
$LogPrint warning $ScriptName ("Running from backup partition, refusing to act."); $LogPrint warning $ScriptName ("Running from backup partition, refusing to act.");
:set ExitOK true; :exit;
:error false;
} }
$WaitFullyConnected; $WaitFullyConnected;
@ -65,8 +62,7 @@
/system/scheduler/remove "_RebootForUpdate"; /system/scheduler/remove "_RebootForUpdate";
} else={ } else={
$LogPrint info $ScriptName ("A reboot for update is already scheduled."); $LogPrint info $ScriptName ("A reboot for update is already scheduled.");
:set ExitOK true; :exit;
:error false;
} }
} }
@ -78,14 +74,12 @@
:if ([ $ScriptFromTerminal $ScriptName ] = true) do={ :if ([ $ScriptFromTerminal $ScriptName ] = true) do={
$LogPrint info $ScriptName ("System is already up to date."); $LogPrint info $ScriptName ("System is already up to date.");
} }
:set ExitOK true; :exit;
:error true;
} }
:if ([ :len ($Update->"latest-version") ] = 0) do={ :if ([ :len ($Update->"latest-version") ] = 0) do={
$LogPrint info $ScriptName ("Received an empty version string from server."); $LogPrint info $ScriptName ("Received an empty version string from server.");
:set ExitOK true; :exit;
:error false;
} }
:local NumInstalled [ $VersionToNum ($Update->"installed-version") ]; :local NumInstalled [ $VersionToNum ($Update->"installed-version") ];
@ -97,8 +91,7 @@
:if ($NumLatest < [ $VersionToNum "7.0" ]) do={ :if ($NumLatest < [ $VersionToNum "7.0" ]) do={
$LogPrint warning $ScriptName ("The version '" . ($Update->"latest-version") . "' is not a valid version."); $LogPrint warning $ScriptName ("The version '" . ($Update->"latest-version") . "' is not a valid version.");
:set ExitOK true; :exit;
:error false;
} }
:if ($NumInstalled < $NumLatest) do={ :if ($NumInstalled < $NumLatest) do={
@ -110,8 +103,7 @@
message=("Installing ALL versions automatically, including " . $Update->"latest-version" . \ message=("Installing ALL versions automatically, including " . $Update->"latest-version" . \
"... Updating on " . $Identity . "..."); link=$Link; silent=true }); "... Updating on " . $Identity . "..."); link=$Link; silent=true });
$DoUpdate $ScriptName; $DoUpdate $ScriptName;
:set ExitOK true; :exit;
:error true;
} }
:if ($SafeUpdatePatch = true && $NumInstalledFeature = $NumLatestFeature) do={ :if ($SafeUpdatePatch = true && $NumInstalledFeature = $NumLatestFeature) do={
@ -121,8 +113,7 @@
message=("Version " . $Update->"latest-version" . " is a patch update for " . $Update->"channel" . \ message=("Version " . $Update->"latest-version" . " is a patch update for " . $Update->"channel" . \
", updating on " . $Identity . "..."); link=$Link; silent=true }); ", updating on " . $Identity . "..."); link=$Link; silent=true });
$DoUpdate $ScriptName; $DoUpdate $ScriptName;
:set ExitOK true; :exit;
:error true;
} }
:if ($SafeUpdateNeighbor = true) do={ :if ($SafeUpdateNeighbor = true) do={
@ -137,8 +128,7 @@
message=("Seen a neighbor (" . $Neighbor . ") running version " . $Update->"latest-version" . \ message=("Seen a neighbor (" . $Neighbor . ") running version " . $Update->"latest-version" . \
" from " . $Update->"channel" . ", updating on " . $Identity . "..."); link=$Link; silent=true }); " from " . $Update->"channel" . ", updating on " . $Identity . "..."); link=$Link; silent=true });
$DoUpdate $ScriptName; $DoUpdate $ScriptName;
:set ExitOK true; :exit;
:error true;
} }
} }
@ -159,8 +149,7 @@
message=("Version " . $Update->"latest-version" . " is considered safe for " . $Update->"channel" . \ message=("Version " . $Update->"latest-version" . " is considered safe for " . $Update->"channel" . \
", updating on " . $Identity . "..."); link=$Link; silent=true }); ", updating on " . $Identity . "..."); link=$Link; silent=true });
$DoUpdate $ScriptName; $DoUpdate $ScriptName;
:set ExitOK true; :exit;
:error true;
} }
} }
@ -170,16 +159,14 @@
:if (([ /terminal/inkey timeout=60 ] % 32) = 25) do={ :if (([ /terminal/inkey timeout=60 ] % 32) = 25) do={
/system/package/update/set channel=stable; /system/package/update/set channel=stable;
$LogPrint info $ScriptName ("Switched to channel 'stable', please re-run!"); $LogPrint info $ScriptName ("Switched to channel 'stable', please re-run!");
:set ExitOK true; :exit;
:error true;
} }
} }
:put ("Do you want to install RouterOS version " . $Update->"latest-version" . "? [y/N]"); :put ("Do you want to install RouterOS version " . $Update->"latest-version" . "? [y/N]");
:if (([ /terminal/inkey timeout=60 ] % 32) = 25) do={ :if (([ /terminal/inkey timeout=60 ] % 32) = 25) do={
$DoUpdate $ScriptName; $DoUpdate $ScriptName;
:set ExitOK true; :exit;
:error true;
} else={ } else={
:put "Canceled..."; :put "Canceled...";
} }
@ -188,8 +175,7 @@
:if ($SentRouterosUpdateNotification = $Update->"latest-version") do={ :if ($SentRouterosUpdateNotification = $Update->"latest-version") do={
$LogPrint info $ScriptName ("Already sent the RouterOS update notification for version " . \ $LogPrint info $ScriptName ("Already sent the RouterOS update notification for version " . \
$Update->"latest-version" . "."); $Update->"latest-version" . ".");
:set ExitOK true; :exit;
:error true;
} }
$SendNotification2 ({ origin=$ScriptName; \ $SendNotification2 ({ origin=$ScriptName; \
@ -204,8 +190,7 @@
:if ($SentRouterosUpdateNotification = $Update->"latest-version") do={ :if ($SentRouterosUpdateNotification = $Update->"latest-version") do={
$LogPrint info $ScriptName ("Already sent the RouterOS downgrade notification for version " . \ $LogPrint info $ScriptName ("Already sent the RouterOS downgrade notification for version " . \
$Update->"latest-version" . "."); $Update->"latest-version" . ".");
:set ExitOK true; :exit;
:error true;
} }
$SendNotification2 ({ origin=$ScriptName; \ $SendNotification2 ({ origin=$ScriptName; \
@ -218,5 +203,5 @@
:set SentRouterosUpdateNotification ($Update->"latest-version"); :set SentRouterosUpdateNotification ($Update->"latest-version");
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -11,7 +11,6 @@
# #
# !! Do not edit this file, it is generated from template! # !! Do not edit this file, it is generated from template!
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -30,8 +29,7 @@
:global SymbolForNotification; :global SymbolForNotification;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={ :if ([ $ScriptLock $ScriptName 10 ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:if ([ :len [ /caps-man/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={ :if ([ :len [ /caps-man/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={
@ -96,5 +94,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -11,7 +11,6 @@
# #
# !! Do not edit this file, it is generated from template! # !! Do not edit this file, it is generated from template!
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -30,8 +29,7 @@
:global SymbolForNotification; :global SymbolForNotification;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={ :if ([ $ScriptLock $ScriptName 10 ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:if ([ :len [ /interface/wireless/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={ :if ([ :len [ /interface/wireless/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={
@ -97,5 +95,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -12,7 +12,6 @@
# !! This is just a template to generate the real script! # !! This is just a template to generate the real script!
# !! Pattern '%TEMPL%' is replaced, paths are filtered. # !! Pattern '%TEMPL%' is replaced, paths are filtered.
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -31,8 +30,7 @@
:global SymbolForNotification; :global SymbolForNotification;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={ :if ([ $ScriptLock $ScriptName 10 ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:if ([ :len [ /caps-man/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={ :if ([ :len [ /caps-man/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={
@ -114,5 +112,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -11,7 +11,6 @@
# #
# !! Do not edit this file, it is generated from template! # !! Do not edit this file, it is generated from template!
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -30,8 +29,7 @@
:global SymbolForNotification; :global SymbolForNotification;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={ :if ([ $ScriptLock $ScriptName 10 ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:if ([ :len [ /interface/wifi/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={ :if ([ :len [ /interface/wifi/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={
@ -96,5 +94,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -11,7 +11,6 @@
# #
# !! Do not edit this file, it is generated from template! # !! Do not edit this file, it is generated from template!
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -32,8 +31,7 @@
:global WaitFullyConnected; :global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
$WaitFullyConnected; $WaitFullyConnected;
@ -92,5 +90,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -11,7 +11,6 @@
# #
# !! Do not edit this file, it is generated from template! # !! Do not edit this file, it is generated from template!
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -32,8 +31,7 @@
:global WaitFullyConnected; :global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
$WaitFullyConnected; $WaitFullyConnected;
@ -91,5 +89,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -12,7 +12,6 @@
# !! This is just a template to generate the real script! # !! This is just a template to generate the real script!
# !! Pattern '%TEMPL%' is replaced, paths are filtered. # !! Pattern '%TEMPL%' is replaced, paths are filtered.
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -33,8 +32,7 @@
:global WaitFullyConnected; :global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
$WaitFullyConnected; $WaitFullyConnected;
@ -107,5 +105,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -11,7 +11,6 @@
# #
# !! Do not edit this file, it is generated from template! # !! Do not edit this file, it is generated from template!
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -32,8 +31,7 @@
:global WaitFullyConnected; :global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
$WaitFullyConnected; $WaitFullyConnected;
@ -92,5 +90,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -11,7 +11,6 @@
# #
# !! Do not edit this file, it is generated from template! # !! Do not edit this file, it is generated from template!
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -22,8 +21,7 @@
:global ScriptLock; :global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={ :foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={
@ -39,5 +37,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -11,7 +11,6 @@
# #
# !! Do not edit this file, it is generated from template! # !! Do not edit this file, it is generated from template!
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -22,8 +21,7 @@
:global ScriptLock; :global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={ :foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={
@ -39,5 +37,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -12,7 +12,6 @@
# !! This is just a template to generate the real script! # !! This is just a template to generate the real script!
# !! Pattern '%TEMPL%' is replaced, paths are filtered. # !! Pattern '%TEMPL%' is replaced, paths are filtered.
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -23,8 +22,7 @@
:global ScriptLock; :global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={ :foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={
@ -44,5 +42,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -11,7 +11,6 @@
# #
# !! Do not edit this file, it is generated from template! # !! Do not edit this file, it is generated from template!
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -22,8 +21,7 @@
:global ScriptLock; :global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={ :foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={
@ -39,5 +37,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -9,7 +9,6 @@
# check DHCP leases and add/remove/update DNS entries # check DHCP leases and add/remove/update DNS entries
# https://rsc.eworm.de/doc/dhcp-to-dns.md # https://rsc.eworm.de/doc/dhcp-to-dns.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -28,8 +27,7 @@
:global ScriptLock; :global ScriptLock;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={ :if ([ $ScriptLock $ScriptName 10 ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:local Ttl 5m; :local Ttl 5m;
@ -126,5 +124,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -8,7 +8,6 @@
# install firmware upgrade, and reboot # install firmware upgrade, and reboot
# https://rsc.eworm.de/doc/firmware-upgrade-reboot.md # https://rsc.eworm.de/doc/firmware-upgrade-reboot.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -20,21 +19,18 @@
:global VersionToNum; :global VersionToNum;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:local RouterBoard [ /system/routerboard/get ]; :local RouterBoard [ /system/routerboard/get ];
:if ($RouterBoard->"current-firmware" = $RouterBoard->"upgrade-firmware") do={ :if ($RouterBoard->"current-firmware" = $RouterBoard->"upgrade-firmware") do={
$LogPrint info $ScriptName ("Current and upgrade firmware match with version " . \ $LogPrint info $ScriptName ("Current and upgrade firmware match with version " . \
$RouterBoard->"current-firmware" . "."); $RouterBoard->"current-firmware" . ".");
:set ExitOK true; :exit;
:error true;
} }
:if ([ $VersionToNum ($RouterBoard->"current-firmware") ] > [ $VersionToNum ($RouterBoard->"upgrade-firmware") ]) do={ :if ([ $VersionToNum ($RouterBoard->"current-firmware") ] > [ $VersionToNum ($RouterBoard->"upgrade-firmware") ]) do={
$LogPrint info $ScriptName ("Different firmware version is available, but it is a downgrade. Ignoring."); $LogPrint info $ScriptName ("Different firmware version is available, but it is a downgrade. Ignoring.");
:set ExitOK true; :exit;
:error true;
} }
:if ([ /system/routerboard/settings/get auto-upgrade ] = false) do={ :if ([ /system/routerboard/settings/get auto-upgrade ] = false) do={
@ -56,5 +52,5 @@
$LogPrint info $ScriptName ("Firmware upgrade successful, rebooting."); $LogPrint info $ScriptName ("Firmware upgrade successful, rebooting.");
/system/reboot; /system/reboot;
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -8,7 +8,6 @@
# download, import and update firewall address-lists # download, import and update firewall address-lists
# https://rsc.eworm.de/doc/fw-addr-lists.md # https://rsc.eworm.de/doc/fw-addr-lists.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -46,8 +45,7 @@
} }
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
$WaitFullyConnected; $WaitFullyConnected;
@ -232,5 +230,5 @@
" - removed: " . [ $HumanReadableNum $CntRemove 1000 ]); " - removed: " . [ $HumanReadableNum $CntRemove 1000 ]);
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -474,18 +474,15 @@
# simple macro to print error message on unintentional error # simple macro to print error message on unintentional error
:set ExitError do={ :set ExitError do={
:local ExitOK [ :tostr $1 ]; :local Name [ :tostr $1 ];
:local Name [ :tostr $2 ]; :local Error [ :tostr $2 ];
:local Error [ :tostr $3 ];
:global IfThenElse; :global IfThenElse;
:global LogPrint; :global LogPrint;
:if ($ExitOK = "false") do={ $LogPrint error $Name ([ $IfThenElse ([ :pick $Name 0 1 ] = "\$") \
$LogPrint error $Name ([ $IfThenElse ([ :pick $Name 0 1 ] = "\$") \ "Function" "Script" ] . " '" . $Name . "' exited with error" . \
"Function" "Script" ] . " '" . $Name . "' exited with error" . \ [ $IfThenElse (!($Error ~ "^(|true|false)\$")) (": " . $Error) "." ]);
[ $IfThenElse (!($Error ~ "^(|true|false)\$")) (": " . $Error) "." ]);
}
} }
# fetch huge data to file, read in chunks # fetch huge data to file, read in chunks
@ -1503,7 +1500,7 @@
:set GlobalConfigMigration; :set GlobalConfigMigration;
} }
} do={ } do={
:global ExitError; $ExitError false $0 $Err; :global ExitError; $ExitError $0 $Err;
} } } }
# lock script against multiple invocation # lock script against multiple invocation
@ -1649,7 +1646,7 @@
$SendNotification2 ({ origin=$0; subject=$1; message=$2; link=$3; silent=$4 }); $SendNotification2 ({ origin=$0; subject=$1; message=$2; link=$3; silent=$4 });
} do={ } do={
:global ExitError; $ExitError false $0 $Err; :global ExitError; $ExitError $0 $Err;
} } } }
# send notification via NotificationFunctions - expects one array argument # send notification via NotificationFunctions - expects one array argument

View file

@ -9,7 +9,6 @@
# track gps data by sending json data to http server # track gps data by sending json data to http server
# https://rsc.eworm.de/doc/gps-track.md # https://rsc.eworm.de/doc/gps-track.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -25,8 +24,7 @@
:global WaitFullyConnected; :global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
$WaitFullyConnected; $WaitFullyConnected;
@ -49,5 +47,5 @@
$LogPrint debug $ScriptName ("GPS data not valid."); $LogPrint debug $ScriptName ("GPS data not valid.");
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -12,7 +12,6 @@
# #
# !! Do not edit this file, it is generated from template! # !! Do not edit this file, it is generated from template!
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -25,8 +24,7 @@
:global ScriptLock; :global ScriptLock;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={ :if ([ $ScriptLock $ScriptName 10 ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:local DHCPServers ({}); :local DHCPServers ({});
@ -76,5 +74,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -13,7 +13,6 @@
# !! This is just a template to generate the real script! # !! This is just a template to generate the real script!
# !! Pattern '%TEMPL%' is replaced, paths are filtered. # !! Pattern '%TEMPL%' is replaced, paths are filtered.
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -26,8 +25,7 @@
:global ScriptLock; :global ScriptLock;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={ :if ([ $ScriptLock $ScriptName 10 ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:local DHCPServers ({}); :local DHCPServers ({});
@ -83,5 +81,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -12,7 +12,6 @@
# #
# !! Do not edit this file, it is generated from template! # !! Do not edit this file, it is generated from template!
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -25,8 +24,7 @@
:global ScriptLock; :global ScriptLock;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={ :if ([ $ScriptLock $ScriptName 10 ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:local DHCPServers ({}); :local DHCPServers ({});
@ -76,5 +74,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -11,7 +11,6 @@
# #
# !! Do not edit this file, it is generated from template! # !! Do not edit this file, it is generated from template!
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -27,14 +26,12 @@
:local UserName $username; :local UserName $username;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:if ([ :typeof $MacAddress ] = "nothing" || [ :typeof $UserName ] = "nothing") do={ :if ([ :typeof $MacAddress ] = "nothing" || [ :typeof $UserName ] = "nothing") do={
$LogPrint error $ScriptName ("This script is supposed to run from hotspot on login."); $LogPrint error $ScriptName ("This script is supposed to run from hotspot on login.");
:set ExitOK true; :exit;
:error false;
} }
:local Date [ /system/clock/get date ]; :local Date [ /system/clock/get date ];
@ -61,8 +58,7 @@
:if ($Template->"action" = "reject") do={ :if ($Template->"action" = "reject") do={
$LogPrint info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'."); $LogPrint info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'.");
:set ExitOK true; :exit;
:error true;
} }
# allow login page to load # allow login page to load
@ -101,5 +97,5 @@
:delay 2s; :delay 2s;
/caps-man/access-list/set $Entry action=accept; /caps-man/access-list/set $Entry action=accept;
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -12,7 +12,6 @@
# !! This is just a template to generate the real script! # !! This is just a template to generate the real script!
# !! Pattern '%TEMPL%' is replaced, paths are filtered. # !! Pattern '%TEMPL%' is replaced, paths are filtered.
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -28,14 +27,12 @@
:local UserName $username; :local UserName $username;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:if ([ :typeof $MacAddress ] = "nothing" || [ :typeof $UserName ] = "nothing") do={ :if ([ :typeof $MacAddress ] = "nothing" || [ :typeof $UserName ] = "nothing") do={
$LogPrint error $ScriptName ("This script is supposed to run from hotspot on login."); $LogPrint error $ScriptName ("This script is supposed to run from hotspot on login.");
:set ExitOK true; :exit;
:error false;
} }
:local Date [ /system/clock/get date ]; :local Date [ /system/clock/get date ];
@ -68,8 +65,7 @@
:if ($Template->"action" = "reject") do={ :if ($Template->"action" = "reject") do={
$LogPrint info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'."); $LogPrint info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'.");
:set ExitOK true; :exit;
:error true;
} }
# allow login page to load # allow login page to load
@ -121,5 +117,5 @@
/caps-man/access-list/set $Entry action=accept; /caps-man/access-list/set $Entry action=accept;
/interface/wifi/access-list/set $Entry action=accept; /interface/wifi/access-list/set $Entry action=accept;
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -11,7 +11,6 @@
# #
# !! Do not edit this file, it is generated from template! # !! Do not edit this file, it is generated from template!
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -27,14 +26,12 @@
:local UserName $username; :local UserName $username;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:if ([ :typeof $MacAddress ] = "nothing" || [ :typeof $UserName ] = "nothing") do={ :if ([ :typeof $MacAddress ] = "nothing" || [ :typeof $UserName ] = "nothing") do={
$LogPrint error $ScriptName ("This script is supposed to run from hotspot on login."); $LogPrint error $ScriptName ("This script is supposed to run from hotspot on login.");
:set ExitOK true; :exit;
:error false;
} }
:local Date [ /system/clock/get date ]; :local Date [ /system/clock/get date ];
@ -61,8 +58,7 @@
:if ($Template->"action" = "reject") do={ :if ($Template->"action" = "reject") do={
$LogPrint info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'."); $LogPrint info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'.");
:set ExitOK true; :exit;
:error true;
} }
# allow login page to load # allow login page to load
@ -98,5 +94,5 @@
:delay 2s; :delay 2s;
/interface/wifi/access-list/set $Entry action=accept; /interface/wifi/access-list/set $Entry action=accept;
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -9,7 +9,6 @@
# and add/remove/update DNS entries from IPSec mode-config # and add/remove/update DNS entries from IPSec mode-config
# https://rsc.eworm.de/doc/ipsec-to-dns.md # https://rsc.eworm.de/doc/ipsec-to-dns.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -28,8 +27,7 @@
:global ScriptLock; :global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:local Zone \ :local Zone \
@ -80,5 +78,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -8,7 +8,6 @@
# update firewall and dns settings on IPv6 prefix change # update firewall and dns settings on IPv6 prefix change
# https://rsc.eworm.de/doc/ipv6-update.md # https://rsc.eworm.de/doc/ipv6-update.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -25,26 +24,22 @@
:local PdValid $"pd-valid"; :local PdValid $"pd-valid";
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:if ([ :typeof $NaAddress ] = "str") do={ :if ([ :typeof $NaAddress ] = "str") do={
$LogPrint info $ScriptName ("An address (" . $NaAddress . ") was acquired, not a prefix. Ignoring."); $LogPrint info $ScriptName ("An address (" . $NaAddress . ") was acquired, not a prefix. Ignoring.");
:set ExitOK true; :exit;
:error false;
} }
:if ([ :typeof $PdPrefix ] = "nothing" || [ :typeof $PdValid ] = "nothing") do={ :if ([ :typeof $PdPrefix ] = "nothing" || [ :typeof $PdValid ] = "nothing") do={
$LogPrint error $ScriptName ("This script is supposed to run from ipv6 dhcp-client."); $LogPrint error $ScriptName ("This script is supposed to run from ipv6 dhcp-client.");
:set ExitOK true; :exit;
:error false;
} }
:if ($PdValid != 1) do={ :if ($PdValid != 1) do={
$LogPrint info $ScriptName ("The prefix " . $PdPrefix . " is no longer valid. Ignoring."); $LogPrint info $ScriptName ("The prefix " . $PdPrefix . " is no longer valid. Ignoring.");
:set ExitOK true; :exit;
:error false;
} }
:local Pool [ /ipv6/pool/get [ find where prefix=$PdPrefix ] name ]; :local Pool [ /ipv6/pool/get [ find where prefix=$PdPrefix ] name ];
@ -103,5 +98,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -8,7 +8,6 @@
# run scripts on DHCP lease # run scripts on DHCP lease
# https://rsc.eworm.de/doc/lease-script.md # https://rsc.eworm.de/doc/lease-script.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -26,22 +25,19 @@
[ :typeof $leaseServerName ] = "nothing" || \ [ :typeof $leaseServerName ] = "nothing" || \
[ :typeof $leaseBound ] = "nothing") do={ [ :typeof $leaseBound ] = "nothing") do={
$LogPrint error $ScriptName ("This script is supposed to run from ip dhcp-server."); $LogPrint error $ScriptName ("This script is supposed to run from ip dhcp-server.");
:set ExitOK true; :exit;
:error false;
} }
$LogPrint debug $ScriptName ("DHCP Server " . $leaseServerName . " " . [ $IfThenElse ($leaseBound = 0) \ $LogPrint debug $ScriptName ("DHCP Server " . $leaseServerName . " " . [ $IfThenElse ($leaseBound = 0) \
"de" "" ] . "assigned lease " . $leaseActIP . " to " . $leaseActMAC); "de" "" ] . "assigned lease " . $leaseActIP . " to " . $leaseActMAC);
:if ([ $ScriptLock $ScriptName 10 ] = false) do={ :if ([ $ScriptLock $ScriptName 10 ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:if ([ :len [ /system/script/job/find where script=$ScriptName ] ] > 1) do={ :if ([ :len [ /system/script/job/find where script=$ScriptName ] ] > 1) do={
$LogPrint debug $ScriptName ("More invocations are waiting, exiting early."); $LogPrint debug $ScriptName ("More invocations are waiting, exiting early.");
:set ExitOK true; :exit;
:error true;
} }
:local RunOrder ({}); :local RunOrder ({});
@ -61,5 +57,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -8,7 +8,6 @@
# forward log messages via notification # forward log messages via notification
# https://rsc.eworm.de/doc/log-forward.md # https://rsc.eworm.de/doc/log-forward.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -33,8 +32,7 @@
:global SymbolForNotification; :global SymbolForNotification;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:if ([ :typeof $LogForwardLast ] = "nothing") do={ :if ([ :typeof $LogForwardLast ] = "nothing") do={
@ -48,8 +46,7 @@
:if ($LogForwardRateLimit > 30) do={ :if ($LogForwardRateLimit > 30) do={
:set LogForwardRateLimit ($LogForwardRateLimit - 1); :set LogForwardRateLimit ($LogForwardRateLimit - 1);
$LogPrint info $ScriptName ("Rate limit in action, not forwarding logs, if any!"); $LogPrint info $ScriptName ("Rate limit in action, not forwarding logs, if any!");
:set ExitOK true; :exit;
:error false;
} }
:local Count 0; :local Count 0;
@ -111,5 +108,5 @@
:set LogForwardLast $Max; :set LogForwardLast $Max;
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -66,5 +66,5 @@
/interface/ethernet/enable $InterfaceReEnable; /interface/ethernet/enable $InterfaceReEnable;
} }
} do={ } do={
:global ExitError; $ExitError false $0 $Err; :global ExitError; $ExitError $0 $Err;
} } } }

View file

@ -75,5 +75,5 @@
/interface/ethernet/enable $InterfaceReEnable; /interface/ethernet/enable $InterfaceReEnable;
} }
} do={ } do={
:global ExitError; $ExitError false $0 $Err; :global ExitError; $ExitError $0 $Err;
} } } }

View file

@ -17,7 +17,7 @@
:put [ :tocrlf [ $InspectVarReturn $1 ] ]; :put [ :tocrlf [ $InspectVarReturn $1 ] ];
} do={ } do={
:global ExitError; $ExitError false $0 $Err; :global ExitError; $ExitError $0 $Err;
} } } }
# inspect variable and return formatted string # inspect variable and return formatted string

View file

@ -28,7 +28,7 @@
[ $FormatLine "HostMax" ($Values->"hostmax") ] . "\n" . \ [ $FormatLine "HostMax" ($Values->"hostmax") ] . "\n" . \
[ $FormatLine "Broadcast" ($Values->"broadcast") ]) ]; [ $FormatLine "Broadcast" ($Values->"broadcast") ]) ];
} do={ } do={
:global ExitError; $ExitError false $0 $Err; :global ExitError; $ExitError $0 $Err;
} } } }
# calculate and return netmask, network, min host, max host and broadcast # calculate and return netmask, network, min host, max host and broadcast

View file

@ -131,7 +131,7 @@
/system/scheduler/set interval=(($SchedVal->"run-count") . "m") \ /system/scheduler/set interval=(($SchedVal->"run-count") . "m") \
comment="Waiting for retry..." $Scheduler; comment="Waiting for retry..." $Scheduler;
} do={ } do={
:global ExitError; $ExitError false $0 $Err; :global ExitError; $ExitError $0 $Err;
} } } }
# generate filter for log-forward # generate filter for log-forward
@ -259,7 +259,7 @@
$SendEMail2 ({ origin=$0; subject=$1; message=$2; link=$3 }); $SendEMail2 ({ origin=$0; subject=$1; message=$2; link=$3 });
} do={ } do={
:global ExitError; $ExitError false $0 $Err; :global ExitError; $ExitError $0 $Err;
} } } }
# send notification via e-mail - expects one array argument # send notification via e-mail - expects one array argument

View file

@ -54,7 +54,7 @@
:set GotifyQueue; :set GotifyQueue;
} }
} do={ } do={
:global ExitError; $ExitError false $0 $Err; :global ExitError; $ExitError $0 $Err;
} } } }
# send notification via Gotify - expects one array argument # send notification via Gotify - expects one array argument
@ -126,7 +126,7 @@
$SendGotify2 ({ origin=$0; subject=$1; message=$2; link=$3; silent=$4 }); $SendGotify2 ({ origin=$0; subject=$1; message=$2; link=$3; silent=$4 });
} do={ } do={
:global ExitError; $ExitError false $0 $Err; :global ExitError; $ExitError $0 $Err;
} } } }
# send notification via Gotify - expects one array argument # send notification via Gotify - expects one array argument

View file

@ -59,7 +59,7 @@
:set MatrixQueue; :set MatrixQueue;
} }
} do={ } do={
:global ExitError; $ExitError false $0 $Err; :global ExitError; $ExitError $0 $Err;
} } } }
# send notification via Matrix - expects one array argument # send notification via Matrix - expects one array argument
@ -172,7 +172,7 @@
$SendMatrix2 ({ origin=$0; subject=$1; message=$2; link=$3 }); $SendMatrix2 ({ origin=$0; subject=$1; message=$2; link=$3 });
} do={ } do={
:global ExitError; $ExitError false $0 $Err; :global ExitError; $ExitError $0 $Err;
} } } }
# send notification via Matrix - expects one array argument # send notification via Matrix - expects one array argument

View file

@ -53,7 +53,7 @@
:set NtfyQueue; :set NtfyQueue;
} }
} do={ } do={
:global ExitError; $ExitError false $0 $Err; :global ExitError; $ExitError $0 $Err;
} } } }
# send notification via ntfy - expects one array argument # send notification via ntfy - expects one array argument
@ -148,7 +148,7 @@
$SendNtfy2 ({ origin=$0; subject=$1; message=$2; link=$3; silent=$4 }); $SendNtfy2 ({ origin=$0; subject=$1; message=$2; link=$3; silent=$4 });
} do={ } do={
:global ExitError; $ExitError false $0 $Err; :global ExitError; $ExitError $0 $Err;
} } } }
# send notification via ntfy - expects one array argument # send notification via ntfy - expects one array argument

View file

@ -62,7 +62,7 @@
:set TelegramQueue; :set TelegramQueue;
} }
} do={ } do={
:global ExitError; $ExitError false $0 $Err; :global ExitError; $ExitError $0 $Err;
} } } }
# get the chat id # get the chat id
@ -101,7 +101,7 @@
$LogPrint info $0 ("The thread id is: " . ($Message->"message_thread_id")); $LogPrint info $0 ("The thread id is: " . ($Message->"message_thread_id"));
} }
} do={ } do={
:global ExitError; $ExitError false $0 $Err; :global ExitError; $ExitError $0 $Err;
} } } }
# send notification via telegram - expects one array argument # send notification via telegram - expects one array argument
@ -237,7 +237,7 @@
$SendTelegram2 ({ origin=$0; subject=$1; message=$2; link=$3; silent=$4 }); $SendTelegram2 ({ origin=$0; subject=$1; message=$2; link=$3; silent=$4 });
} do={ } do={
:global ExitError; $ExitError false $0 $Err; :global ExitError; $ExitError $0 $Err;
} } } }
# send notification via telegram - expects one array argument # send notification via telegram - expects one array argument

View file

@ -52,5 +52,5 @@
:return true; :return true;
} }
} do={ } do={
:global ExitError; $ExitError false $0 $Err; :global ExitError; $ExitError $0 $Err;
} } } }

View file

@ -67,7 +67,7 @@
:return false; :return false;
} }
} do={ } do={
:global ExitError; $ExitError false $0 $Err; :global ExitError; $ExitError $0 $Err;
} } } }
# import keys from a file # import keys from a file
@ -109,5 +109,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError false $0 $Err; :global ExitError; $ExitError $0 $Err;
} } } }

View file

@ -82,7 +82,7 @@
$LogPrint info $FuncName ("No action defined for " . $Count . " mode-button presses."); $LogPrint info $FuncName ("No action defined for " . $Count . " mode-button presses.");
} }
} do={ } do={
:global ExitError; $ExitError false $0 $Err; :global ExitError; $ExitError $0 $Err;
} } } }
/system/scheduler/add name="_ModeButtonScheduler" \ /system/scheduler/add name="_ModeButtonScheduler" \
on-event=":global ModeButtonScheduler; \$ModeButtonScheduler;" interval=3s; on-event=":global ModeButtonScheduler; \$ModeButtonScheduler;" interval=3s;
@ -91,5 +91,5 @@
/system/scheduler/set $Scheduler start-time=[ /system/clock/get time ]; /system/scheduler/set $Scheduler start-time=[ /system/clock/get time ];
} }
} do={ } do={
:global ExitError; $ExitError false [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -9,7 +9,6 @@
# monitor and manage dns/doh with netwatch # monitor and manage dns/doh with netwatch
# https://rsc.eworm.de/doc/netwatch-dns.md # https://rsc.eworm.de/doc/netwatch-dns.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -26,15 +25,13 @@
:global ScriptLock; :global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:local SettleTime (5m30s - [ /system/resource/get uptime ]); :local SettleTime (5m30s - [ /system/resource/get uptime ]);
:if ($SettleTime > 0s) do={ :if ($SettleTime > 0s) do={
$LogPrint info $ScriptName ("System just booted, giving netwatch " . $SettleTime . " to settle."); $LogPrint info $ScriptName ("System just booted, giving netwatch " . $SettleTime . " to settle.");
:set ExitOK true; :exit;
:error true;
} }
:local DnsServers ({}); :local DnsServers ({});
@ -89,8 +86,7 @@
:if ($DohCurrent = $HostInfo->"doh-url" && [ $IsDNSResolving ] = true) do={ :if ($DohCurrent = $HostInfo->"doh-url" && [ $IsDNSResolving ] = true) do={
$LogPrint debug $ScriptName ("Current DoH server is still up and resolving: " . $DohCurrent); $LogPrint debug $ScriptName ("Current DoH server is still up and resolving: " . $DohCurrent);
:set ExitOK true; :exit;
:error true;
} }
:set ($DohServers->[ :len $DohServers ]) $HostInfo; :set ($DohServers->[ :len $DohServers ]) $HostInfo;
@ -135,8 +131,7 @@
} }
/ip/dns/cache/flush; /ip/dns/cache/flush;
$LogPrint info $ScriptName ("Setting DoH server: " . ($DohServer->"doh-url")); $LogPrint info $ScriptName ("Setting DoH server: " . ($DohServer->"doh-url"));
:set ExitOK true; :exit;
:error true;
} else={ } else={
$LogPrint warning $ScriptName ("Received unexpected response from DoH server: " . \ $LogPrint warning $ScriptName ("Received unexpected response from DoH server: " . \
($DohServer->"doh-url")); ($DohServer->"doh-url"));
@ -144,5 +139,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -8,7 +8,6 @@
# monitor netwatch and send notifications # monitor netwatch and send notifications
# https://rsc.eworm.de/doc/netwatch-notify.md # https://rsc.eworm.de/doc/netwatch-notify.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -80,8 +79,7 @@
} }
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:local ScriptFromTerminalCached [ $ScriptFromTerminal $ScriptName ]; :local ScriptFromTerminalCached [ $ScriptFromTerminal $ScriptName ];
@ -225,5 +223,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -8,7 +8,6 @@
# visualize ospf instance state via leds # visualize ospf instance state via leds
# https://rsc.eworm.de/doc/ospf-to-leds.md # https://rsc.eworm.de/doc/ospf-to-leds.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -20,8 +19,7 @@
:global ScriptLock; :global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:foreach Instance in=[ /routing/ospf/instance/find where comment~"^ospf-to-leds," ] do={ :foreach Instance in=[ /routing/ospf/instance/find where comment~"^ospf-to-leds," ] do={
@ -45,5 +43,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -9,7 +9,6 @@
# download packages and reboot for installation # download packages and reboot for installation
# https://rsc.eworm.de/doc/packages-update.md # https://rsc.eworm.de/doc/packages-update.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -59,28 +58,24 @@
} }
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:if ([ :len [ /system/scheduler/find where name="running-from-backup-partition" ] ] > 0) do={ :if ([ :len [ /system/scheduler/find where name="running-from-backup-partition" ] ] > 0) do={
$LogPrint warning $ScriptName ("Running from backup partition, refusing to act."); $LogPrint warning $ScriptName ("Running from backup partition, refusing to act.");
:set ExitOK true; :exit;
:error false;
} }
:local Update [ /system/package/update/get ]; :local Update [ /system/package/update/get ];
:if ([ :typeof ($Update->"latest-version") ] = "nothing") do={ :if ([ :typeof ($Update->"latest-version") ] = "nothing") do={
$LogPrint warning $ScriptName ("Latest version is not known."); $LogPrint warning $ScriptName ("Latest version is not known.");
:set ExitOK true; :exit;
:error false;
} }
:if ($Update->"installed-version" = $Update->"latest-version") do={ :if ($Update->"installed-version" = $Update->"latest-version") do={
$LogPrint info $ScriptName ("Version " . $Update->"latest-version" . " is already installed."); $LogPrint info $ScriptName ("Version " . $Update->"latest-version" . " is already installed.");
:set ExitOK true; :exit;
:error true;
} }
:local RunOrder ({}); :local RunOrder ({});
@ -111,13 +106,11 @@
$LogPrint info $ScriptName ("User requested to continue anyway."); $LogPrint info $ScriptName ("User requested to continue anyway.");
} else={ } else={
$LogPrint info $ScriptName ("Canceled update..."); $LogPrint info $ScriptName ("Canceled update...");
:set ExitOK true; :exit;
:error false;
} }
} else={ } else={
$LogPrint warning $ScriptName ("Canceled non-interactive update."); $LogPrint warning $ScriptName ("Canceled non-interactive update.");
:set ExitOK true; :exit;
:error false;
} }
} }
} }
@ -136,8 +129,7 @@
} }
} else={ } else={
$LogPrint warning $ScriptName ("Not installing downgrade automatically."); $LogPrint warning $ScriptName ("Not installing downgrade automatically.");
:set ExitOK true; :exit;
:error false;
} }
} }
@ -145,8 +137,7 @@
:local PkgName [ /system/package/get $Package name ]; :local PkgName [ /system/package/get $Package name ];
:if ([ $DownloadPackage $PkgName ($Update->"latest-version") ] = false) do={ :if ([ $DownloadPackage $PkgName ($Update->"latest-version") ] = false) do={
$LogPrint error $ScriptName ("Download for package " . $PkgName . " failed, update aborted."); $LogPrint error $ScriptName ("Download for package " . $PkgName . " failed, update aborted.");
:set ExitOK true; :exit;
:error false;
} }
} }
@ -160,14 +151,12 @@
:put "Do you want to (s)chedule reboot or (r)eboot now? [s/R]"; :put "Do you want to (s)chedule reboot or (r)eboot now? [s/R]";
:if (([ /terminal/inkey timeout=60 ] % 32) = 19) do={ :if (([ /terminal/inkey timeout=60 ] % 32) = 19) do={
$Schedule $ScriptName; $Schedule $ScriptName;
:set ExitOK true; :exit;
:error true;
} }
} else={ } else={
:if ($PackagesUpdateDeferReboot = true || [ :totime $PackagesUpdateDeferReboot ] >= 1d) do={ :if ($PackagesUpdateDeferReboot = true || [ :totime $PackagesUpdateDeferReboot ] >= 1d) do={
$Schedule $ScriptName; $Schedule $ScriptName;
:set ExitOK true; :exit;
:error true;
} }
} }
@ -175,5 +164,5 @@
:delay 1s; :delay 1s;
/system/reboot; /system/reboot;
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -8,7 +8,6 @@
# run scripts on ppp up # run scripts on ppp up
# https://rsc.eworm.de/doc/ppp-on-up.md # https://rsc.eworm.de/doc/ppp-on-up.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -21,8 +20,7 @@
:if ([ :typeof $Interface ] = "nothing") do={ :if ([ :typeof $Interface ] = "nothing") do={
$LogPrint error $ScriptName ("This script is supposed to run from ppp on-up script hook."); $LogPrint error $ScriptName ("This script is supposed to run from ppp on-up script hook.");
:set ExitOK true; :exit;
:error false;
} }
:local IntName [ /interface/get $Interface name ]; :local IntName [ /interface/get $Interface name ];
@ -40,5 +38,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -8,7 +8,6 @@
# run action on received SMS # run action on received SMS
# https://rsc.eworm.de/doc/sms-action.md # https://rsc.eworm.de/doc/sms-action.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -24,8 +23,7 @@
:if ([ :typeof $Action ] = "nothing") do={ :if ([ :typeof $Action ] = "nothing") do={
$LogPrint error $ScriptName ("This script is supposed to run from SMS hook with action=..."); $LogPrint error $ScriptName ("This script is supposed to run from SMS hook with action=...");
:set ExitOK true; :exit;
:error false;
} }
:local Code ($SmsAction->$Action); :local Code ($SmsAction->$Action);
@ -37,5 +35,5 @@
$LogPrint warning $ScriptName ("The code for action '" . $Action . "' failed syntax validation!"); $LogPrint warning $ScriptName ("The code for action '" . $Action . "' failed syntax validation!");
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -9,7 +9,6 @@
# forward SMS to e-mail # forward SMS to e-mail
# https://rsc.eworm.de/doc/sms-forward.md # https://rsc.eworm.de/doc/sms-forward.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -29,14 +28,12 @@
:global WaitFullyConnected; :global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:if ([ /tool/sms/get receive-enabled ] = false) do={ :if ([ /tool/sms/get receive-enabled ] = false) do={
$LogPrintOnce warning $ScriptName ("Receiving of SMS is not enabled."); $LogPrintOnce warning $ScriptName ("Receiving of SMS is not enabled.");
:set ExitOK true; :exit;
:error false;
} }
$WaitFullyConnected; $WaitFullyConnected;
@ -45,8 +42,7 @@
:if ([ /interface/lte/get ($Settings->"port") running ] != true) do={ :if ([ /interface/lte/get ($Settings->"port") running ] != true) do={
$LogPrint info $ScriptName ("The LTE interface is not in running state, skipping."); $LogPrint info $ScriptName ("The LTE interface is not in running state, skipping.");
:set ExitOK true; :exit;
:error true;
} }
# forward SMS in a loop # forward SMS in a loop
@ -107,5 +103,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -9,7 +9,6 @@
# use Telegram to chat with your Router and send commands # use Telegram to chat with your Router and send commands
# https://rsc.eworm.de/doc/telegram-chat.md # https://rsc.eworm.de/doc/telegram-chat.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -48,8 +47,7 @@
:global WaitFullyConnected; :global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
$WaitFullyConnected; $WaitFullyConnected;
@ -63,8 +61,7 @@
:if ([ $CertificateAvailable "Go Daddy Root Certificate Authority - G2" "fetch" ] = false) do={ :if ([ $CertificateAvailable "Go Daddy Root Certificate Authority - G2" "fetch" ] = false) do={
$LogPrint warning $ScriptName ("Downloading required certificate failed."); $LogPrint warning $ScriptName ("Downloading required certificate failed.");
:set ExitOK true; :exit;
:error false;
} }
$RandomDelay $TelegramRandomDelay; $RandomDelay $TelegramRandomDelay;
@ -89,8 +86,7 @@
:if ($Data = false) do={ :if ($Data = false) do={
$LogPrint warning $ScriptName ("Failed getting updates."); $LogPrint warning $ScriptName ("Failed getting updates.");
:set ExitOK true; :exit;
:error false;
} }
:local JSON [ :deserialize from=json value=$Data ]; :local JSON [ :deserialize from=json value=$Data ];
@ -146,8 +142,7 @@
:local File ("tmpfs/telegram-chat/" . [ $GetRandom20CharAlNum 6 ]); :local File ("tmpfs/telegram-chat/" . [ $GetRandom20CharAlNum 6 ]);
:if ([ $MkDir "tmpfs/telegram-chat" ] = false) do={ :if ([ $MkDir "tmpfs/telegram-chat" ] = false) do={
$LogPrint error $ScriptName ("Failed creating directory!"); $LogPrint error $ScriptName ("Failed creating directory!");
:set ExitOK true; :exit;
:error false;
} }
$LogPrint info $ScriptName ("Running command from update " . $UpdateID . ": " . $Command); $LogPrint info $ScriptName ("Running command from update " . $UpdateID . ": " . $Command);
:execute script=(":do {\n" . $Command . "\n} on-error={ /file/add name=\"" . $File . ".failed\" };" . \ :execute script=(":do {\n" . $Command . "\n} on-error={ /file/add name=\"" . $File . ".failed\" };" . \
@ -197,5 +192,5 @@
:set TelegramChatOffset ([ :pick $TelegramChatOffset 1 3 ], \ :set TelegramChatOffset ([ :pick $TelegramChatOffset 1 3 ], \
[ $IfThenElse ($UpdateID >= $TelegramChatOffset->2) ($UpdateID + 1) ($TelegramChatOffset->2) ]); [ $IfThenElse ($UpdateID >= $TelegramChatOffset->2) ($UpdateID + 1) ($TelegramChatOffset->2) ]);
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -9,7 +9,6 @@
# ipsec remote peer # ipsec remote peer
# https://rsc.eworm.de/doc/update-gre-address.md # https://rsc.eworm.de/doc/update-gre-address.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -21,8 +20,7 @@
:global ScriptLock; :global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
/interface/gre/set remote-address=0.0.0.0 disabled=yes [ find where !running !disabled ]; /interface/gre/set remote-address=0.0.0.0 disabled=yes [ find where !running !disabled ];
@ -42,5 +40,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }

View file

@ -11,7 +11,6 @@
# update local address of tunnelbroker interface # update local address of tunnelbroker interface
# https://rsc.eworm.de/doc/update-tunnelbroker.md # https://rsc.eworm.de/doc/update-tunnelbroker.md
:local ExitOK false;
:onerror Err { :onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady; :global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -24,14 +23,12 @@
:global ScriptLock; :global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={ :if ([ $ScriptLock $ScriptName ] = false) do={
:set ExitOK true; :exit;
:error false;
} }
:if ([ $CertificateAvailable "Starfield Root Certificate Authority - G2" "fetch" ] = false) do={ :if ([ $CertificateAvailable "Starfield Root Certificate Authority - G2" "fetch" ] = false) do={
$LogPrint error $ScriptName ("Downloading required certificate failed."); $LogPrint error $ScriptName ("Downloading required certificate failed.");
:set ExitOK true; :exit;
:error false;
} }
:foreach Interface in=[ /interface/6to4/find where comment~"^tunnelbroker" !disabled ] do={ :foreach Interface in=[ /interface/6to4/find where comment~"^tunnelbroker" !disabled ] do={
@ -54,8 +51,7 @@
:if (!($Data ~ "^(good|nochg) ")) do={ :if (!($Data ~ "^(good|nochg) ")) do={
$LogPrint error $ScriptName ("Failed sending the local address to tunnelbroker or unexpected response!"); $LogPrint error $ScriptName ("Failed sending the local address to tunnelbroker or unexpected response!");
:set ExitOK true; :exit;
:error false;
} }
:local PublicAddress [ :pick $Data ([ :find $Data " " ] + 1) [ :find $Data "\n" ] ]; :local PublicAddress [ :pick $Data ([ :find $Data " " ] + 1) [ :find $Data "\n" ] ];
@ -70,5 +66,5 @@
} }
} }
} do={ } do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err; :global ExitError; $ExitError [ :jobname ] $Err;
} }