Skip to content

Commit

Permalink
global-functions: $ScriptLock: do not exit from global function
Browse files Browse the repository at this point in the history
  • Loading branch information
eworm-de committed Mar 12, 2024
1 parent 56e97dd commit 1e8918f
Show file tree
Hide file tree
Showing 57 changed files with 172 additions and 61 deletions.
4 changes: 3 additions & 1 deletion backup-cloud.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
:global SymbolForNotification;
:global WaitFullyConnected;

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected;

:if ([ $ScriptFromTerminal $ScriptName ] = false && $BackupRandomDelay > 0) do={
Expand Down
4 changes: 3 additions & 1 deletion backup-email.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
$LogPrintExit2 error $ScriptName ("Configured to send neither backup nor config export.") true;
}

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected;

:if ([ $ScriptFromTerminal $ScriptName ] = false && $BackupRandomDelay > 0) do={
Expand Down
4 changes: 3 additions & 1 deletion backup-partition.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
:global LogPrintExit2;
:global ScriptLock;

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}

:if ([ :len [ /partitions/find ] ] < 2) do={
$LogPrintExit2 error $ScriptName ("Device does not have a fallback partition.") true;
Expand Down
4 changes: 3 additions & 1 deletion backup-upload.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
$LogPrintExit2 error $ScriptName ("Configured to send neither backup nor config export.") true;
}

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected;

:if ([ $ScriptFromTerminal $ScriptName ] = false && $BackupRandomDelay > 0) do={
Expand Down
4 changes: 3 additions & 1 deletion capsman-download-packages.capsman.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
:global ScriptLock;
:global WaitFullyConnected;

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected;

:local PackagePath [ $CleanFilePath [ /caps-man/manager/get package-path ] ];
Expand Down
4 changes: 3 additions & 1 deletion capsman-download-packages.template.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
:global ScriptLock;
:global WaitFullyConnected;

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected;

:local PackagePath [ $CleanFilePath [ /caps-man/manager/get package-path ] ];
Expand Down
4 changes: 3 additions & 1 deletion capsman-download-packages.wifi.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
:global ScriptLock;
:global WaitFullyConnected;

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected;

:local PackagePath [ $CleanFilePath [ /interface/wifi/capsman/get package-path ] ];
Expand Down
4 changes: 3 additions & 1 deletion capsman-download-packages.wifiwave2.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
:global ScriptLock;
:global WaitFullyConnected;

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected;

:local PackagePath [ $CleanFilePath [ /interface/wifiwave2/capsman/get package-path ] ];
Expand Down
4 changes: 3 additions & 1 deletion capsman-rolling-upgrade.capsman.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
:global LogPrintExit2;
:global ScriptLock;

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}

:local InstalledVersion [ /system/package/update/get installed-version ];

Expand Down
4 changes: 3 additions & 1 deletion capsman-rolling-upgrade.template.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
:global LogPrintExit2;
:global ScriptLock;

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}

:local InstalledVersion [ /system/package/update/get installed-version ];

Expand Down
4 changes: 3 additions & 1 deletion capsman-rolling-upgrade.wifi.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
:global LogPrintExit2;
:global ScriptLock;

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}

:local InstalledVersion [ /system/package/update/get installed-version ];

Expand Down
4 changes: 3 additions & 1 deletion capsman-rolling-upgrade.wifiwave2.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
:global LogPrintExit2;
:global ScriptLock;

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}

:local InstalledVersion [ /system/package/update/get installed-version ];

Expand Down
4 changes: 3 additions & 1 deletion certificate-renew-issued.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
:global MkDir;
:global ScriptLock;

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}

:foreach Cert in=[ /certificate/find where issued expires-after<3w ] do={
:local CertVal [ /certificate/get $Cert ];
Expand Down
4 changes: 3 additions & 1 deletion check-certificates.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@
[ $FormatLine "Expires in" [ $IfThenElse (($CertVal->"expired") = true) "expired" [ $FormatExpire ($CertVal->"expires-after") ] ] ]);
}

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected;

:foreach Cert in=[ /certificate/find where !revoked !ca !scep-url expires-after<$CertRenewTime ] do={
Expand Down
4 changes: 3 additions & 1 deletion check-health.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
:return ($T->0 * 10 + $T->1);
}

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}

:local Resource [ /system/resource/get ];

Expand Down
4 changes: 3 additions & 1 deletion check-lte-firmware-upgrade.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

:global ScriptLock;

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}

:if ([ :typeof $SentLteFirmwareUpgradeNotification ] != "array") do={
:global SentLteFirmwareUpgradeNotification ({});
Expand Down
4 changes: 3 additions & 1 deletion check-routeros-update.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
:error "Waiting for system to reboot.";
}

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected;

:if ([ :len [ /system/scheduler/find where name="_RebootForUpdate" ] ] > 0) do={
Expand Down
4 changes: 3 additions & 1 deletion collect-wireless-mac.capsman.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
:global SendNotification2;
:global SymbolForNotification;

$ScriptLock $ScriptName false 10;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
:return false;
}

:if ([ :len [ /caps-man/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={
/caps-man/access-list/add comment="--- collected above ---" disabled=yes;
Expand Down
4 changes: 3 additions & 1 deletion collect-wireless-mac.local.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
:global SendNotification2;
:global SymbolForNotification;

$ScriptLock $ScriptName false 10;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
:return false;
}

:if ([ :len [ /interface/wireless/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={
/interface/wireless/access-list/add comment="--- collected above ---" disabled=yes;
Expand Down
4 changes: 3 additions & 1 deletion collect-wireless-mac.template.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
:global SendNotification2;
:global SymbolForNotification;

$ScriptLock $ScriptName false 10;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
:return false;
}

:if ([ :len [ /caps-man/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={
:if ([ :len [ /interface/wifi/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={
Expand Down
4 changes: 3 additions & 1 deletion collect-wireless-mac.wifi.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
:global SendNotification2;
:global SymbolForNotification;

$ScriptLock $ScriptName false 10;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
:return false;
}

:if ([ :len [ /interface/wifi/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={
/interface/wifi/access-list/add comment="--- collected above ---" disabled=yes;
Expand Down
4 changes: 3 additions & 1 deletion collect-wireless-mac.wifiwave2.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
:global SendNotification2;
:global SymbolForNotification;

$ScriptLock $ScriptName false 10;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
:return false;
}

:if ([ :len [ /interface/wifiwave2/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={
/interface/wifiwave2/access-list/add comment="--- collected above ---" disabled=yes;
Expand Down
4 changes: 3 additions & 1 deletion daily-psk.capsman.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
:global WaitForFile;
:global WaitFullyConnected;

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected;

# return pseudo-random string for PSK
Expand Down
4 changes: 3 additions & 1 deletion daily-psk.local.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
:global WaitForFile;
:global WaitFullyConnected;

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected;

# return pseudo-random string for PSK
Expand Down
4 changes: 3 additions & 1 deletion daily-psk.template.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
:global WaitForFile;
:global WaitFullyConnected;

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected;

# return pseudo-random string for PSK
Expand Down
4 changes: 3 additions & 1 deletion daily-psk.wifi.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
:global WaitForFile;
:global WaitFullyConnected;

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected;

# return pseudo-random string for PSK
Expand Down
4 changes: 3 additions & 1 deletion daily-psk.wifiwave2.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
:global WaitForFile;
:global WaitFullyConnected;

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected;

# return pseudo-random string for PSK
Expand Down
4 changes: 3 additions & 1 deletion dhcp-lease-comment.capsman.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
:global LogPrintExit2;
:global ScriptLock;

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}

:foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={
:local LeaseVal [ /ip/dhcp-server/lease/get $Lease ];
Expand Down
4 changes: 3 additions & 1 deletion dhcp-lease-comment.local.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
:global LogPrintExit2;
:global ScriptLock;

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}

:foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={
:local LeaseVal [ /ip/dhcp-server/lease/get $Lease ];
Expand Down
4 changes: 3 additions & 1 deletion dhcp-lease-comment.template.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
:global LogPrintExit2;
:global ScriptLock;

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}

:foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={
:local LeaseVal [ /ip/dhcp-server/lease/get $Lease ];
Expand Down
4 changes: 3 additions & 1 deletion dhcp-lease-comment.wifi.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
:global LogPrintExit2;
:global ScriptLock;

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}

:foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={
:local LeaseVal [ /ip/dhcp-server/lease/get $Lease ];
Expand Down
4 changes: 3 additions & 1 deletion dhcp-lease-comment.wifiwave2.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
:global LogPrintExit2;
:global ScriptLock;

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}

:foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={
:local LeaseVal [ /ip/dhcp-server/lease/get $Lease ];
Expand Down
4 changes: 3 additions & 1 deletion dhcp-to-dns.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
:global ParseKeyValueStore;
:global ScriptLock;

$ScriptLock $ScriptName false 10;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
:return false;
}

:local Ttl 5m;
:local CommentPrefix ("managed by " . $ScriptName);
Expand Down
4 changes: 3 additions & 1 deletion firmware-upgrade-reboot.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
:global ScriptLock;
:global VersionToNum;

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}

:local RouterBoard [ /system/routerboard/get ];
:if ($RouterBoard->"current-firmware" = $RouterBoard->"upgrade-firmware") do={
Expand Down
4 changes: 3 additions & 1 deletion fw-addr-lists.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
}
}

$ScriptLock $ScriptName;
:if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected;

:local ListComment ("managed by " . $ScriptName);
Expand Down
Loading

0 comments on commit 1e8918f

Please sign in to comment.