aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2024-03-06 23:53:50 +0100
committerGravatar Christian Hesse <mail@eworm.de>2024-03-12 15:27:15 +0100
commit6fd39bd3c5d7c3fe5dca9e92275f60e0b3217f03 (patch)
tree7ced2fbdb536447b537a967e945600ba6dd78c8a
parentb86d6314868596dacdf422db80ef0ff27c61c644 (diff)
parentf0856c264e07804a229668268a457f2154cb373a (diff)
Merge branch 'do-with-on-error' into nextrouteros-7.15beta4-2
-rw-r--r--accesslist-duplicates.capsman.rsc8
-rw-r--r--accesslist-duplicates.local.rsc8
-rw-r--r--accesslist-duplicates.template.rsc8
-rw-r--r--accesslist-duplicates.wifi.rsc8
-rw-r--r--backup-cloud.rsc10
-rw-r--r--backup-email.rsc10
-rw-r--r--backup-partition.rsc10
-rw-r--r--backup-upload.rsc10
-rw-r--r--capsman-download-packages.capsman.rsc10
-rw-r--r--capsman-download-packages.template.rsc10
-rw-r--r--capsman-download-packages.wifi.rsc10
-rw-r--r--capsman-rolling-upgrade.capsman.rsc10
-rw-r--r--capsman-rolling-upgrade.template.rsc10
-rw-r--r--capsman-rolling-upgrade.wifi.rsc10
-rw-r--r--certificate-renew-issued.rsc10
-rw-r--r--check-certificates.rsc10
-rw-r--r--check-health.rsc12
-rw-r--r--check-lte-firmware-upgrade.rsc10
-rw-r--r--check-routeros-update.rsc16
-rw-r--r--collect-wireless-mac.capsman.rsc10
-rw-r--r--collect-wireless-mac.local.rsc10
-rw-r--r--collect-wireless-mac.template.rsc10
-rw-r--r--collect-wireless-mac.wifi.rsc10
-rw-r--r--daily-psk.capsman.rsc10
-rw-r--r--daily-psk.local.rsc10
-rw-r--r--daily-psk.template.rsc10
-rw-r--r--daily-psk.wifi.rsc10
-rw-r--r--dhcp-lease-comment.capsman.rsc10
-rw-r--r--dhcp-lease-comment.local.rsc10
-rw-r--r--dhcp-lease-comment.template.rsc10
-rw-r--r--dhcp-lease-comment.wifi.rsc10
-rw-r--r--dhcp-to-dns.rsc10
-rw-r--r--firmware-upgrade-reboot.rsc14
-rw-r--r--fw-addr-lists.rsc10
-rw-r--r--gps-track.rsc10
-rw-r--r--hotspot-to-wpa-cleanup.capsman.rsc10
-rw-r--r--hotspot-to-wpa-cleanup.template.rsc10
-rw-r--r--hotspot-to-wpa-cleanup.wifi.rsc10
-rw-r--r--hotspot-to-wpa.capsman.rsc19
-rw-r--r--hotspot-to-wpa.template.rsc19
-rw-r--r--hotspot-to-wpa.wifi.rsc19
-rw-r--r--ipsec-to-dns.rsc10
-rw-r--r--ipv6-update.rsc13
-rw-r--r--lease-script.rsc16
-rw-r--r--log-forward.rsc12
-rw-r--r--mode-button.rsc8
-rw-r--r--netwatch-dns.rsc16
-rw-r--r--netwatch-notify.rsc10
-rw-r--r--ospf-to-leds.rsc10
-rw-r--r--packages-update.rsc12
-rw-r--r--ppp-on-up.rsc11
-rw-r--r--sms-action.rsc13
-rw-r--r--sms-forward.rsc12
-rw-r--r--telegram-chat.rsc10
-rw-r--r--update-gre-address.rsc10
-rw-r--r--update-tunnelbroker.rsc10
56 files changed, 252 insertions, 362 deletions
diff --git a/accesslist-duplicates.capsman.rsc b/accesslist-duplicates.capsman.rsc
index f781eb3..2ce8302 100644
--- a/accesslist-duplicates.capsman.rsc
+++ b/accesslist-duplicates.capsman.rsc
@@ -13,8 +13,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:local Seen ({});
@@ -31,6 +31,4 @@
}
:set ($Seen->$Mac) 1;
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/accesslist-duplicates.local.rsc b/accesslist-duplicates.local.rsc
index b235cd1..51ef6f3 100644
--- a/accesslist-duplicates.local.rsc
+++ b/accesslist-duplicates.local.rsc
@@ -13,8 +13,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:local Seen ({});
@@ -31,6 +31,4 @@
}
:set ($Seen->$Mac) 1;
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/accesslist-duplicates.template.rsc b/accesslist-duplicates.template.rsc
index c65e9e0..770fb30 100644
--- a/accesslist-duplicates.template.rsc
+++ b/accesslist-duplicates.template.rsc
@@ -14,8 +14,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:local Seen ({});
@@ -40,6 +40,4 @@
}
:set ($Seen->$Mac) 1;
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/accesslist-duplicates.wifi.rsc b/accesslist-duplicates.wifi.rsc
index 04ac19c..65f8aaa 100644
--- a/accesslist-duplicates.wifi.rsc
+++ b/accesslist-duplicates.wifi.rsc
@@ -13,8 +13,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:local Seen ({});
@@ -31,6 +31,4 @@
}
:set ($Seen->$Mac) 1;
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/backup-cloud.rsc b/backup-cloud.rsc
index 2846d75..a3dfe0c 100644
--- a/backup-cloud.rsc
+++ b/backup-cloud.rsc
@@ -12,8 +12,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global BackupRandomDelay;
:global Identity;
@@ -32,7 +32,7 @@
:global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
$WaitFullyConnected;
@@ -77,6 +77,4 @@
$LogPrintExit2 error $ScriptName ("Failed uploading backup for " . $Identity . " to cloud!") true;
}
/file/remove "tmpfs/backup-cloud";
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/backup-email.rsc b/backup-email.rsc
index c5b4568..9f6e31a 100644
--- a/backup-email.rsc
+++ b/backup-email.rsc
@@ -12,8 +12,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global BackupPassword;
:global BackupRandomDelay;
@@ -46,7 +46,7 @@
}
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
$WaitFullyConnected;
@@ -114,6 +114,4 @@
:delay 1s;
:set I ($I + 1);
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/backup-partition.rsc b/backup-partition.rsc
index 74dccfe..1238fab 100644
--- a/backup-partition.rsc
+++ b/backup-partition.rsc
@@ -12,14 +12,14 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global LogPrintExit2;
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
:if ([ :len [ /partitions/find ] ] < 2) do={
@@ -47,6 +47,4 @@
$LogPrintExit2 error $ScriptName ("Failed saving configuration to partition '" . \
$FallbackTo . "'!") true;
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/backup-upload.rsc b/backup-upload.rsc
index c2b3285..2b42730 100644
--- a/backup-upload.rsc
+++ b/backup-upload.rsc
@@ -12,8 +12,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global BackupPassword;
:global BackupRandomDelay;
@@ -45,7 +45,7 @@
}
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
$WaitFullyConnected;
@@ -153,6 +153,4 @@
:if ($Failed = 1) do={
:error "An error occured!";
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/capsman-download-packages.capsman.rsc b/capsman-download-packages.capsman.rsc
index cb82a37..d4e900d 100644
--- a/capsman-download-packages.capsman.rsc
+++ b/capsman-download-packages.capsman.rsc
@@ -14,8 +14,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global CleanFilePath;
:global DownloadPackage;
@@ -25,7 +25,7 @@
:global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
$WaitFullyConnected;
@@ -78,6 +78,4 @@
/caps-man/remote-cap/upgrade [ find where version!=$InstalledVersion ];
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/capsman-download-packages.template.rsc b/capsman-download-packages.template.rsc
index a76071e..cd4a83b 100644
--- a/capsman-download-packages.template.rsc
+++ b/capsman-download-packages.template.rsc
@@ -15,8 +15,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global CleanFilePath;
:global DownloadPackage;
@@ -26,7 +26,7 @@
:global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
$WaitFullyConnected;
@@ -89,6 +89,4 @@
/interface/wifi/capsman/remote-cap/upgrade [ find where version!=$InstalledVersion ];
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/capsman-download-packages.wifi.rsc b/capsman-download-packages.wifi.rsc
index 89af381..633830a 100644
--- a/capsman-download-packages.wifi.rsc
+++ b/capsman-download-packages.wifi.rsc
@@ -14,8 +14,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global CleanFilePath;
:global DownloadPackage;
@@ -25,7 +25,7 @@
:global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
$WaitFullyConnected;
@@ -80,6 +80,4 @@
/interface/wifi/capsman/remote-cap/upgrade [ find where version!=$InstalledVersion ];
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/capsman-rolling-upgrade.capsman.rsc b/capsman-rolling-upgrade.capsman.rsc
index 9379b24..16a3498 100644
--- a/capsman-rolling-upgrade.capsman.rsc
+++ b/capsman-rolling-upgrade.capsman.rsc
@@ -15,14 +15,14 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global LogPrintExit2;
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
:local InstalledVersion [ /system/package/update/get installed-version ];
@@ -43,6 +43,4 @@
:delay ($Delay . "s");
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/capsman-rolling-upgrade.template.rsc b/capsman-rolling-upgrade.template.rsc
index 731dbeb..45a5f8e 100644
--- a/capsman-rolling-upgrade.template.rsc
+++ b/capsman-rolling-upgrade.template.rsc
@@ -16,14 +16,14 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global LogPrintExit2;
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
:local InstalledVersion [ /system/package/update/get installed-version ];
@@ -51,6 +51,4 @@
:delay ($Delay . "s");
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/capsman-rolling-upgrade.wifi.rsc b/capsman-rolling-upgrade.wifi.rsc
index 205d1d8..63245dc 100644
--- a/capsman-rolling-upgrade.wifi.rsc
+++ b/capsman-rolling-upgrade.wifi.rsc
@@ -15,14 +15,14 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global LogPrintExit2;
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
:local InstalledVersion [ /system/package/update/get installed-version ];
@@ -44,6 +44,4 @@
:delay ($Delay . "s");
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/certificate-renew-issued.rsc b/certificate-renew-issued.rsc
index 7bf4128..a360a3f 100644
--- a/certificate-renew-issued.rsc
+++ b/certificate-renew-issued.rsc
@@ -11,8 +11,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global CertIssuedExportPass;
@@ -21,7 +21,7 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
:foreach Cert in=[ /certificate/find where issued expires-after<3w ] do={
@@ -45,6 +45,4 @@
$LogPrintExit2 info $ScriptName ("Issued a new certificate for \"" . $CertVal->"common-name" . "\".") false;
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/check-certificates.rsc b/check-certificates.rsc
index e470b59..edde7f3 100644
--- a/check-certificates.rsc
+++ b/check-certificates.rsc
@@ -11,8 +11,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global CertRenewTime;
:global CertRenewUrl;
@@ -132,7 +132,7 @@
}
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
$WaitFullyConnected;
@@ -216,6 +216,4 @@
", it is invalid after " . ($CertVal->"invalid-after") . ".") false;
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/check-health.rsc b/check-health.rsc
index df76d25..91330fc 100644
--- a/check-health.rsc
+++ b/check-health.rsc
@@ -11,8 +11,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global CheckHealthCPUUtilization;
:global CheckHealthCPUUtilizationNotified;
@@ -40,7 +40,7 @@
}
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
:local Resource [ /system/resource/get ];
@@ -78,7 +78,7 @@
:if ([ :len [ /system/health/find ] ] = 0) do={
$LogPrintExit2 debug $ScriptName ("Your device does not provide any health values.") false;
- :return true;
+ :error true;
}
:if ([ :typeof $CheckHealthLast ] != "array") do={
@@ -175,6 +175,4 @@
}
:set ($CheckHealthLast->$Name) $Value;
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/check-lte-firmware-upgrade.rsc b/check-lte-firmware-upgrade.rsc
index 18109fb..f2a6e37 100644
--- a/check-lte-firmware-upgrade.rsc
+++ b/check-lte-firmware-upgrade.rsc
@@ -11,15 +11,15 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global SentLteFirmwareUpgradeNotification;
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
:if ([ :typeof $SentLteFirmwareUpgradeNotification ] != "array") do={
@@ -100,6 +100,4 @@
:foreach Interface in=[ /interface/lte/find ] do={
$CheckInterface $ScriptName $Interface;
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/check-routeros-update.rsc b/check-routeros-update.rsc
index ae0038c..a68762b 100644
--- a/check-routeros-update.rsc
+++ b/check-routeros-update.rsc
@@ -11,8 +11,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global Identity;
:global SafeUpdateAll;
@@ -42,7 +42,7 @@
}
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
$WaitFullyConnected;
@@ -56,7 +56,7 @@
:if ([ $ScriptFromTerminal $ScriptName ] = true && ($Update->"installed-version") = ($Update->"latest-version")) do={
$LogPrintExit2 info $ScriptName ("System is already up to date.") false;
- :return true;
+ :error true;
}
:local NumInstalled [ $VersionToNum ($Update->"installed-version") ];
@@ -133,7 +133,7 @@
:if ($SentRouterosUpdateNotification = $Update->"latest-version") do={
$LogPrintExit2 info $ScriptName ("Already sent the RouterOS update notification for version " . \
$Update->"latest-version" . ".") false;
- :return true;
+ :error true;
}
$SendNotification2 ({ origin=$ScriptName; \
@@ -148,7 +148,7 @@
:if ($SentRouterosUpdateNotification = $Update->"latest-version") do={
$LogPrintExit2 info $ScriptName ("Already sent the RouterOS downgrade notification for version " . \
$Update->"latest-version" . ".") false;
- :return true;
+ :error true;
}
$SendNotification2 ({ origin=$ScriptName; \
@@ -160,6 +160,4 @@
" is available for downgrade.") false;
:set SentRouterosUpdateNotification ($Update->"latest-version");
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/collect-wireless-mac.capsman.rsc b/collect-wireless-mac.capsman.rsc
index 3a10b1f..5423624 100644
--- a/collect-wireless-mac.capsman.rsc
+++ b/collect-wireless-mac.capsman.rsc
@@ -14,8 +14,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global Identity;
@@ -29,7 +29,7 @@
:global SymbolForNotification;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
- :return false;
+ :error false;
}
:if ([ :len [ /caps-man/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={
@@ -93,6 +93,4 @@
$LogPrintExit2 debug $ScriptName ("No mac address available... Ignoring.") false;
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/collect-wireless-mac.local.rsc b/collect-wireless-mac.local.rsc
index f6f898e..a4e81a3 100644
--- a/collect-wireless-mac.local.rsc
+++ b/collect-wireless-mac.local.rsc
@@ -14,8 +14,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global Identity;
@@ -29,7 +29,7 @@
:global SymbolForNotification;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
- :return false;
+ :error false;
}
:if ([ :len [ /interface/wireless/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={
@@ -94,6 +94,4 @@
$LogPrintExit2 debug $ScriptName ("No mac address available... Ignoring.") false;
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/collect-wireless-mac.template.rsc b/collect-wireless-mac.template.rsc
index e633e03..f647eb3 100644
--- a/collect-wireless-mac.template.rsc
+++ b/collect-wireless-mac.template.rsc
@@ -15,8 +15,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global Identity;
@@ -30,7 +30,7 @@
:global SymbolForNotification;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
- :return false;
+ :error false;
}
:if ([ :len [ /caps-man/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={
@@ -111,6 +111,4 @@
$LogPrintExit2 debug $ScriptName ("No mac address available... Ignoring.") false;
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/collect-wireless-mac.wifi.rsc b/collect-wireless-mac.wifi.rsc
index c866bcc..063d6dc 100644
--- a/collect-wireless-mac.wifi.rsc
+++ b/collect-wireless-mac.wifi.rsc
@@ -14,8 +14,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global Identity;
@@ -29,7 +29,7 @@
:global SymbolForNotification;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
- :return false;
+ :error false;
}
:if ([ :len [ /interface/wifi/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={
@@ -93,6 +93,4 @@
$LogPrintExit2 debug $ScriptName ("No mac address available... Ignoring.") false;
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/daily-psk.capsman.rsc b/daily-psk.capsman.rsc
index 85e05b6..c9c0186 100644
--- a/daily-psk.capsman.rsc
+++ b/daily-psk.capsman.rsc
@@ -14,8 +14,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global DailyPskMatchComment;
:global DailyPskQrCodeUrl;
@@ -31,7 +31,7 @@
:global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
$WaitFullyConnected;
@@ -89,6 +89,4 @@
}
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/daily-psk.local.rsc b/daily-psk.local.rsc
index 108c711..228efc8 100644
--- a/daily-psk.local.rsc
+++ b/daily-psk.local.rsc
@@ -14,8 +14,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global DailyPskMatchComment;
:global DailyPskQrCodeUrl;
@@ -31,7 +31,7 @@
:global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
$WaitFullyConnected;
@@ -88,6 +88,4 @@
}
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/daily-psk.template.rsc b/daily-psk.template.rsc
index c45f34a..4403fe6 100644
--- a/daily-psk.template.rsc
+++ b/daily-psk.template.rsc
@@ -15,8 +15,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global DailyPskMatchComment;
:global DailyPskQrCodeUrl;
@@ -32,7 +32,7 @@
:global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
$WaitFullyConnected;
@@ -104,6 +104,4 @@
}
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/daily-psk.wifi.rsc b/daily-psk.wifi.rsc
index 0ba22ab..e9b5199 100644
--- a/daily-psk.wifi.rsc
+++ b/daily-psk.wifi.rsc
@@ -14,8 +14,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global DailyPskMatchComment;
:global DailyPskQrCodeUrl;
@@ -31,7 +31,7 @@
:global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
$WaitFullyConnected;
@@ -89,6 +89,4 @@
}
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/dhcp-lease-comment.capsman.rsc b/dhcp-lease-comment.capsman.rsc
index 09893ce..1b61167 100644
--- a/dhcp-lease-comment.capsman.rsc
+++ b/dhcp-lease-comment.capsman.rsc
@@ -14,14 +14,14 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global LogPrintExit2;
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
:foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={
@@ -36,6 +36,4 @@
/ip/dhcp-server/lease/set comment=$NewComment $Lease;
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/dhcp-lease-comment.local.rsc b/dhcp-lease-comment.local.rsc
index a5e9330..5401a77 100644
--- a/dhcp-lease-comment.local.rsc
+++ b/dhcp-lease-comment.local.rsc
@@ -14,14 +14,14 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global LogPrintExit2;
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
:foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={
@@ -36,6 +36,4 @@
/ip/dhcp-server/lease/set comment=$NewComment $Lease;
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/dhcp-lease-comment.template.rsc b/dhcp-lease-comment.template.rsc
index d7f36a3..6ed8fc3 100644
--- a/dhcp-lease-comment.template.rsc
+++ b/dhcp-lease-comment.template.rsc
@@ -15,14 +15,14 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global LogPrintExit2;
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
:foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={
@@ -41,6 +41,4 @@
/ip/dhcp-server/lease/set comment=$NewComment $Lease;
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/dhcp-lease-comment.wifi.rsc b/dhcp-lease-comment.wifi.rsc
index 2552b5a..62ed03d 100644
--- a/dhcp-lease-comment.wifi.rsc
+++ b/dhcp-lease-comment.wifi.rsc
@@ -14,14 +14,14 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global LogPrintExit2;
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
:foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={
@@ -36,6 +36,4 @@
/ip/dhcp-server/lease/set comment=$NewComment $Lease;
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/dhcp-to-dns.rsc b/dhcp-to-dns.rsc
index df6ae01..84a1e84 100644
--- a/dhcp-to-dns.rsc
+++ b/dhcp-to-dns.rsc
@@ -12,8 +12,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global Domain;
:global Identity;
@@ -27,7 +27,7 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
- :return false;
+ :error false;
}
:local Ttl 5m;
@@ -123,6 +123,4 @@
$LogPrintExit2 debug $ScriptName ("No address available... Ignoring.") false;
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/firmware-upgrade-reboot.rsc b/firmware-upgrade-reboot.rsc
index bd28f12..6499d27 100644
--- a/firmware-upgrade-reboot.rsc
+++ b/firmware-upgrade-reboot.rsc
@@ -11,26 +11,26 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global LogPrintExit2;
:global ScriptLock;
:global VersionToNum;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
:local RouterBoard [ /system/routerboard/get ];
:if ($RouterBoard->"current-firmware" = $RouterBoard->"upgrade-firmware") do={
$LogPrintExit2 info $ScriptName ("Current and upgrade firmware match with version " . \
$RouterBoard->"current-firmware" . ".") false;
- :return true;
+ :error true;
}
:if ([ $VersionToNum ($RouterBoard->"current-firmware") ] > [ $VersionToNum ($RouterBoard->"upgrade-firmware") ]) do={
$LogPrintExit2 info $ScriptName ("Different firmware version is available, but it is a downgrade. Ignoring.") false;
- :return true;
+ :error true;
}
:if ([ /system/routerboard/settings/get auto-upgrade ] = false) do={
@@ -51,6 +51,4 @@
$LogPrintExit2 info $ScriptName ("Firmware upgrade successful, rebooting.") false;
/system/reboot;
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/fw-addr-lists.rsc b/fw-addr-lists.rsc
index 8ba0147..6071f7b 100644
--- a/fw-addr-lists.rsc
+++ b/fw-addr-lists.rsc
@@ -11,8 +11,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global FetchUserAgent;
:global FwAddrLists;
@@ -35,7 +35,7 @@
}
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
$WaitFullyConnected;
@@ -156,6 +156,4 @@
$LogPrintExit2 info $ScriptName ("list: " . $FwListName . " -- added: " . $CntAdd . " - renewed: " . $CntRenew . " - removed: " . $CntRemove) false;
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/gps-track.rsc b/gps-track.rsc
index cef95f2..c40e2e0 100644
--- a/gps-track.rsc
+++ b/gps-track.rsc
@@ -11,8 +11,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global GpsTrackUrl;
:global Identity;
@@ -22,7 +22,7 @@
:global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
$WaitFullyConnected;
@@ -47,6 +47,4 @@
} else={
$LogPrintExit2 debug $ScriptName ("GPS data not valid.") false;
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/hotspot-to-wpa-cleanup.capsman.rsc b/hotspot-to-wpa-cleanup.capsman.rsc
index 62beacc..ba74260 100644
--- a/hotspot-to-wpa-cleanup.capsman.rsc
+++ b/hotspot-to-wpa-cleanup.capsman.rsc
@@ -14,8 +14,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global EitherOr;
:global LogPrintExit2;
@@ -23,7 +23,7 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
- :return false;
+ :error false;
}
:local DHCPServers ({});
@@ -71,6 +71,4 @@
/ip/dhcp-server/lease/remove $Lease;
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/hotspot-to-wpa-cleanup.template.rsc b/hotspot-to-wpa-cleanup.template.rsc
index bba9f0e..c46d75d 100644
--- a/hotspot-to-wpa-cleanup.template.rsc
+++ b/hotspot-to-wpa-cleanup.template.rsc
@@ -15,8 +15,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global EitherOr;
:global LogPrintExit2;
@@ -24,7 +24,7 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
- :return false;
+ :error false;
}
:local DHCPServers ({});
@@ -78,6 +78,4 @@
/ip/dhcp-server/lease/remove $Lease;
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/hotspot-to-wpa-cleanup.wifi.rsc b/hotspot-to-wpa-cleanup.wifi.rsc
index a44064f..3e5799a 100644
--- a/hotspot-to-wpa-cleanup.wifi.rsc
+++ b/hotspot-to-wpa-cleanup.wifi.rsc
@@ -14,8 +14,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global EitherOr;
:global LogPrintExit2;
@@ -23,7 +23,7 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
- :return false;
+ :error false;
}
:local DHCPServers ({});
@@ -71,6 +71,4 @@
/ip/dhcp-server/lease/remove $Lease;
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/hotspot-to-wpa.capsman.rsc b/hotspot-to-wpa.capsman.rsc
index 7498ae2..a6ad2a1 100644
--- a/hotspot-to-wpa.capsman.rsc
+++ b/hotspot-to-wpa.capsman.rsc
@@ -13,21 +13,22 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
- :local MacAddress [ :tostr $2 ];
- :local UserName [ :tostr $3 ];
+:do {
+ :local ScriptName [ :jobname ];
:global EitherOr;
:global LogPrintExit2;
:global ParseKeyValueStore;
:global ScriptLock;
+ :local MacAddress $"mac-address";
+ :local UserName $username;
+
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
- :if ([ :len $MacAddress ] = 0 || [ :len $UserName ] = 0) do={
+ :if ([ :typeof $MacAddress ] = "nothing" || [ :typeof $UserName ] = "nothing") do={
$LogPrintExit2 error $ScriptName ("This script is supposed to run from hotspot on login.") true;
}
@@ -55,7 +56,7 @@
:if ($Template->"action" = "reject") do={
$LogPrintExit2 info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'.") false;
- :return true;
+ :error true;
}
# allow login page to load
@@ -93,6 +94,4 @@
:delay 2s;
/caps-man/access-list/set $Entry action=accept;
-}
-
-$Main [ :jobname ] $"mac-address" $username;
+} on-error={ }
diff --git a/hotspot-to-wpa.template.rsc b/hotspot-to-wpa.template.rsc
index c96096c..b7869c4 100644
--- a/hotspot-to-wpa.template.rsc
+++ b/hotspot-to-wpa.template.rsc
@@ -14,21 +14,22 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
- :local MacAddress [ :tostr $2 ];
- :local UserName [ :tostr $3 ];
+:do {
+ :local ScriptName [ :jobname ];
:global EitherOr;
:global LogPrintExit2;
:global ParseKeyValueStore;
:global ScriptLock;
+ :local MacAddress $"mac-address";
+ :local UserName $username;
+
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
- :if ([ :len $MacAddress ] = 0 || [ :len $UserName ] = 0) do={
+ :if ([ :typeof $MacAddress ] = "nothing" || [ :typeof $UserName ] = "nothing") do={
$LogPrintExit2 error $ScriptName ("This script is supposed to run from hotspot on login.") true;
}
@@ -62,7 +63,7 @@
:if ($Template->"action" = "reject") do={
$LogPrintExit2 info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'.") false;
- :return true;
+ :error true;
}
# allow login page to load
@@ -113,6 +114,4 @@
:delay 2s;
/caps-man/access-list/set $Entry action=accept;
/interface/wifi/access-list/set $Entry action=accept;
-}
-
-$Main [ :jobname ] $"mac-address" $username;
+} on-error={ }
diff --git a/hotspot-to-wpa.wifi.rsc b/hotspot-to-wpa.wifi.rsc
index 83f490d..e728d7f 100644
--- a/hotspot-to-wpa.wifi.rsc
+++ b/hotspot-to-wpa.wifi.rsc
@@ -13,21 +13,22 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
- :local MacAddress [ :tostr $2 ];
- :local UserName [ :tostr $3 ];
+:do {
+ :local ScriptName [ :jobname ];
:global EitherOr;
:global LogPrintExit2;
:global ParseKeyValueStore;
:global ScriptLock;
+ :local MacAddress $"mac-address";
+ :local UserName $username;
+
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
- :if ([ :len $MacAddress ] = 0 || [ :len $UserName ] = 0) do={
+ :if ([ :typeof $MacAddress ] = "nothing" || [ :typeof $UserName ] = "nothing") do={
$LogPrintExit2 error $ScriptName ("This script is supposed to run from hotspot on login.") true;
}
@@ -55,7 +56,7 @@
:if ($Template->"action" = "reject") do={
$LogPrintExit2 info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'.") false;
- :return true;
+ :error true;
}
# allow login page to load
@@ -90,6 +91,4 @@
:delay 2s;
/interface/wifi/access-list/set $Entry action=accept;
-}
-
-$Main [ :jobname ] $"mac-address" $username;
+} on-error={ }
diff --git a/ipsec-to-dns.rsc b/ipsec-to-dns.rsc
index e19a11b..03abf59 100644
--- a/ipsec-to-dns.rsc
+++ b/ipsec-to-dns.rsc
@@ -11,8 +11,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global Domain;
:global HostNameInZone;
@@ -26,7 +26,7 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
:local Zone \
@@ -76,6 +76,4 @@
/ip/dns/static/add name=$Fqdn address=($PeerVal->"dynamic-address") ttl=$Ttl comment=$Comment place-before=$PlaceBefore;
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/ipv6-update.rsc b/ipv6-update.rsc
index d173347..8ce1e4d 100644
--- a/ipv6-update.rsc
+++ b/ipv6-update.rsc
@@ -11,16 +11,17 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
- :local PdPrefix $2;
+:do {
+ :local ScriptName [ :jobname ];
:global LogPrintExit2;
:global ParseKeyValueStore;
:global ScriptLock;
+ :local PdPrefix $"pd-prefix";
+
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
:if ([ :typeof $PdPrefix ] = "nothing") do={
@@ -82,6 +83,4 @@
}
}
}
-}
-
-$Main [ :jobname ] $"pd-prefix";
+} on-error={ }
diff --git a/lease-script.rsc b/lease-script.rsc
index 582f8ff..0f6b7f8 100644
--- a/lease-script.rsc
+++ b/lease-script.rsc
@@ -11,12 +11,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
- :local leaseActIP [ :tostr $2 ];
- :local leaseActMAC [ :tostr $2 ];
- :local leaseServerName [ :tostr $2 ];
- :local leaseBound [ :tostr $2 ];
+:do {
+ :local ScriptName [ :jobname ];
:global Grep;
:global IfThenElse;
@@ -35,12 +31,12 @@
"de" "" ] . "assigned lease " . $leaseActIP . " to " . $leaseActMAC) false;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
- :return false;
+ :error false;
}
:if ([ :len [ /system/script/job/find where script=$ScriptName ] ] > 1) do={
$LogPrintExit2 debug $ScriptName ("More invocations are waiting, exiting early.") false;
- :return true;
+ :error true;
}
:local RunOrder ({});
@@ -59,6 +55,4 @@
$LogPrintExit2 warning $ScriptName ("Running script '" . $Script . "' failed!") false;
}
}
-}
-
-$Main [ :jobname ] $leaseActIP $leaseActMAC $leaseServerName $leaseBound;
+} on-error={ }
diff --git a/log-forward.rsc b/log-forward.rsc
index b9dbc8b..09e3b84 100644
--- a/log-forward.rsc
+++ b/log-forward.rsc
@@ -11,8 +11,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global Identity;
:global LogForwardFilter;
@@ -33,7 +33,7 @@
:global SymbolForNotification;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
:if ([ :typeof $LogForwardRateLimit ] = "nothing") do={
@@ -43,7 +43,7 @@
:if ($LogForwardRateLimit > 30) do={
:set LogForwardRateLimit ($LogForwardRateLimit - 1);
$LogPrintExit2 info $ScriptName ("Rate limit in action, not forwarding logs, if any!") false;
- :return true;
+ :error false;
}
:local Count 0;
@@ -99,6 +99,4 @@
} else={
:set LogForwardRateLimit [ $MAX 0 ($LogForwardRateLimit - 1) ];
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/mode-button.rsc b/mode-button.rsc
index 0cd9167..07788cb 100644
--- a/mode-button.rsc
+++ b/mode-button.rsc
@@ -11,8 +11,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global ModeButton;
@@ -78,6 +78,4 @@
$LogPrintExit2 debug $ScriptName ("Updating scheduler _ModeButtonScheduler...") false;
/system/scheduler/set $Scheduler start-time=[ /system/clock/get time ];
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/netwatch-dns.rsc b/netwatch-dns.rsc
index 2468d35..76f2685 100644
--- a/netwatch-dns.rsc
+++ b/netwatch-dns.rsc
@@ -11,8 +11,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global CertificateAvailable;
:global EitherOr;
@@ -21,13 +21,13 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
:local SettleTime (5m30s - [ /system/resource/get uptime ]);
:if ($SettleTime > 0s) do={
$LogPrintExit2 info $ScriptName ("System just booted, giving netwatch " . $SettleTime . " to settle.") false;
- :return true;
+ :error true;
}
:local DnsServers ({});
@@ -84,7 +84,7 @@
:if ($DohCurrent = $HostInfo->"doh-url") do={
$LogPrintExit2 debug $ScriptName ("Current DoH server is still up: " . $DohCurrent) false;
- :return true;
+ :error true;
}
:set ($DohServers->[ :len $DohServers ]) $HostInfo;
@@ -121,13 +121,11 @@
/ip/dns/set use-doh-server=($DohServer->"doh-url") verify-doh-cert=yes;
/ip/dns/cache/flush;
$LogPrintExit2 info $ScriptName ("Setting DoH server: " . ($DohServer->"doh-url")) false;
- :return true;
+ :error true;
} else={
$LogPrintExit2 warning $ScriptName ("Received unexpected response from DoH server: " . \
($DohServer->"doh-url")) false;
}
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/netwatch-notify.rsc b/netwatch-notify.rsc
index ce74ffa..90d26f1 100644
--- a/netwatch-notify.rsc
+++ b/netwatch-notify.rsc
@@ -11,8 +11,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global NetwatchNotify;
@@ -76,7 +76,7 @@
}
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
:local ScriptFromTerminalCached [ $ScriptFromTerminal $ScriptName ];
@@ -217,6 +217,4 @@
"since"=($Metric->"since") };
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/ospf-to-leds.rsc b/ospf-to-leds.rsc
index 3ca16db..73c9922 100644
--- a/ospf-to-leds.rsc
+++ b/ospf-to-leds.rsc
@@ -11,15 +11,15 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global LogPrintExit2;
:global ParseKeyValueStore;
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
:foreach Instance in=[ /routing/ospf/instance/find where comment~"^ospf-to-leds," ] do={
@@ -42,6 +42,4 @@
/system/leds/set type=off [ find where leds=$LED ];
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/packages-update.rsc b/packages-update.rsc
index 5b6d158..abcbfd8 100644
--- a/packages-update.rsc
+++ b/packages-update.rsc
@@ -11,8 +11,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global DownloadPackage;
:global Grep;
@@ -44,7 +44,7 @@
}
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
:local Update [ /system/package/update/get ];
@@ -55,7 +55,7 @@
:if ($Update->"installed-version" = $Update->"latest-version") do={
$LogPrintExit2 info $ScriptName ("Version " . $Update->"latest-version" . " is already installed.") false;
- :return true;
+ :error true;
}
:local NumInstalled [ $VersionToNum ($Update->"installed-version") ];
@@ -134,6 +134,4 @@
$LogPrintExit2 info $ScriptName ("Rebooting for update.") false;
:delay 1s;
/system/reboot;
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/ppp-on-up.rsc b/ppp-on-up.rsc
index ae259d7..0cc2405 100644
--- a/ppp-on-up.rsc
+++ b/ppp-on-up.rsc
@@ -11,12 +11,13 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
- :local Interface $2;
+:do {
+ :local ScriptName [ :jobname ];
:global LogPrintExit2;
+ :local Interface $interface;
+
:if ([ :typeof $Interface ] = "nothing") do={
$LogPrintExit2 error $ScriptName ("This script is supposed to run from ppp on-up script hook.") true;
}
@@ -35,6 +36,4 @@
$LogPrintExit2 warning $ScriptName ("Running script '" . $ScriptName . "' failed!") false;
}
}
-}
-
-$Main [ :jobname ] $interface;
+} on-error={ }
diff --git a/sms-action.rsc b/sms-action.rsc
index b78a2b2..11d3523 100644
--- a/sms-action.rsc
+++ b/sms-action.rsc
@@ -11,16 +11,17 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
- :local Action [ :tostr $2 ];
+:do {
+ :local ScriptName [ :jobname ];
:global SmsAction;
:global LogPrintExit2;
:global ValidateSyntax;
- :if ([ :len $Action ] = 0) do={
+ :local Action $action;
+
+ :if ([ :typeof $Action ] = "nothing") do={
$LogPrintExit2 error $ScriptName ("This script is supposed to run from SMS hook with action=...") true;
}
@@ -32,6 +33,4 @@
} else={
$LogPrintExit2 warning $ScriptName ("The code for action '" . $Action . "' failed syntax validation!") false;
}
-}
-
-$Main [ :jobname ] $action;
+} on-error={ }
diff --git a/sms-forward.rsc b/sms-forward.rsc
index 7c4488a..2f549b1 100644
--- a/sms-forward.rsc
+++ b/sms-forward.rsc
@@ -12,8 +12,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global Identity;
:global SmsForwardHooks;
@@ -28,7 +28,7 @@
:global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
:if ([ /tool/sms/get receive-enabled ] = false) do={
@@ -41,7 +41,7 @@
:if ([ /interface/lte/get ($Settings->"port") running ] != true) do={
$LogPrintExit2 info $ScriptName ("The LTE interface is not in running state, skipping.") false;
- :return true;
+ :error true;
}
# forward SMS in a loop
@@ -95,6 +95,4 @@
}
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/telegram-chat.rsc b/telegram-chat.rsc
index 528d99c..799569f 100644
--- a/telegram-chat.rsc
+++ b/telegram-chat.rsc
@@ -11,8 +11,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global Identity;
:global TelegramChatActive;
@@ -44,7 +44,7 @@
:global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
$WaitFullyConnected;
@@ -171,6 +171,4 @@
}
:set TelegramChatOffset ([ :pick $TelegramChatOffset 1 3 ], \
[ $IfThenElse ($UpdateID >= $TelegramChatOffset->2) ($UpdateID + 1) ($TelegramChatOffset->2) ]);
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/update-gre-address.rsc b/update-gre-address.rsc
index d9a7a55..78705c5 100644
--- a/update-gre-address.rsc
+++ b/update-gre-address.rsc
@@ -12,15 +12,15 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global CharacterReplace;
:global LogPrintExit2;
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
/interface/gre/set remote-address=0.0.0.0 disabled=yes [ find where !running !disabled ];
@@ -39,6 +39,4 @@
}
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }
diff --git a/update-tunnelbroker.rsc b/update-tunnelbroker.rsc
index 90e3f24..9f316e3 100644
--- a/update-tunnelbroker.rsc
+++ b/update-tunnelbroker.rsc
@@ -13,8 +13,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global CertificateAvailable;
:global LogPrintExit2;
@@ -22,7 +22,7 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
:if ([ $CertificateAvailable "Starfield Secure Certificate Authority - G2" ] = false) do={
@@ -62,6 +62,4 @@
/interface/6to4/set $Interface local-address=$PublicAddress;
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }