Merge branch 'do-with-on-error' into next

This commit is contained in:
Christian Hesse 2024-03-06 23:53:50 +01:00
commit 6fd39bd3c5
56 changed files with 252 additions and 362 deletions

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }

View file

@ -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={ }