Compare commits

..

11 commits

Author SHA1 Message Date
Christian Hesse
eb9960eaa9 doc/mod/ssh-keys-import: update for RouterOS 7.21 2026-01-17 17:00:36 +01:00
Christian Hesse
5ed36f5a53 mod/ssh-keys-import: drop old property
The property name changed in RouterOS 7.21beta2, so bump required
version to 7.21.
2026-01-17 17:00:36 +01:00
Christian Hesse
003b5f4506 telegram-chat: use :continue in loop 2026-01-17 17:00:36 +01:00
Christian Hesse
332c2867c6 telegram-chat: early exit with :exit 2026-01-17 17:00:36 +01:00
Christian Hesse
6acdcb600e netwatch-dns: early exit with :exit 2026-01-17 17:00:36 +01:00
Christian Hesse
24cc13ecbb global-functions: drop $HexToNum 2026-01-17 17:00:36 +01:00
Christian Hesse
b99cc053e1 log-forward: fix indention 2026-01-17 17:00:36 +01:00
Christian Hesse
ccd669742e log-forward: use comparison for ids
This was introduced with RouterOS 7.22beta1.

Initializing $LogForwardLast with boolean value looks odd, but this is
reuqired to match the very first message.
2026-01-17 17:00:36 +01:00
Christian Hesse
b1b9604e6b check-certificates: drop the compatibility workaround...
... and make it depend in RouterOS 7.19 and its builtin certificates.
2026-01-17 17:00:36 +01:00
Christian Hesse
749891216b global-functions: $CertificateAvailable: drop the compatibility workaround...
... and make it depend in RouterOS 7.19 and its builtin certificates.
2026-01-17 17:00:36 +01:00
Christian Hesse
a0f39c0a40 INITIAL-COMMANDS: drop the compatibility workaround...
... and make it depend in RouterOS 7.19 and its builtin certificates.
2026-01-17 17:00:36 +01:00
69 changed files with 492 additions and 317 deletions

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

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

View file

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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

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

View file

@ -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;
} }

View file

@ -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;
}

View file

@ -139,5 +139,5 @@
}
}
} do={
:global ExitError; $ExitError [ :jobname ] $Err;
:global ExitError; $ExitError true [ :jobname ] $Err;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}