aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--accesslist-duplicates.capsman.rsc5
-rw-r--r--accesslist-duplicates.local.rsc5
-rw-r--r--accesslist-duplicates.template.rsc5
-rw-r--r--accesslist-duplicates.wifi.rsc5
-rw-r--r--backup-cloud.rsc7
-rw-r--r--backup-email.rsc10
-rw-r--r--backup-partition.rsc12
-rw-r--r--backup-upload.rsc8
-rw-r--r--capsman-download-packages.capsman.rsc8
-rw-r--r--capsman-download-packages.template.rsc8
-rw-r--r--capsman-download-packages.wifi.rsc8
-rw-r--r--capsman-rolling-upgrade.capsman.rsc6
-rw-r--r--capsman-rolling-upgrade.template.rsc6
-rw-r--r--capsman-rolling-upgrade.wifi.rsc6
-rw-r--r--certificate-renew-issued.rsc6
-rw-r--r--check-certificates.rsc6
-rw-r--r--check-health.rsc7
-rw-r--r--check-lte-firmware-upgrade.rsc6
-rw-r--r--check-routeros-update.rsc27
-rw-r--r--collect-wireless-mac.capsman.rsc6
-rw-r--r--collect-wireless-mac.local.rsc6
-rw-r--r--collect-wireless-mac.template.rsc6
-rw-r--r--collect-wireless-mac.wifi.rsc6
-rw-r--r--daily-psk.capsman.rsc6
-rw-r--r--daily-psk.local.rsc6
-rw-r--r--daily-psk.template.rsc6
-rw-r--r--daily-psk.wifi.rsc6
-rw-r--r--dhcp-lease-comment.capsman.rsc6
-rw-r--r--dhcp-lease-comment.local.rsc6
-rw-r--r--dhcp-lease-comment.template.rsc6
-rw-r--r--dhcp-lease-comment.wifi.rsc6
-rw-r--r--dhcp-to-dns.rsc6
-rw-r--r--firmware-upgrade-reboot.rsc8
-rw-r--r--fw-addr-lists.rsc6
-rw-r--r--global-functions.rsc13
-rw-r--r--gps-track.rsc6
-rw-r--r--hotspot-to-wpa-cleanup.capsman.rsc6
-rw-r--r--hotspot-to-wpa-cleanup.template.rsc6
-rw-r--r--hotspot-to-wpa-cleanup.wifi.rsc6
-rw-r--r--hotspot-to-wpa.capsman.rsc8
-rw-r--r--hotspot-to-wpa.template.rsc8
-rw-r--r--hotspot-to-wpa.wifi.rsc8
-rw-r--r--ipsec-to-dns.rsc6
-rw-r--r--ipv6-update.rsc8
-rw-r--r--lease-script.rsc8
-rw-r--r--log-forward.rsc7
-rw-r--r--mode-button.rsc5
-rw-r--r--netwatch-dns.rsc9
-rw-r--r--netwatch-notify.rsc6
-rw-r--r--ospf-to-leds.rsc6
-rw-r--r--packages-update.rsc14
-rw-r--r--ppp-on-up.rsc6
-rw-r--r--sms-action.rsc6
-rw-r--r--sms-forward.rsc8
-rw-r--r--telegram-chat.rsc9
-rw-r--r--update-gre-address.rsc6
-rw-r--r--update-tunnelbroker.rsc8
57 files changed, 359 insertions, 57 deletions
diff --git a/accesslist-duplicates.capsman.rsc b/accesslist-duplicates.capsman.rsc
index d6e2928..ce0ce11 100644
--- a/accesslist-duplicates.capsman.rsc
+++ b/accesslist-duplicates.capsman.rsc
@@ -13,6 +13,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -31,4 +32,6 @@
}
:set ($Seen->$Mac) 1;
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/accesslist-duplicates.local.rsc b/accesslist-duplicates.local.rsc
index e90842d..aa78fe8 100644
--- a/accesslist-duplicates.local.rsc
+++ b/accesslist-duplicates.local.rsc
@@ -13,6 +13,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -31,4 +32,6 @@
}
:set ($Seen->$Mac) 1;
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/accesslist-duplicates.template.rsc b/accesslist-duplicates.template.rsc
index d275340..d0c282d 100644
--- a/accesslist-duplicates.template.rsc
+++ b/accesslist-duplicates.template.rsc
@@ -14,6 +14,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -40,4 +41,6 @@
}
:set ($Seen->$Mac) 1;
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/accesslist-duplicates.wifi.rsc b/accesslist-duplicates.wifi.rsc
index f4dae4b..b1444e3 100644
--- a/accesslist-duplicates.wifi.rsc
+++ b/accesslist-duplicates.wifi.rsc
@@ -13,6 +13,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -31,4 +32,6 @@
}
:set ($Seen->$Mac) 1;
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/backup-cloud.rsc b/backup-cloud.rsc
index f70752e..4cc7a58 100644
--- a/backup-cloud.rsc
+++ b/backup-cloud.rsc
@@ -12,6 +12,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -34,6 +35,7 @@
:if ([ $ScriptLock $ScriptName ] = false) do={
:set PackagesUpdateBackupFailure true;
+ :set ExitOK true;
:error false;
}
$WaitFullyConnected;
@@ -44,6 +46,7 @@
:if ([ $MkDir ("tmpfs/backup-cloud") ] = false) do={
$LogPrint error $ScriptName ("Failed creating directory!");
+ :set ExitOK true;
:error false;
}
@@ -87,4 +90,6 @@
:set PackagesUpdateBackupFailure true;
}
/file/remove "tmpfs/backup-cloud";
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/backup-email.rsc b/backup-email.rsc
index e507c6e..e1d44ea 100644
--- a/backup-email.rsc
+++ b/backup-email.rsc
@@ -12,6 +12,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -39,17 +40,20 @@
:if ([ :typeof $SendEMail2 ] = "nothing") do={
$LogPrint error $ScriptName ("The module for sending notifications via e-mail is not installed.");
+ :set ExitOK true;
:error false;
}
:if ($BackupSendBinary != true && \
$BackupSendExport != true) do={
$LogPrint error $ScriptName ("Configured to send neither backup nor config export.");
+ :set ExitOK true;
:error false;
}
:if ([ $ScriptLock $ScriptName ] = false) do={
:set PackagesUpdateBackupFailure true;
+ :set ExitOK true;
:error false;
}
$WaitFullyConnected;
@@ -69,6 +73,7 @@
:if ([ $MkDir $DirName ] = false) do={
$LogPrint error $ScriptName ("Failed creating directory!");
+ :set ExitOK true;
:error false;
}
@@ -116,9 +121,12 @@
:if ($I >= 120) do={
$LogPrint warning $ScriptName ("Files are still available, sending e-mail failed.");
:set PackagesUpdateBackupFailure true;
+ :set ExitOK true;
:error false;
}
:delay 1s;
:set I ($I + 1);
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/backup-partition.rsc b/backup-partition.rsc
index 51df454..f1e1c17 100644
--- a/backup-partition.rsc
+++ b/backup-partition.rsc
@@ -12,6 +12,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -42,12 +43,14 @@
:if ([ $ScriptLock $ScriptName ] = false) do={
:set PackagesUpdateBackupFailure true;
+ :set ExitOK true;
:error false;
}
:if ([ :len [ /partitions/find ] ] < 2) do={
$LogPrint error $ScriptName ("Device does not have a fallback partition.");
:set PackagesUpdateBackupFailure true;
+ :set ExitOK true;
:error false;
}
@@ -56,6 +59,7 @@
:if ([ :len $ActiveRunning ] < 1) do={
$LogPrint error $ScriptName ("Device is not running from active partition.");
:set PackagesUpdateBackupFailure true;
+ :set ExitOK true;
:error false;
}
@@ -65,6 +69,7 @@
:if ([ :len $FallbackTo ] < 1) do={
$LogPrint error $ScriptName ("There is no inactive partition named '" . $FallbackToName . "'.");
:set PackagesUpdateBackupFailure true;
+ :set ExitOK true;
:error false;
}
@@ -74,6 +79,7 @@
:if (([ /terminal/inkey timeout=60 ] % 32) = 25) do={
:if ([ $CopyTo $ScriptName $FallbackTo $FallbackToName ] = false) do={
:set PackagesUpdateBackupFailure true;
+ :set ExitOK true;
:error false;
}
}
@@ -86,6 +92,7 @@
($NumInstalled & $BitMask) != ($NumLatest & $BitMask)) do={
:if ([ $CopyTo $ScriptName $FallbackTo $FallbackToName ] = false) do={
:set PackagesUpdateBackupFailure true;
+ :set ExitOK true;
:error false;
}
}
@@ -103,6 +110,9 @@
/system/scheduler/remove [ find where name="running-from-backup-partition" ];
$LogPrint error $ScriptName ("Failed saving configuration to partition '" . $FallbackToName . "'!");
:set PackagesUpdateBackupFailure true;
+ :set ExitOK true;
:error false;
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/backup-upload.rsc b/backup-upload.rsc
index 8d96eba..12698e9 100644
--- a/backup-upload.rsc
+++ b/backup-upload.rsc
@@ -12,6 +12,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -43,11 +44,13 @@
:if ($BackupSendBinary != true && \
$BackupSendExport != true) do={
$LogPrint error $ScriptName ("Configured to send neither backup nor config export.");
+ :set ExitOK true;
:error false;
}
:if ([ $ScriptLock $ScriptName ] = false) do={
:set PackagesUpdateBackupFailure true;
+ :set ExitOK true;
:error false;
}
$WaitFullyConnected;
@@ -67,6 +70,7 @@
:if ([ $MkDir $DirName ] = false) do={
$LogPrint error $ScriptName ("Failed creating directory!");
+ :set ExitOK true;
:error false;
}
@@ -158,4 +162,6 @@
:set PackagesUpdateBackupFailure true;
}
/file/remove $DirName;
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/capsman-download-packages.capsman.rsc b/capsman-download-packages.capsman.rsc
index f2ff024..1802884 100644
--- a/capsman-download-packages.capsman.rsc
+++ b/capsman-download-packages.capsman.rsc
@@ -14,6 +14,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -25,6 +26,7 @@
:global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
$WaitFullyConnected;
@@ -35,6 +37,7 @@
:if ([ :len $PackagePath ] = 0) do={
$LogPrint warning $ScriptName ("The CAPsMAN package path is not defined, can not download packages.");
+ :set ExitOK true;
:error false;
}
@@ -42,6 +45,7 @@
:if ([ $MkDir $PackagePath ] = false) do={
$LogPrint warning $ScriptName ("Creating directory at CAPsMAN package path (" . \
$PackagePath . ") failed!");
+ :set ExitOK true;
:error false;
}
$LogPrint info $ScriptName ("Created directory at CAPsMAN package path (" . $PackagePath . \
@@ -82,4 +86,6 @@
/caps-man/remote-cap/upgrade [ find where version!=$InstalledVersion ];
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/capsman-download-packages.template.rsc b/capsman-download-packages.template.rsc
index ad9b926..72edaa9 100644
--- a/capsman-download-packages.template.rsc
+++ b/capsman-download-packages.template.rsc
@@ -15,6 +15,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -26,6 +27,7 @@
:global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
$WaitFullyConnected;
@@ -37,6 +39,7 @@
:if ([ :len $PackagePath ] = 0) do={
$LogPrint warning $ScriptName ("The CAPsMAN package path is not defined, can not download packages.");
+ :set ExitOK true;
:error false;
}
@@ -44,6 +47,7 @@
:if ([ $MkDir $PackagePath ] = false) do={
$LogPrint warning $ScriptName ("Creating directory at CAPsMAN package path (" . \
$PackagePath . ") failed!");
+ :set ExitOK true;
:error false;
}
$LogPrint info $ScriptName ("Created directory at CAPsMAN package path (" . $PackagePath . \
@@ -93,4 +97,6 @@
/interface/wifi/capsman/remote-cap/upgrade [ find where version!=$InstalledVersion ];
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/capsman-download-packages.wifi.rsc b/capsman-download-packages.wifi.rsc
index 056136f..74a5d9d 100644
--- a/capsman-download-packages.wifi.rsc
+++ b/capsman-download-packages.wifi.rsc
@@ -14,6 +14,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -25,6 +26,7 @@
:global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
$WaitFullyConnected;
@@ -35,6 +37,7 @@
:if ([ :len $PackagePath ] = 0) do={
$LogPrint warning $ScriptName ("The CAPsMAN package path is not defined, can not download packages.");
+ :set ExitOK true;
:error false;
}
@@ -42,6 +45,7 @@
:if ([ $MkDir $PackagePath ] = false) do={
$LogPrint warning $ScriptName ("Creating directory at CAPsMAN package path (" . \
$PackagePath . ") failed!");
+ :set ExitOK true;
:error false;
}
$LogPrint info $ScriptName ("Created directory at CAPsMAN package path (" . $PackagePath . \
@@ -84,4 +88,6 @@
/interface/wifi/capsman/remote-cap/upgrade [ find where version!=$InstalledVersion ];
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/capsman-rolling-upgrade.capsman.rsc b/capsman-rolling-upgrade.capsman.rsc
index f287ea3..d0f9fb8 100644
--- a/capsman-rolling-upgrade.capsman.rsc
+++ b/capsman-rolling-upgrade.capsman.rsc
@@ -15,6 +15,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -22,6 +23,7 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -43,4 +45,6 @@
:delay ($Delay . "s");
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/capsman-rolling-upgrade.template.rsc b/capsman-rolling-upgrade.template.rsc
index 3d98747..1bd5f2a 100644
--- a/capsman-rolling-upgrade.template.rsc
+++ b/capsman-rolling-upgrade.template.rsc
@@ -16,6 +16,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -23,6 +24,7 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -51,4 +53,6 @@
:delay ($Delay . "s");
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/capsman-rolling-upgrade.wifi.rsc b/capsman-rolling-upgrade.wifi.rsc
index 369dccc..c9e6622 100644
--- a/capsman-rolling-upgrade.wifi.rsc
+++ b/capsman-rolling-upgrade.wifi.rsc
@@ -15,6 +15,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -22,6 +23,7 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -44,4 +46,6 @@
:delay ($Delay . "s");
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/certificate-renew-issued.rsc b/certificate-renew-issued.rsc
index f2c1dfe..ce61f7d 100644
--- a/certificate-renew-issued.rsc
+++ b/certificate-renew-issued.rsc
@@ -11,6 +11,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -21,6 +22,7 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -45,4 +47,6 @@
$LogPrint info $ScriptName ("Issued a new certificate for '" . $CertVal->"common-name" . "'.");
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/check-certificates.rsc b/check-certificates.rsc
index 7aaac84..52cfc5e 100644
--- a/check-certificates.rsc
+++ b/check-certificates.rsc
@@ -11,6 +11,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -133,6 +134,7 @@
}
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
$WaitFullyConnected;
@@ -218,4 +220,6 @@
", it is invalid after " . ($CertVal->"invalid-after") . ".");
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/check-health.rsc b/check-health.rsc
index 540336d..495b450 100644
--- a/check-health.rsc
+++ b/check-health.rsc
@@ -11,6 +11,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -40,6 +41,7 @@
}
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -78,6 +80,7 @@
:if ([ :len [ /system/health/find ] ] = 0) do={
$LogPrint debug $ScriptName ("Your device does not provide any health values.");
+ :set ExitOK true;
:error true;
}
@@ -175,4 +178,6 @@
}
:set ($CheckHealthLast->$Name) $Value;
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/check-lte-firmware-upgrade.rsc b/check-lte-firmware-upgrade.rsc
index 2e52c2a..898d6f1 100644
--- a/check-lte-firmware-upgrade.rsc
+++ b/check-lte-firmware-upgrade.rsc
@@ -11,6 +11,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -19,6 +20,7 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -100,4 +102,6 @@
:foreach Interface in=[ /interface/lte/find ] do={
$CheckInterface $ScriptName $Interface;
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/check-routeros-update.rsc b/check-routeros-update.rsc
index 0624808..510acd9 100644
--- a/check-routeros-update.rsc
+++ b/check-routeros-update.rsc
@@ -11,6 +11,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -34,20 +35,24 @@
:global WaitFullyConnected;
:local DoUpdate do={
+ :global LogPrint;
+
:if ([ :len [ /system/script/find where name="packages-update" ] ] > 0) do={
/system/script/run packages-update;
} else={
/system/package/update/install without-paging;
}
- :error "Waiting for system to reboot.";
+ $LogPrint info $0 ("Waiting for system to reboot.");
}
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
$WaitFullyConnected;
:if ([ :len [ /system/scheduler/find where name="_RebootForUpdate" ] ] > 0) do={
+ :set ExitOK true;
:error "A reboot for update is already scheduled.";
}
@@ -59,11 +64,13 @@
:if ([ $ScriptFromTerminal $ScriptName ] = true) do={
$LogPrint info $ScriptName ("System is already up to date.");
}
+ :set ExitOK true;
:error true;
}
:if ([ :len ($Update->"latest-version") ] = 0) do={
$LogPrint info $ScriptName ("Received an empty version string from server.");
+ :set ExitOK true;
:error false;
}
@@ -76,6 +83,7 @@
:if ($NumLatest < [ $VersionToNum "7.0" ]) do={
$LogPrint warning $ScriptName ("The version '" . ($Update->"latest-version") . "' is not a valid version.");
+ :set ExitOK true;
:error false;
}
@@ -88,6 +96,8 @@
message=("Installing ALL versions automatically, including " . $Update->"latest-version" . \
"... Updating on " . $Identity . "..."); link=$Link; silent=true });
$DoUpdate;
+ :set ExitOK true;
+ :error true;
}
:if ($SafeUpdatePatch = true && $NumInstalledFeature = $NumLatestFeature) do={
@@ -97,6 +107,8 @@
message=("Version " . $Update->"latest-version" . " is a patch update for " . $Update->"channel" . \
", updating on " . $Identity . "..."); link=$Link; silent=true });
$DoUpdate;
+ :set ExitOK true;
+ :error true;
}
:if ($SafeUpdateNeighbor = true) do={
@@ -111,6 +123,8 @@
message=("Seen a neighbor (" . $Neighbor . ") running version " . $Update->"latest-version" . \
" from " . $Update->"channel" . ", updating on " . $Identity . "..."); link=$Link; silent=true });
$DoUpdate;
+ :set ExitOK true;
+ :error true;
}
}
@@ -131,6 +145,8 @@
message=("Version " . $Update->"latest-version" . " is considered safe for " . $Update->"channel" . \
", updating on " . $Identity . "..."); link=$Link; silent=true });
$DoUpdate;
+ :set ExitOK true;
+ :error true;
}
}
@@ -140,6 +156,7 @@
:if (([ /terminal/inkey timeout=60 ] % 32) = 25) do={
/system/package/update/set channel=stable;
$LogPrint info $ScriptName ("Switched to channel 'stable', please re-run!");
+ :set ExitOK true;
:error true;
}
}
@@ -147,6 +164,8 @@
:put ("Do you want to install RouterOS version " . $Update->"latest-version" . "? [y/N]");
:if (([ /terminal/inkey timeout=60 ] % 32) = 25) do={
$DoUpdate;
+ :set ExitOK true;
+ :error true;
} else={
:put "Canceled...";
}
@@ -155,6 +174,7 @@
:if ($SentRouterosUpdateNotification = $Update->"latest-version") do={
$LogPrint info $ScriptName ("Already sent the RouterOS update notification for version " . \
$Update->"latest-version" . ".");
+ :set ExitOK true;
:error true;
}
@@ -170,6 +190,7 @@
:if ($SentRouterosUpdateNotification = $Update->"latest-version") do={
$LogPrint info $ScriptName ("Already sent the RouterOS downgrade notification for version " . \
$Update->"latest-version" . ".");
+ :set ExitOK true;
:error true;
}
@@ -182,4 +203,6 @@
" is available for downgrade.");
:set SentRouterosUpdateNotification ($Update->"latest-version");
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/collect-wireless-mac.capsman.rsc b/collect-wireless-mac.capsman.rsc
index 9efa9ef..77fd6e3 100644
--- a/collect-wireless-mac.capsman.rsc
+++ b/collect-wireless-mac.capsman.rsc
@@ -14,6 +14,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -29,6 +30,7 @@
:global SymbolForNotification;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -93,4 +95,6 @@
$LogPrint debug $ScriptName ("No mac address available... Ignoring.");
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/collect-wireless-mac.local.rsc b/collect-wireless-mac.local.rsc
index 27c9d1c..dc7be19 100644
--- a/collect-wireless-mac.local.rsc
+++ b/collect-wireless-mac.local.rsc
@@ -14,6 +14,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -29,6 +30,7 @@
:global SymbolForNotification;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -94,4 +96,6 @@
$LogPrint debug $ScriptName ("No mac address available... Ignoring.");
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/collect-wireless-mac.template.rsc b/collect-wireless-mac.template.rsc
index d41c17d..34b1695 100644
--- a/collect-wireless-mac.template.rsc
+++ b/collect-wireless-mac.template.rsc
@@ -15,6 +15,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -30,6 +31,7 @@
:global SymbolForNotification;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -111,4 +113,6 @@
$LogPrint debug $ScriptName ("No mac address available... Ignoring.");
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/collect-wireless-mac.wifi.rsc b/collect-wireless-mac.wifi.rsc
index 0075320..23c93b0 100644
--- a/collect-wireless-mac.wifi.rsc
+++ b/collect-wireless-mac.wifi.rsc
@@ -14,6 +14,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -29,6 +30,7 @@
:global SymbolForNotification;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -93,4 +95,6 @@
$LogPrint debug $ScriptName ("No mac address available... Ignoring.");
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/daily-psk.capsman.rsc b/daily-psk.capsman.rsc
index 0562e39..263f6e5 100644
--- a/daily-psk.capsman.rsc
+++ b/daily-psk.capsman.rsc
@@ -14,6 +14,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -31,6 +32,7 @@
:global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
$WaitFullyConnected;
@@ -89,4 +91,6 @@
}
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/daily-psk.local.rsc b/daily-psk.local.rsc
index 0bef0e9..f0757e1 100644
--- a/daily-psk.local.rsc
+++ b/daily-psk.local.rsc
@@ -14,6 +14,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -31,6 +32,7 @@
:global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
$WaitFullyConnected;
@@ -88,4 +90,6 @@
}
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/daily-psk.template.rsc b/daily-psk.template.rsc
index 9d71958..7e36b5a 100644
--- a/daily-psk.template.rsc
+++ b/daily-psk.template.rsc
@@ -15,6 +15,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -32,6 +33,7 @@
:global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
$WaitFullyConnected;
@@ -104,4 +106,6 @@
}
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/daily-psk.wifi.rsc b/daily-psk.wifi.rsc
index 83a896c..293f0e4 100644
--- a/daily-psk.wifi.rsc
+++ b/daily-psk.wifi.rsc
@@ -14,6 +14,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -31,6 +32,7 @@
:global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
$WaitFullyConnected;
@@ -89,4 +91,6 @@
}
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/dhcp-lease-comment.capsman.rsc b/dhcp-lease-comment.capsman.rsc
index c435ec3..5ac0009 100644
--- a/dhcp-lease-comment.capsman.rsc
+++ b/dhcp-lease-comment.capsman.rsc
@@ -14,6 +14,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -21,6 +22,7 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -36,4 +38,6 @@
/ip/dhcp-server/lease/set comment=$NewComment $Lease;
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/dhcp-lease-comment.local.rsc b/dhcp-lease-comment.local.rsc
index 27e6605..1b74d93 100644
--- a/dhcp-lease-comment.local.rsc
+++ b/dhcp-lease-comment.local.rsc
@@ -14,6 +14,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -21,6 +22,7 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -36,4 +38,6 @@
/ip/dhcp-server/lease/set comment=$NewComment $Lease;
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/dhcp-lease-comment.template.rsc b/dhcp-lease-comment.template.rsc
index c562ca2..8f1ad47 100644
--- a/dhcp-lease-comment.template.rsc
+++ b/dhcp-lease-comment.template.rsc
@@ -15,6 +15,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -22,6 +23,7 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -41,4 +43,6 @@
/ip/dhcp-server/lease/set comment=$NewComment $Lease;
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/dhcp-lease-comment.wifi.rsc b/dhcp-lease-comment.wifi.rsc
index ba617d7..d3741c5 100644
--- a/dhcp-lease-comment.wifi.rsc
+++ b/dhcp-lease-comment.wifi.rsc
@@ -14,6 +14,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -21,6 +22,7 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -36,4 +38,6 @@
/ip/dhcp-server/lease/set comment=$NewComment $Lease;
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/dhcp-to-dns.rsc b/dhcp-to-dns.rsc
index 9bf506f..ad55c4d 100644
--- a/dhcp-to-dns.rsc
+++ b/dhcp-to-dns.rsc
@@ -12,6 +12,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -27,6 +28,7 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -123,4 +125,6 @@
$LogPrint debug $ScriptName ("No address available... Ignoring.");
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/firmware-upgrade-reboot.rsc b/firmware-upgrade-reboot.rsc
index 74847ac..9655903 100644
--- a/firmware-upgrade-reboot.rsc
+++ b/firmware-upgrade-reboot.rsc
@@ -11,6 +11,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -19,6 +20,7 @@
:global VersionToNum;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -26,10 +28,12 @@
:if ($RouterBoard->"current-firmware" = $RouterBoard->"upgrade-firmware") do={
$LogPrint info $ScriptName ("Current and upgrade firmware match with version " . \
$RouterBoard->"current-firmware" . ".");
+ :set ExitOK true;
:error true;
}
:if ([ $VersionToNum ($RouterBoard->"current-firmware") ] > [ $VersionToNum ($RouterBoard->"upgrade-firmware") ]) do={
$LogPrint info $ScriptName ("Different firmware version is available, but it is a downgrade. Ignoring.");
+ :set ExitOK true;
:error true;
}
@@ -51,4 +55,6 @@
$LogPrint info $ScriptName ("Firmware upgrade successful, rebooting.");
/system/reboot;
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/fw-addr-lists.rsc b/fw-addr-lists.rsc
index 34b2fcc..6682f4a 100644
--- a/fw-addr-lists.rsc
+++ b/fw-addr-lists.rsc
@@ -11,6 +11,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -36,6 +37,7 @@
}
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
$WaitFullyConnected;
@@ -184,4 +186,6 @@
" - renewed: " . [ $HumanReadableNum $CntRenew 1000 ] . \
" - removed: " . [ $HumanReadableNum $CntRemove 1000 ]);
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/global-functions.rsc b/global-functions.rsc
index 6fec6dd..8941994 100644
--- a/global-functions.rsc
+++ b/global-functions.rsc
@@ -32,6 +32,7 @@
:global DownloadPackage;
:global EitherOr;
:global EscapeForRegEx;
+:global ExitError;
:global FetchHuge;
:global FetchUserAgentStr;
:global FormatLine;
@@ -425,6 +426,18 @@
:return $Return;
}
+# simple macro to print error message on unintentional error
+:set ExitError do={
+ :local ExitOK [ :tostr $1 ];
+ :local ScriptName [ :tostr $2 ];
+
+ :global LogPrint;
+
+ :if ($ExitOK = "false") do={
+ $LogPrint error $ScriptName ("Script '" . $ScriptName . "' exited with error.");
+ }
+}
+
# fetch huge data to file, read in chunks
:set FetchHuge do={
:local ScriptName [ :tostr $1 ];
diff --git a/gps-track.rsc b/gps-track.rsc
index a2ea9ff..c0ecac4 100644
--- a/gps-track.rsc
+++ b/gps-track.rsc
@@ -11,6 +11,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -23,6 +24,7 @@
:global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
$WaitFullyConnected;
@@ -45,4 +47,6 @@
} else={
$LogPrint debug $ScriptName ("GPS data not valid.");
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/hotspot-to-wpa-cleanup.capsman.rsc b/hotspot-to-wpa-cleanup.capsman.rsc
index e935850..8a38213 100644
--- a/hotspot-to-wpa-cleanup.capsman.rsc
+++ b/hotspot-to-wpa-cleanup.capsman.rsc
@@ -14,6 +14,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -23,6 +24,7 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -72,4 +74,6 @@
/ip/dhcp-server/lease/remove $Lease;
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/hotspot-to-wpa-cleanup.template.rsc b/hotspot-to-wpa-cleanup.template.rsc
index fa99b5d..e8d2dfb 100644
--- a/hotspot-to-wpa-cleanup.template.rsc
+++ b/hotspot-to-wpa-cleanup.template.rsc
@@ -15,6 +15,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -24,6 +25,7 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -79,4 +81,6 @@
/ip/dhcp-server/lease/remove $Lease;
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/hotspot-to-wpa-cleanup.wifi.rsc b/hotspot-to-wpa-cleanup.wifi.rsc
index d3f859e..e2ef1fd 100644
--- a/hotspot-to-wpa-cleanup.wifi.rsc
+++ b/hotspot-to-wpa-cleanup.wifi.rsc
@@ -14,6 +14,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -23,6 +24,7 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -72,4 +74,6 @@
/ip/dhcp-server/lease/remove $Lease;
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/hotspot-to-wpa.capsman.rsc b/hotspot-to-wpa.capsman.rsc
index b85c591..e57d327 100644
--- a/hotspot-to-wpa.capsman.rsc
+++ b/hotspot-to-wpa.capsman.rsc
@@ -13,6 +13,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -25,11 +26,13 @@
:local UserName $username;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :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.");
+ :set ExitOK true;
:error false;
}
@@ -57,6 +60,7 @@
:if ($Template->"action" = "reject") do={
$LogPrint info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'.");
+ :set ExitOK true;
:error true;
}
@@ -95,4 +99,6 @@
:delay 2s;
/caps-man/access-list/set $Entry action=accept;
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/hotspot-to-wpa.template.rsc b/hotspot-to-wpa.template.rsc
index 44607cc..efe37d0 100644
--- a/hotspot-to-wpa.template.rsc
+++ b/hotspot-to-wpa.template.rsc
@@ -14,6 +14,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -26,11 +27,13 @@
:local UserName $username;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :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.");
+ :set ExitOK true;
:error false;
}
@@ -64,6 +67,7 @@
:if ($Template->"action" = "reject") do={
$LogPrint info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'.");
+ :set ExitOK true;
:error true;
}
@@ -115,4 +119,6 @@
:delay 2s;
/caps-man/access-list/set $Entry action=accept;
/interface/wifi/access-list/set $Entry action=accept;
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/hotspot-to-wpa.wifi.rsc b/hotspot-to-wpa.wifi.rsc
index 25933c6..6242d04 100644
--- a/hotspot-to-wpa.wifi.rsc
+++ b/hotspot-to-wpa.wifi.rsc
@@ -13,6 +13,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -25,11 +26,13 @@
:local UserName $username;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :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.");
+ :set ExitOK true;
:error false;
}
@@ -57,6 +60,7 @@
:if ($Template->"action" = "reject") do={
$LogPrint info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'.");
+ :set ExitOK true;
:error true;
}
@@ -92,4 +96,6 @@
:delay 2s;
/interface/wifi/access-list/set $Entry action=accept;
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/ipsec-to-dns.rsc b/ipsec-to-dns.rsc
index bd74a8f..47676ca 100644
--- a/ipsec-to-dns.rsc
+++ b/ipsec-to-dns.rsc
@@ -11,6 +11,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -26,6 +27,7 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -76,4 +78,6 @@
/ip/dns/static/add name=$Fqdn address=($PeerVal->"dynamic-address") ttl=$Ttl comment=$Comment place-before=$PlaceBefore;
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/ipv6-update.rsc b/ipv6-update.rsc
index ccc0eb9..ea1d444 100644
--- a/ipv6-update.rsc
+++ b/ipv6-update.rsc
@@ -11,6 +11,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -22,16 +23,19 @@
:local PdPrefix $"pd-prefix";
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
:if ([ :typeof $NaAddress ] = "str") do={
$LogPrint info $ScriptName ("An address (" . $NaAddress . ") was acquired, not a prefix. Ignoring.");
+ :set ExitOK true;
:error false;
}
:if ([ :typeof $PdPrefix ] = "nothing") do={
$LogPrint error $ScriptName ("This script is supposed to run from ipv6 dhcp-client.");
+ :set ExitOK true;
:error false;
}
@@ -90,4 +94,6 @@
}
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/lease-script.rsc b/lease-script.rsc
index f484414..995c7e4 100644
--- a/lease-script.rsc
+++ b/lease-script.rsc
@@ -11,6 +11,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -25,6 +26,7 @@
[ :typeof $leaseServerName ] = "nothing" || \
[ :typeof $leaseBound ] = "nothing") do={
$LogPrint error $ScriptName ("This script is supposed to run from ip dhcp-server.");
+ :set ExitOK true;
:error false;
}
@@ -32,11 +34,13 @@
"de" "" ] . "assigned lease " . $leaseActIP . " to " . $leaseActMAC);
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
+ :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.");
+ :set ExitOK true;
:error true;
}
@@ -56,4 +60,6 @@
$LogPrint warning $ScriptName ("Running script '" . $Script . "' failed!");
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/log-forward.rsc b/log-forward.rsc
index e0d8f35..8e660fc 100644
--- a/log-forward.rsc
+++ b/log-forward.rsc
@@ -11,6 +11,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -33,6 +34,7 @@
:global SymbolForNotification;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -43,6 +45,7 @@
:if ($LogForwardRateLimit > 30) do={
:set LogForwardRateLimit ($LogForwardRateLimit - 1);
$LogPrint info $ScriptName ("Rate limit in action, not forwarding logs, if any!");
+ :set ExitOK true;
:error false;
}
@@ -100,4 +103,6 @@
:local LogAll [ /log/find ];
:set LogForwardLast ($LogAll->([ :len $LogAll ] - 1) );
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/mode-button.rsc b/mode-button.rsc
index 3bd922b..24de453 100644
--- a/mode-button.rsc
+++ b/mode-button.rsc
@@ -11,6 +11,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -83,4 +84,6 @@
$LogPrint debug $ScriptName ("Updating scheduler _ModeButtonScheduler...");
/system/scheduler/set $Scheduler start-time=[ /system/clock/get time ];
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/netwatch-dns.rsc b/netwatch-dns.rsc
index 6fbfc89..a704c84 100644
--- a/netwatch-dns.rsc
+++ b/netwatch-dns.rsc
@@ -11,6 +11,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -24,12 +25,14 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
:local SettleTime (5m30s - [ /system/resource/get uptime ]);
:if ($SettleTime > 0s) do={
$LogPrint info $ScriptName ("System just booted, giving netwatch " . $SettleTime . " to settle.");
+ :set ExitOK true;
:error true;
}
@@ -92,6 +95,7 @@
:if ($DohCurrent = $HostInfo->"doh-url") do={
$LogPrint debug $ScriptName ("Current DoH server is still up: " . $DohCurrent);
+ :set ExitOK true;
:error true;
}
@@ -132,6 +136,7 @@
}
/ip/dns/cache/flush;
$LogPrint info $ScriptName ("Setting DoH server: " . ($DohServer->"doh-url"));
+ :set ExitOK true;
:error true;
} else={
$LogPrint warning $ScriptName ("Received unexpected response from DoH server: " . \
@@ -139,4 +144,6 @@
}
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/netwatch-notify.rsc b/netwatch-notify.rsc
index a49d0cd..f1e87bd 100644
--- a/netwatch-notify.rsc
+++ b/netwatch-notify.rsc
@@ -11,6 +11,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -75,6 +76,7 @@
}
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -218,4 +220,6 @@
"since"=($Metric->"since") };
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/ospf-to-leds.rsc b/ospf-to-leds.rsc
index b78faa4..d96e763 100644
--- a/ospf-to-leds.rsc
+++ b/ospf-to-leds.rsc
@@ -11,6 +11,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -19,6 +20,7 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -42,4 +44,6 @@
/system/leds/set type=off [ find where leds=$LED ];
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/packages-update.rsc b/packages-update.rsc
index b08a48d..924a5d9 100644
--- a/packages-update.rsc
+++ b/packages-update.rsc
@@ -11,6 +11,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -45,6 +46,7 @@
}
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -52,11 +54,13 @@
:if ([ :typeof ($Update->"latest-version") ] = "nothing") do={
$LogPrint warning $ScriptName ("Latest version is not known.");
+ :set ExitOK true;
:error false;
}
:if ($Update->"installed-version" = $Update->"latest-version") do={
$LogPrint info $ScriptName ("Version " . $Update->"latest-version" . " is already installed.");
+ :set ExitOK true;
:error true;
}
@@ -85,10 +89,12 @@
$LogPrint info $ScriptName ("User requested to continue anyway.");
} else={
$LogPrint info $ScriptName ("Canceled update...");
+ :set ExitOK true;
:error false;
}
} else={
$LogPrint warning $ScriptName ("Canceled non-interactive update.");
+ :set ExitOK true;
:error false;
}
}
@@ -108,6 +114,7 @@
}
} else={
$LogPrint warning $ScriptName ("Not installing downgrade automatically.");
+ :set ExitOK true;
:error false;
}
}
@@ -116,6 +123,7 @@
:local PkgName [ /system/package/get $Package name ];
:if ([ $DownloadPackage $PkgName ($Update->"latest-version") ] = false) do={
$LogPrint error $ScriptName ("Download for package " . $PkgName . " failed, update aborted.");
+ :set ExitOK true;
:error false;
}
}
@@ -130,11 +138,13 @@
:put "Do you want to (s)chedule reboot or (r)eboot now? [s/R]";
:if (([ /terminal/inkey timeout=60 ] % 32) = 19) do={
$Schedule $ScriptName;
+ :set ExitOK true;
:error true;
}
} else={
:if ($PackagesUpdateDeferReboot = true) do={
$Schedule $ScriptName;
+ :set ExitOK true;
:error true;
}
}
@@ -142,4 +152,6 @@
$LogPrint info $ScriptName ("Rebooting for update.");
:delay 1s;
/system/reboot;
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/ppp-on-up.rsc b/ppp-on-up.rsc
index 337b32d..13b42c7 100644
--- a/ppp-on-up.rsc
+++ b/ppp-on-up.rsc
@@ -11,6 +11,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -20,6 +21,7 @@
:if ([ :typeof $Interface ] = "nothing") do={
$LogPrint error $ScriptName ("This script is supposed to run from ppp on-up script hook.");
+ :set ExitOK true;
:error false;
}
@@ -37,4 +39,6 @@
$LogPrint warning $ScriptName ("Running script '" . $ScriptName . "' failed!");
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/sms-action.rsc b/sms-action.rsc
index c896659..fd3096c 100644
--- a/sms-action.rsc
+++ b/sms-action.rsc
@@ -11,6 +11,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -23,6 +24,7 @@
:if ([ :typeof $Action ] = "nothing") do={
$LogPrint error $ScriptName ("This script is supposed to run from SMS hook with action=...");
+ :set ExitOK true;
:error false;
}
@@ -34,4 +36,6 @@
} else={
$LogPrint warning $ScriptName ("The code for action '" . $Action . "' failed syntax validation!");
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/sms-forward.rsc b/sms-forward.rsc
index 0d493b6..8334d5f 100644
--- a/sms-forward.rsc
+++ b/sms-forward.rsc
@@ -12,6 +12,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -28,11 +29,13 @@
:global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
:if ([ /tool/sms/get receive-enabled ] = false) do={
$LogPrintOnce warning $ScriptName ("Receiving of SMS is not enabled.");
+ :set ExitOK true;
:error false;
}
@@ -42,6 +45,7 @@
:if ([ /interface/lte/get ($Settings->"port") running ] != true) do={
$LogPrint info $ScriptName ("The LTE interface is not in running state, skipping.");
+ :set ExitOK true;
:error true;
}
@@ -92,4 +96,6 @@
}
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/telegram-chat.rsc b/telegram-chat.rsc
index f2750f5..8589aab 100644
--- a/telegram-chat.rsc
+++ b/telegram-chat.rsc
@@ -11,6 +11,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -43,6 +44,7 @@
:global WaitFullyConnected;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -57,6 +59,7 @@
:if ([ $CertificateAvailable "Go Daddy Root Certificate Authority - G2" ] = false) do={
$LogPrint warning $ScriptName ("Downloading required certificate failed.");
+ :set ExitOK true;
:error false;
}
@@ -82,6 +85,7 @@
:if ($Data = false) do={
$LogPrint warning $ScriptName ("Failed getting updates.");
+ :set ExitOK true;
:error false;
}
@@ -130,6 +134,7 @@
:local File ("tmpfs/telegram-chat/" . [ $GetRandom20CharAlNum 6 ]);
:if ([ $MkDir "tmpfs/telegram-chat" ] = false) do={
$LogPrint error $ScriptName ("Failed creating directory!");
+ :set ExitOK true;
:error false;
}
$LogPrint info $ScriptName ("Running command from update " . $UpdateID . ": " . $Command);
@@ -176,4 +181,6 @@
}
:set TelegramChatOffset ([ :pick $TelegramChatOffset 1 3 ], \
[ $IfThenElse ($UpdateID >= $TelegramChatOffset->2) ($UpdateID + 1) ($TelegramChatOffset->2) ]);
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/update-gre-address.rsc b/update-gre-address.rsc
index 6dd829d..87762d6 100644
--- a/update-gre-address.rsc
+++ b/update-gre-address.rsc
@@ -12,6 +12,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -20,6 +21,7 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
@@ -39,4 +41,6 @@
}
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}
diff --git a/update-tunnelbroker.rsc b/update-tunnelbroker.rsc
index 67a5d30..dd43c64 100644
--- a/update-tunnelbroker.rsc
+++ b/update-tunnelbroker.rsc
@@ -13,6 +13,7 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
+:local ExitOK false;
:do {
:local ScriptName [ :jobname ];
@@ -22,11 +23,13 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
+ :set ExitOK true;
:error false;
}
:if ([ $CertificateAvailable "Starfield Root Certificate Authority - G2" ] = false) do={
$LogPrint error $ScriptName ("Downloading required certificate failed.");
+ :set ExitOK true;
:error false;
}
@@ -50,6 +53,7 @@
:if (!($Data ~ "^(good|nochg) ")) do={
$LogPrint error $ScriptName ("Failed sending the local address to tunnelbroker or unexpected response!");
+ :set ExitOK true;
:error false;
}
@@ -64,4 +68,6 @@
/interface/6to4/set $Interface local-address=$PublicAddress;
}
}
-} on-error={ }
+} on-error={
+ :global ExitError; $ExitError $ExitOK [ :jobname ];
+}