From d0af9d62ea6bd3b749d717f223ee424d5962c2af Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: accesslist-duplicates: drop main function, use :do with on-error --- accesslist-duplicates.capsman.rsc | 8 +++----- accesslist-duplicates.local.rsc | 8 +++----- accesslist-duplicates.template.rsc | 8 +++----- accesslist-duplicates.wifi.rsc | 8 +++----- 4 files changed, 12 insertions(+), 20 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={ } -- cgit v1.2.3-70-g09d2 From 15c68c5660ab6bc0af4c9dee4de7b74ebcf0abb8 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: backup-cloud: drop main function, use :do with on-error --- backup-cloud.rsc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From 3eb8fad5ae36334b2f4c56c6641d453eee5b0136 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: backup-email: drop main function, use :do with on-error --- backup-email.rsc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From b8bd64bac5b9925d84d1baa0eef8dbd511b738a9 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: backup-partition: drop main function, use :do with on-error --- backup-partition.rsc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From 8d020a4de84cc86f0328a79c6e27bf87a35d45ba Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: backup-upload: drop main function, use :do with on-error --- backup-upload.rsc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From 03309d4fdb3542c60e81b505ee9a9dc1fd623f5d Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: capsman-download-packages: drop main function, use :do with on-error --- capsman-download-packages.capsman.rsc | 10 ++++------ capsman-download-packages.template.rsc | 10 ++++------ capsman-download-packages.wifi.rsc | 10 ++++------ 3 files changed, 12 insertions(+), 18 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From 25c9bff6f38fa7738c21572c8f13b3a831e1e6f3 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: capsman-rolling-upgrade: drop main function, use :do with on-error --- capsman-rolling-upgrade.capsman.rsc | 10 ++++------ capsman-rolling-upgrade.template.rsc | 10 ++++------ capsman-rolling-upgrade.wifi.rsc | 10 ++++------ 3 files changed, 12 insertions(+), 18 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From 78f65ead599a6ccb9161fe93a88674e28d8e95cb Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: certificate-renew-issued: drop main function, use :do with on-error --- certificate-renew-issued.rsc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From b1e37c27346209aa523705ee7076a2480e782780 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: check-certificates: drop main function, use :do with on-error --- check-certificates.rsc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From 7bf36fa8a5b4b568444e17aca7ccee817280ed31 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: check-health: drop main function, use :do with on-error --- check-health.rsc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From b78556ca41c720f14c57eb84b85bcf099c06764c Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: check-lte-firmware-upgrade: drop main function, use :do with on-error --- check-lte-firmware-upgrade.rsc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From 7110b29cbabdd7097c0eeebb338b4b5b42ce6aee Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: check-routeros-update: drop main function, use :do with on-error --- check-routeros-update.rsc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From 4ada2e7678d43246575005a300f2baab24f019f8 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: collect-wireless-mac: drop main function, use :do with on-error --- collect-wireless-mac.capsman.rsc | 10 ++++------ collect-wireless-mac.local.rsc | 10 ++++------ collect-wireless-mac.template.rsc | 10 ++++------ collect-wireless-mac.wifi.rsc | 10 ++++------ 4 files changed, 16 insertions(+), 24 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From f79206a9b82850c2df299158191f63d9e57c03f4 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: daily-psk: drop main function, use :do with on-error --- daily-psk.capsman.rsc | 10 ++++------ daily-psk.local.rsc | 10 ++++------ daily-psk.template.rsc | 10 ++++------ daily-psk.wifi.rsc | 10 ++++------ 4 files changed, 16 insertions(+), 24 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From 0d1c4cece27094aa529a5bf75ef5a0bae3bc6321 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: dhcp-lease-comment: drop main function, use :do with on-error --- dhcp-lease-comment.capsman.rsc | 10 ++++------ dhcp-lease-comment.local.rsc | 10 ++++------ dhcp-lease-comment.template.rsc | 10 ++++------ dhcp-lease-comment.wifi.rsc | 10 ++++------ 4 files changed, 16 insertions(+), 24 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From ef5972e9f09be975f0905ca8d81477bc443515cb Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: dhcp-to-dns: drop main function, use :do with on-error --- dhcp-to-dns.rsc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From 894c36fc1583bbc6b48ecaa35c562dfcf467e4d3 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: firmware-upgrade-reboot: drop main function, use :do with on-error --- firmware-upgrade-reboot.rsc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From c1362f54e585d2b17fac9232cbf845da34fa8707 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: fw-addr-lists: drop main function, use :do with on-error --- fw-addr-lists.rsc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From 47b67af2266e8706f8b047477c9db84c6282360a Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: gps-track: drop main function, use :do with on-error --- gps-track.rsc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From b622f47d6566d2049f95f17c787f1b3ee2b103b4 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: hotspot-to-wpa-cleanup: drop main function, use :do with on-error --- hotspot-to-wpa-cleanup.capsman.rsc | 10 ++++------ hotspot-to-wpa-cleanup.template.rsc | 10 ++++------ hotspot-to-wpa-cleanup.wifi.rsc | 10 ++++------ 3 files changed, 12 insertions(+), 18 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From 54638924e4a06f926d3bdd3bbd44489acc692a75 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: hotspot-to-wpa: drop main function, use :do with on-error --- hotspot-to-wpa.capsman.rsc | 19 +++++++++---------- hotspot-to-wpa.template.rsc | 19 +++++++++---------- hotspot-to-wpa.wifi.rsc | 19 +++++++++---------- 3 files changed, 27 insertions(+), 30 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From 341e84682cd3242735a0776640901ed0b9b7bebe Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: ipsec-to-dns: drop main function, use :do with on-error --- ipsec-to-dns.rsc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From 6f91c97b7fe68dbfd5274259aafbc2a77dd80d3d Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: ipv6-update: drop main function, use :do with on-error --- ipv6-update.rsc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From 6546e7f085c9a5ce33c6efa0b1887d178eb4ac5a Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: lease-script: drop main function, use :do with on-error --- lease-script.rsc | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From 52f54baea08184294825b24a43f1c21a45de265d Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: log-forward: drop main function, use :do with on-error --- log-forward.rsc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From 4dd6bdef3185d154c5b28efa7075f50cdb990682 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: mode-button: drop main function, use :do with on-error --- mode-button.rsc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From 8fcb8efbea2b377f12038f983d751c99aad07fb7 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: netwatch-dns: drop main function, use :do with on-error --- netwatch-dns.rsc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From 18ed12e3f7ced88d30b53ab1e4c557d25a2df755 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: netwatch-notify: drop main function, use :do with on-error --- netwatch-notify.rsc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From 850e8db9752aa62746183a639da60a0a26b66217 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: ospf-to-leds: drop main function, use :do with on-error --- ospf-to-leds.rsc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From 1012d9fc51973adefff4b72885e828f2cd04149a Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: packages-update: drop main function, use :do with on-error --- packages-update.rsc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From 1db1a943e2c802e9e869fa9222998b16d14cedba Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: ppp-on-up: drop main function, use :do with on-error --- ppp-on-up.rsc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From e19a48682e6d3675da75b391ef7678286177e69d Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: sms-action: drop main function, use :do with on-error --- sms-action.rsc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From ac38e1694435c3fb070dabcf8e8325d931b3eb27 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: sms-forward: drop main function, use :do with on-error --- sms-forward.rsc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From 738dd119293efe0f16235e2bcce241314393da5d Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: telegram-chat: drop main function, use :do with on-error --- telegram-chat.rsc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From febd13af13c3bd0fff3d702364a3979d3e4221a3 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: update-gre-address: drop main function, use :do with on-error --- update-gre-address.rsc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2 From f0856c264e07804a229668268a457f2154cb373a Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 6 Mar 2024 15:28:55 +0100 Subject: update-tunnelbroker: drop main function, use :do with on-error --- update-tunnelbroker.rsc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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={ } -- cgit v1.2.3-70-g09d2