Merge branch 'no-error-on-exit' into next

This commit is contained in:
Christian Hesse 2024-03-04 17:54:28 +01:00
commit c462c0b598
57 changed files with 210 additions and 80 deletions

View file

@ -30,7 +30,9 @@
:global SymbolForNotification; :global SymbolForNotification;
:global WaitFullyConnected; :global WaitFullyConnected;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected; $WaitFullyConnected;
:if ([ $ScriptFromTerminal $ScriptName ] = false && $BackupRandomDelay > 0) do={ :if ([ $ScriptFromTerminal $ScriptName ] = false && $BackupRandomDelay > 0) do={

View file

@ -45,7 +45,9 @@
$LogPrintExit2 error $ScriptName ("Configured to send neither backup nor config export.") true; $LogPrintExit2 error $ScriptName ("Configured to send neither backup nor config export.") true;
} }
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected; $WaitFullyConnected;
:if ([ $ScriptFromTerminal $ScriptName ] = false && $BackupRandomDelay > 0) do={ :if ([ $ScriptFromTerminal $ScriptName ] = false && $BackupRandomDelay > 0) do={

View file

@ -18,7 +18,9 @@
:global LogPrintExit2; :global LogPrintExit2;
:global ScriptLock; :global ScriptLock;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
:if ([ :len [ /partitions/find ] ] < 2) do={ :if ([ :len [ /partitions/find ] ] < 2) do={
$LogPrintExit2 error $ScriptName ("Device does not have a fallback partition.") true; $LogPrintExit2 error $ScriptName ("Device does not have a fallback partition.") true;

View file

@ -44,7 +44,9 @@
$LogPrintExit2 error $ScriptName ("Configured to send neither backup nor config export.") true; $LogPrintExit2 error $ScriptName ("Configured to send neither backup nor config export.") true;
} }
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected; $WaitFullyConnected;
:if ([ $ScriptFromTerminal $ScriptName ] = false && $BackupRandomDelay > 0) do={ :if ([ $ScriptFromTerminal $ScriptName ] = false && $BackupRandomDelay > 0) do={

View file

@ -24,7 +24,9 @@
:global ScriptLock; :global ScriptLock;
:global WaitFullyConnected; :global WaitFullyConnected;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected; $WaitFullyConnected;
:local PackagePath [ $CleanFilePath [ /caps-man/manager/get package-path ] ]; :local PackagePath [ $CleanFilePath [ /caps-man/manager/get package-path ] ];

View file

@ -25,7 +25,9 @@
:global ScriptLock; :global ScriptLock;
:global WaitFullyConnected; :global WaitFullyConnected;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected; $WaitFullyConnected;
:local PackagePath [ $CleanFilePath [ /caps-man/manager/get package-path ] ]; :local PackagePath [ $CleanFilePath [ /caps-man/manager/get package-path ] ];

View file

@ -24,7 +24,9 @@
:global ScriptLock; :global ScriptLock;
:global WaitFullyConnected; :global WaitFullyConnected;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected; $WaitFullyConnected;
:local PackagePath [ $CleanFilePath [ /interface/wifi/capsman/get package-path ] ]; :local PackagePath [ $CleanFilePath [ /interface/wifi/capsman/get package-path ] ];

View file

@ -24,7 +24,9 @@
:global ScriptLock; :global ScriptLock;
:global WaitFullyConnected; :global WaitFullyConnected;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected; $WaitFullyConnected;
:local PackagePath [ $CleanFilePath [ /interface/wifiwave2/capsman/get package-path ] ]; :local PackagePath [ $CleanFilePath [ /interface/wifiwave2/capsman/get package-path ] ];

View file

@ -21,7 +21,9 @@
:global LogPrintExit2; :global LogPrintExit2;
:global ScriptLock; :global ScriptLock;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
:local InstalledVersion [ /system/package/update/get installed-version ]; :local InstalledVersion [ /system/package/update/get installed-version ];

View file

@ -22,7 +22,9 @@
:global LogPrintExit2; :global LogPrintExit2;
:global ScriptLock; :global ScriptLock;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
:local InstalledVersion [ /system/package/update/get installed-version ]; :local InstalledVersion [ /system/package/update/get installed-version ];

View file

@ -21,7 +21,9 @@
:global LogPrintExit2; :global LogPrintExit2;
:global ScriptLock; :global ScriptLock;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
:local InstalledVersion [ /system/package/update/get installed-version ]; :local InstalledVersion [ /system/package/update/get installed-version ];

View file

@ -21,7 +21,9 @@
:global LogPrintExit2; :global LogPrintExit2;
:global ScriptLock; :global ScriptLock;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
:local InstalledVersion [ /system/package/update/get installed-version ]; :local InstalledVersion [ /system/package/update/get installed-version ];

View file

@ -20,7 +20,9 @@
:global MkDir; :global MkDir;
:global ScriptLock; :global ScriptLock;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
:foreach Cert in=[ /certificate/find where issued expires-after<3w ] do={ :foreach Cert in=[ /certificate/find where issued expires-after<3w ] do={
:local CertVal [ /certificate/get $Cert ]; :local CertVal [ /certificate/get $Cert ];

View file

@ -127,7 +127,9 @@
[ $FormatLine "Expires in" [ $IfThenElse (($CertVal->"expired") = true) "expired" [ $FormatExpire ($CertVal->"expires-after") ] ] ]); [ $FormatLine "Expires in" [ $IfThenElse (($CertVal->"expired") = true) "expired" [ $FormatExpire ($CertVal->"expires-after") ] ] ]);
} }
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected; $WaitFullyConnected;
:foreach Cert in=[ /certificate/find where !revoked !ca !scep-url expires-after<$CertRenewTime ] do={ :foreach Cert in=[ /certificate/find where !revoked !ca !scep-url expires-after<$CertRenewTime ] do={

View file

@ -39,7 +39,9 @@
:return ($T->0 * 10 + $T->1); :return ($T->0 * 10 + $T->1);
} }
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
:local Resource [ /system/resource/get ]; :local Resource [ /system/resource/get ];
@ -75,7 +77,8 @@
} }
:if ([ :len [ /system/health/find ] ] = 0) do={ :if ([ :len [ /system/health/find ] ] = 0) do={
$LogPrintExit2 debug $ScriptName ("Your device does not provide any health values.") true; $LogPrintExit2 debug $ScriptName ("Your device does not provide any health values.") false;
:return true;
} }
:if ([ :typeof $CheckHealthLast ] != "array") do={ :if ([ :typeof $CheckHealthLast ] != "array") do={

View file

@ -18,7 +18,9 @@
:global ScriptLock; :global ScriptLock;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
:if ([ :typeof $SentLteFirmwareUpgradeNotification ] != "array") do={ :if ([ :typeof $SentLteFirmwareUpgradeNotification ] != "array") do={
:global SentLteFirmwareUpgradeNotification ({}); :global SentLteFirmwareUpgradeNotification ({});

View file

@ -41,7 +41,9 @@
:error "Waiting for system to reboot."; :error "Waiting for system to reboot.";
} }
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected; $WaitFullyConnected;
:if ([ :len [ /system/scheduler/find where name="_RebootForUpdate" ] ] > 0) do={ :if ([ :len [ /system/scheduler/find where name="_RebootForUpdate" ] ] > 0) do={
@ -53,7 +55,8 @@
:local Update [ /system/package/update/get ]; :local Update [ /system/package/update/get ];
:if ([ $ScriptFromTerminal $ScriptName ] = true && ($Update->"installed-version") = ($Update->"latest-version")) do={ :if ([ $ScriptFromTerminal $ScriptName ] = true && ($Update->"installed-version") = ($Update->"latest-version")) do={
$LogPrintExit2 info $ScriptName ("System is already up to date.") true; $LogPrintExit2 info $ScriptName ("System is already up to date.") false;
:return true;
} }
:local NumInstalled [ $VersionToNum ($Update->"installed-version") ]; :local NumInstalled [ $VersionToNum ($Update->"installed-version") ];
@ -129,7 +132,8 @@
:if ($SentRouterosUpdateNotification = $Update->"latest-version") do={ :if ($SentRouterosUpdateNotification = $Update->"latest-version") do={
$LogPrintExit2 info $ScriptName ("Already sent the RouterOS update notification for version " . \ $LogPrintExit2 info $ScriptName ("Already sent the RouterOS update notification for version " . \
$Update->"latest-version" . ".") true; $Update->"latest-version" . ".") false;
:return true;
} }
$SendNotification2 ({ origin=$ScriptName; \ $SendNotification2 ({ origin=$ScriptName; \
@ -143,7 +147,8 @@
:if ($NumInstalled > $NumLatest) do={ :if ($NumInstalled > $NumLatest) do={
:if ($SentRouterosUpdateNotification = $Update->"latest-version") do={ :if ($SentRouterosUpdateNotification = $Update->"latest-version") do={
$LogPrintExit2 info $ScriptName ("Already sent the RouterOS downgrade notification for version " . \ $LogPrintExit2 info $ScriptName ("Already sent the RouterOS downgrade notification for version " . \
$Update->"latest-version" . ".") true; $Update->"latest-version" . ".") false;
:return true;
} }
$SendNotification2 ({ origin=$ScriptName; \ $SendNotification2 ({ origin=$ScriptName; \

View file

@ -28,7 +28,9 @@
:global SendNotification2; :global SendNotification2;
:global SymbolForNotification; :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 [ /caps-man/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={
/caps-man/access-list/add comment="--- collected above ---" disabled=yes; /caps-man/access-list/add comment="--- collected above ---" disabled=yes;

View file

@ -28,7 +28,9 @@
:global SendNotification2; :global SendNotification2;
:global SymbolForNotification; :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={ :if ([ :len [ /interface/wireless/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={
/interface/wireless/access-list/add comment="--- collected above ---" disabled=yes; /interface/wireless/access-list/add comment="--- collected above ---" disabled=yes;

View file

@ -29,7 +29,9 @@
:global SendNotification2; :global SendNotification2;
:global SymbolForNotification; :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 [ /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={ :if ([ :len [ /interface/wifi/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={

View file

@ -28,7 +28,9 @@
:global SendNotification2; :global SendNotification2;
:global SymbolForNotification; :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={ :if ([ :len [ /interface/wifi/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={
/interface/wifi/access-list/add comment="--- collected above ---" disabled=yes; /interface/wifi/access-list/add comment="--- collected above ---" disabled=yes;

View file

@ -28,7 +28,9 @@
:global SendNotification2; :global SendNotification2;
:global SymbolForNotification; :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={ :if ([ :len [ /interface/wifiwave2/access-list/find where comment="--- collected above ---" disabled ] ] = 0) do={
/interface/wifiwave2/access-list/add comment="--- collected above ---" disabled=yes; /interface/wifiwave2/access-list/add comment="--- collected above ---" disabled=yes;

View file

@ -30,7 +30,9 @@
:global WaitForFile; :global WaitForFile;
:global WaitFullyConnected; :global WaitFullyConnected;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected; $WaitFullyConnected;
# return pseudo-random string for PSK # return pseudo-random string for PSK

View file

@ -30,7 +30,9 @@
:global WaitForFile; :global WaitForFile;
:global WaitFullyConnected; :global WaitFullyConnected;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected; $WaitFullyConnected;
# return pseudo-random string for PSK # return pseudo-random string for PSK

View file

@ -31,7 +31,9 @@
:global WaitForFile; :global WaitForFile;
:global WaitFullyConnected; :global WaitFullyConnected;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected; $WaitFullyConnected;
# return pseudo-random string for PSK # return pseudo-random string for PSK

View file

@ -30,7 +30,9 @@
:global WaitForFile; :global WaitForFile;
:global WaitFullyConnected; :global WaitFullyConnected;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected; $WaitFullyConnected;
# return pseudo-random string for PSK # return pseudo-random string for PSK

View file

@ -30,7 +30,9 @@
:global WaitForFile; :global WaitForFile;
:global WaitFullyConnected; :global WaitFullyConnected;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected; $WaitFullyConnected;
# return pseudo-random string for PSK # return pseudo-random string for PSK

View file

@ -20,7 +20,9 @@
:global LogPrintExit2; :global LogPrintExit2;
:global ScriptLock; :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={ :foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={
:local LeaseVal [ /ip/dhcp-server/lease/get $Lease ]; :local LeaseVal [ /ip/dhcp-server/lease/get $Lease ];

View file

@ -20,7 +20,9 @@
:global LogPrintExit2; :global LogPrintExit2;
:global ScriptLock; :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={ :foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={
:local LeaseVal [ /ip/dhcp-server/lease/get $Lease ]; :local LeaseVal [ /ip/dhcp-server/lease/get $Lease ];

View file

@ -21,7 +21,9 @@
:global LogPrintExit2; :global LogPrintExit2;
:global ScriptLock; :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={ :foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={
:local LeaseVal [ /ip/dhcp-server/lease/get $Lease ]; :local LeaseVal [ /ip/dhcp-server/lease/get $Lease ];

View file

@ -20,7 +20,9 @@
:global LogPrintExit2; :global LogPrintExit2;
:global ScriptLock; :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={ :foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={
:local LeaseVal [ /ip/dhcp-server/lease/get $Lease ]; :local LeaseVal [ /ip/dhcp-server/lease/get $Lease ];

View file

@ -20,7 +20,9 @@
:global LogPrintExit2; :global LogPrintExit2;
:global ScriptLock; :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={ :foreach Lease in=[ /ip/dhcp-server/lease/find where dynamic=yes status=bound ] do={
:local LeaseVal [ /ip/dhcp-server/lease/get $Lease ]; :local LeaseVal [ /ip/dhcp-server/lease/get $Lease ];

View file

@ -26,7 +26,9 @@
:global ParseKeyValueStore; :global ParseKeyValueStore;
:global ScriptLock; :global ScriptLock;
$ScriptLock $ScriptName false 10; :if ([ $ScriptLock $ScriptName 10 ] = false) do={
:return false;
}
:local Ttl 5m; :local Ttl 5m;
:local CommentPrefix ("managed by " . $ScriptName); :local CommentPrefix ("managed by " . $ScriptName);

View file

@ -18,15 +18,19 @@
:global ScriptLock; :global ScriptLock;
:global VersionToNum; :global VersionToNum;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
:local RouterBoard [ /system/routerboard/get ]; :local RouterBoard [ /system/routerboard/get ];
:if ($RouterBoard->"current-firmware" = $RouterBoard->"upgrade-firmware") do={ :if ($RouterBoard->"current-firmware" = $RouterBoard->"upgrade-firmware") do={
$LogPrintExit2 info $ScriptName ("Current and upgrade firmware match with version " . \ $LogPrintExit2 info $ScriptName ("Current and upgrade firmware match with version " . \
$RouterBoard->"current-firmware" . ".") true; $RouterBoard->"current-firmware" . ".") false;
:return true;
} }
:if ([ $VersionToNum ($RouterBoard->"current-firmware") ] > [ $VersionToNum ($RouterBoard->"upgrade-firmware") ]) do={ :if ([ $VersionToNum ($RouterBoard->"current-firmware") ] > [ $VersionToNum ($RouterBoard->"upgrade-firmware") ]) do={
$LogPrintExit2 info $ScriptName ("Different firmware version is available, but it is a downgrade. Ignoring.") true; $LogPrintExit2 info $ScriptName ("Different firmware version is available, but it is a downgrade. Ignoring.") false;
:return true;
} }
:if ([ /system/routerboard/settings/get auto-upgrade ] = false) do={ :if ([ /system/routerboard/settings/get auto-upgrade ] = false) do={

View file

@ -34,7 +34,9 @@
} }
} }
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected; $WaitFullyConnected;
:local ListComment ("managed by " . $ScriptName); :local ListComment ("managed by " . $ScriptName);

View file

@ -328,7 +328,8 @@
} }
:if ([ $CertificateAvailable "R3" ] = false) do={ :if ([ $CertificateAvailable "R3" ] = false) do={
$LogPrintExit2 error $0 ("Downloading required certificate failed.") true; $LogPrintExit2 error $0 ("Downloading required certificate failed.") false;
:return false;
} }
:local Url ("https://upgrade.mikrotik.com/routeros/" . $PkgVer . "/" . $PkgFile); :local Url ("https://upgrade.mikrotik.com/routeros/" . $PkgVer . "/" . $PkgFile);
@ -1169,7 +1170,6 @@
# lock script against multiple invocation # lock script against multiple invocation
:set ScriptLock do={ :set ScriptLock do={
:local Script [ :tostr $1 ]; :local Script [ :tostr $1 ];
:local DoReturn $2;
:local WaitMax ([ :tonum $3 ] * 10); :local WaitMax ([ :tonum $3 ] * 10);
:global GetRandom20CharAlNum; :global GetRandom20CharAlNum;
@ -1285,13 +1285,13 @@
:if ([ $IsFirstTicket $Script $MyTicket ] = true && [ $TicketCount $Script ] = [ $JobCount $Script ]) do={ :if ([ $IsFirstTicket $Script $MyTicket ] = true && [ $TicketCount $Script ] = [ $JobCount $Script ]) do={
$RemoveTicket $Script $MyTicket; $RemoveTicket $Script $MyTicket;
$CleanupTickets $Script; $CleanupTickets $Script;
:return false; :return true;
} }
$RemoveTicket $Script $MyTicket; $RemoveTicket $Script $MyTicket;
$LogPrintExit2 info $0 ("Script '" . $Script . "' started more than once" . [ $IfThenElse ($WaitCount > 0) \ $LogPrintExit2 info $0 ("Script '" . $Script . "' started more than once" . [ $IfThenElse ($WaitCount > 0) \
" and timed out waiting for lock" "" ] . "... Aborting.") [ $IfThenElse ($DoReturn = true) false true ]; " and timed out waiting for lock" "" ] . "...") false;
:return true; :return false;
} }
# send notification via NotificationFunctions - expects at least two string arguments # send notification via NotificationFunctions - expects at least two string arguments

View file

@ -21,7 +21,9 @@
:global ScriptLock; :global ScriptLock;
:global WaitFullyConnected; :global WaitFullyConnected;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected; $WaitFullyConnected;
:local CoordinateFormat [ /system/gps/get coordinate-format ]; :local CoordinateFormat [ /system/gps/get coordinate-format ];

View file

@ -22,7 +22,9 @@
:global ParseKeyValueStore; :global ParseKeyValueStore;
:global ScriptLock; :global ScriptLock;
$ScriptLock $ScriptName false 10; :if ([ $ScriptLock $ScriptName 10 ] = false) do={
:return false;
}
:local DHCPServers ({}); :local DHCPServers ({});
:foreach Server in=[ /ip/dhcp-server/find where comment~"hotspot-to-wpa" ] do={ :foreach Server in=[ /ip/dhcp-server/find where comment~"hotspot-to-wpa" ] do={

View file

@ -23,7 +23,9 @@
:global ParseKeyValueStore; :global ParseKeyValueStore;
:global ScriptLock; :global ScriptLock;
$ScriptLock $ScriptName false 10; :if ([ $ScriptLock $ScriptName 10 ] = false) do={
:return false;
}
:local DHCPServers ({}); :local DHCPServers ({});
:foreach Server in=[ /ip/dhcp-server/find where comment~"hotspot-to-wpa" ] do={ :foreach Server in=[ /ip/dhcp-server/find where comment~"hotspot-to-wpa" ] do={

View file

@ -22,7 +22,9 @@
:global ParseKeyValueStore; :global ParseKeyValueStore;
:global ScriptLock; :global ScriptLock;
$ScriptLock $ScriptName false 10; :if ([ $ScriptLock $ScriptName 10 ] = false) do={
:return false;
}
:local DHCPServers ({}); :local DHCPServers ({});
:foreach Server in=[ /ip/dhcp-server/find where comment~"hotspot-to-wpa" ] do={ :foreach Server in=[ /ip/dhcp-server/find where comment~"hotspot-to-wpa" ] do={

View file

@ -22,7 +22,9 @@
:global ParseKeyValueStore; :global ParseKeyValueStore;
:global ScriptLock; :global ScriptLock;
$ScriptLock $ScriptName false 10; :if ([ $ScriptLock $ScriptName 10 ] = false) do={
:return false;
}
:local DHCPServers ({}); :local DHCPServers ({});
:foreach Server in=[ /ip/dhcp-server/find where comment~"hotspot-to-wpa" ] do={ :foreach Server in=[ /ip/dhcp-server/find where comment~"hotspot-to-wpa" ] do={

View file

@ -23,7 +23,9 @@
:global ParseKeyValueStore; :global ParseKeyValueStore;
:global ScriptLock; :global ScriptLock;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
:if ([ :len $MacAddress ] = 0 || [ :len $UserName ] = 0) do={ :if ([ :len $MacAddress ] = 0 || [ :len $UserName ] = 0) do={
$LogPrintExit2 error $ScriptName ("This script is supposed to run from hotspot on login.") true; $LogPrintExit2 error $ScriptName ("This script is supposed to run from hotspot on login.") true;
@ -52,7 +54,8 @@
comment=("hotspot-to-wpa template " . $Hotspot) disabled ]->0) ]; comment=("hotspot-to-wpa template " . $Hotspot) disabled ]->0) ];
:if ($Template->"action" = "reject") do={ :if ($Template->"action" = "reject") do={
$LogPrintExit2 info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'.") true; $LogPrintExit2 info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'.") false;
:return true;
} }
# allow login page to load # allow login page to load

View file

@ -24,7 +24,9 @@
:global ParseKeyValueStore; :global ParseKeyValueStore;
:global ScriptLock; :global ScriptLock;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
:if ([ :len $MacAddress ] = 0 || [ :len $UserName ] = 0) do={ :if ([ :len $MacAddress ] = 0 || [ :len $UserName ] = 0) do={
$LogPrintExit2 error $ScriptName ("This script is supposed to run from hotspot on login.") true; $LogPrintExit2 error $ScriptName ("This script is supposed to run from hotspot on login.") true;
@ -65,7 +67,8 @@
comment=("hotspot-to-wpa template " . $Hotspot) disabled ]->0) ]; comment=("hotspot-to-wpa template " . $Hotspot) disabled ]->0) ];
:if ($Template->"action" = "reject") do={ :if ($Template->"action" = "reject") do={
$LogPrintExit2 info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'.") true; $LogPrintExit2 info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'.") false;
:return true;
} }
# allow login page to load # allow login page to load

View file

@ -23,7 +23,9 @@
:global ParseKeyValueStore; :global ParseKeyValueStore;
:global ScriptLock; :global ScriptLock;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
:if ([ :len $MacAddress ] = 0 || [ :len $UserName ] = 0) do={ :if ([ :len $MacAddress ] = 0 || [ :len $UserName ] = 0) do={
$LogPrintExit2 error $ScriptName ("This script is supposed to run from hotspot on login.") true; $LogPrintExit2 error $ScriptName ("This script is supposed to run from hotspot on login.") true;
@ -52,7 +54,8 @@
comment=("hotspot-to-wpa template " . $Hotspot) disabled ]->0) ]; comment=("hotspot-to-wpa template " . $Hotspot) disabled ]->0) ];
:if ($Template->"action" = "reject") do={ :if ($Template->"action" = "reject") do={
$LogPrintExit2 info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'.") true; $LogPrintExit2 info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'.") false;
:return true;
} }
# allow login page to load # allow login page to load

View file

@ -23,7 +23,9 @@
:global ParseKeyValueStore; :global ParseKeyValueStore;
:global ScriptLock; :global ScriptLock;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
:if ([ :len $MacAddress ] = 0 || [ :len $UserName ] = 0) do={ :if ([ :len $MacAddress ] = 0 || [ :len $UserName ] = 0) do={
$LogPrintExit2 error $ScriptName ("This script is supposed to run from hotspot on login.") true; $LogPrintExit2 error $ScriptName ("This script is supposed to run from hotspot on login.") true;
@ -52,7 +54,8 @@
comment=("hotspot-to-wpa template " . $Hotspot) disabled ]->0) ]; comment=("hotspot-to-wpa template " . $Hotspot) disabled ]->0) ];
:if ($Template->"action" = "reject") do={ :if ($Template->"action" = "reject") do={
$LogPrintExit2 info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'.") true; $LogPrintExit2 info $ScriptName ("Ignoring login for hotspot '" . $Hotspot . "'.") false;
:return true;
} }
# allow login page to load # allow login page to load

View file

@ -25,7 +25,9 @@
:global LogPrintExit2; :global LogPrintExit2;
:global ScriptLock; :global ScriptLock;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
:local Zone \ :local Zone \
([ $IfThenElse ($PrefixInZone = true) "ipsec." ] . \ ([ $IfThenElse ($PrefixInZone = true) "ipsec." ] . \

View file

@ -19,7 +19,9 @@
:global ParseKeyValueStore; :global ParseKeyValueStore;
:global ScriptLock; :global ScriptLock;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
:if ([ :typeof $PdPrefix ] = "nothing") do={ :if ([ :typeof $PdPrefix ] = "nothing") do={
$LogPrintExit2 error $ScriptName ("This script is supposed to run from ipv6 dhcp-client.") true; $LogPrintExit2 error $ScriptName ("This script is supposed to run from ipv6 dhcp-client.") true;

View file

@ -34,10 +34,13 @@
$LogPrintExit2 debug $ScriptName ("DHCP Server " . $leaseServerName . " " . [ $IfThenElse ($leaseBound = 0) \ $LogPrintExit2 debug $ScriptName ("DHCP Server " . $leaseServerName . " " . [ $IfThenElse ($leaseBound = 0) \
"de" "" ] . "assigned lease " . $leaseActIP . " to " . $leaseActMAC) false; "de" "" ] . "assigned lease " . $leaseActIP . " to " . $leaseActMAC) false;
$ScriptLock $ScriptName false 10; :if ([ $ScriptLock $ScriptName 10 ] = false) do={
:return false;
}
:if ([ :len [ /system/script/job/find where script=$ScriptName ] ] > 1) do={ :if ([ :len [ /system/script/job/find where script=$ScriptName ] ] > 1) do={
$LogPrintExit2 debug $ScriptName ("More invocations are waiting, exiting early.") true; $LogPrintExit2 debug $ScriptName ("More invocations are waiting, exiting early.") false;
:return true;
} }
:local RunOrder ({}); :local RunOrder ({});

View file

@ -32,7 +32,9 @@
:global SendNotification2; :global SendNotification2;
:global SymbolForNotification; :global SymbolForNotification;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
:if ([ :typeof $LogForwardRateLimit ] = "nothing") do={ :if ([ :typeof $LogForwardRateLimit ] = "nothing") do={
:set LogForwardRateLimit 0; :set LogForwardRateLimit 0;
@ -40,7 +42,8 @@
:if ($LogForwardRateLimit > 30) do={ :if ($LogForwardRateLimit > 30) do={
:set LogForwardRateLimit ($LogForwardRateLimit - 1); :set LogForwardRateLimit ($LogForwardRateLimit - 1);
$LogPrintExit2 info $ScriptName ("Rate limit in action, not forwarding logs, if any!") true; $LogPrintExit2 info $ScriptName ("Rate limit in action, not forwarding logs, if any!") false;
:return true;
} }
:local Count 0; :local Count 0;

View file

@ -20,11 +20,14 @@
:global ParseKeyValueStore; :global ParseKeyValueStore;
:global ScriptLock; :global ScriptLock;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
:local SettleTime (5m30s - [ /system/resource/get uptime ]); :local SettleTime (5m30s - [ /system/resource/get uptime ]);
:if ($SettleTime > 0s) do={ :if ($SettleTime > 0s) do={
$LogPrintExit2 info $ScriptName ("System just booted, giving netwatch " . $SettleTime . " to settle.") true; $LogPrintExit2 info $ScriptName ("System just booted, giving netwatch " . $SettleTime . " to settle.") false;
:return true;
} }
:local DnsServers ({}); :local DnsServers ({});
@ -80,7 +83,8 @@
} }
:if ($DohCurrent = $HostInfo->"doh-url") do={ :if ($DohCurrent = $HostInfo->"doh-url") do={
$LogPrintExit2 debug $ScriptName ("Current DoH server is still up: " . $DohCurrent) true; $LogPrintExit2 debug $ScriptName ("Current DoH server is still up: " . $DohCurrent) false;
:return true;
} }
:set ($DohServers->[ :len $DohServers ]) $HostInfo; :set ($DohServers->[ :len $DohServers ]) $HostInfo;
@ -116,7 +120,8 @@
:if ([ :typeof [ :find $Data "doh-check-OK" ] ] = "num") do={ :if ([ :typeof [ :find $Data "doh-check-OK" ] ] = "num") do={
/ip/dns/set use-doh-server=($DohServer->"doh-url") verify-doh-cert=yes; /ip/dns/set use-doh-server=($DohServer->"doh-url") verify-doh-cert=yes;
/ip/dns/cache/flush; /ip/dns/cache/flush;
$LogPrintExit2 info $ScriptName ("Setting DoH server: " . ($DohServer->"doh-url")) true; $LogPrintExit2 info $ScriptName ("Setting DoH server: " . ($DohServer->"doh-url")) false;
:return true;
} else={ } else={
$LogPrintExit2 warning $ScriptName ("Received unexpected response from DoH server: " . \ $LogPrintExit2 warning $ScriptName ("Received unexpected response from DoH server: " . \
($DohServer->"doh-url")) false; ($DohServer->"doh-url")) false;

View file

@ -75,7 +75,9 @@
:return false; :return false;
} }
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
:local ScriptFromTerminalCached [ $ScriptFromTerminal $ScriptName ]; :local ScriptFromTerminalCached [ $ScriptFromTerminal $ScriptName ];

View file

@ -18,7 +18,9 @@
:global ParseKeyValueStore; :global ParseKeyValueStore;
:global ScriptLock; :global ScriptLock;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
:foreach Instance in=[ /routing/ospf/instance/find where comment~"^ospf-to-leds," ] do={ :foreach Instance in=[ /routing/ospf/instance/find where comment~"^ospf-to-leds," ] do={
:local InstanceVal [ /routing/ospf/instance/get $Instance ]; :local InstanceVal [ /routing/ospf/instance/get $Instance ];

View file

@ -39,10 +39,13 @@
on-event=("/system/scheduler/remove \"_RebootForUpdate\"; " . \ on-event=("/system/scheduler/remove \"_RebootForUpdate\"; " . \
":global RebootForUpdate; \$RebootForUpdate;"); ":global RebootForUpdate; \$RebootForUpdate;");
$LogPrintExit2 info $ScriptName ("Scheduled reboot for update at " . $StartTime . \ $LogPrintExit2 info $ScriptName ("Scheduled reboot for update at " . $StartTime . \
" local time (" . [ /system/clock/get time-zone-name ] . ").") true; " local time (" . [ /system/clock/get time-zone-name ] . ").") false;
:return true;
} }
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
:local Update [ /system/package/update/get ]; :local Update [ /system/package/update/get ];
@ -51,7 +54,8 @@
} }
:if ($Update->"installed-version" = $Update->"latest-version") do={ :if ($Update->"installed-version" = $Update->"latest-version") do={
$LogPrintExit2 info $ScriptName ("Version " . $Update->"latest-version" . " is already installed.") true; $LogPrintExit2 info $ScriptName ("Version " . $Update->"latest-version" . " is already installed.") false;
:return true;
} }
:local NumInstalled [ $VersionToNum ($Update->"installed-version") ]; :local NumInstalled [ $VersionToNum ($Update->"installed-version") ];

View file

@ -27,7 +27,9 @@
:global ValidateSyntax; :global ValidateSyntax;
:global WaitFullyConnected; :global WaitFullyConnected;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
:if ([ /tool/sms/get receive-enabled ] = false) do={ :if ([ /tool/sms/get receive-enabled ] = false) do={
$LogPrintOnce warning $ScriptName ("Receiving of SMS is not enabled.") true; $LogPrintOnce warning $ScriptName ("Receiving of SMS is not enabled.") true;
@ -38,7 +40,8 @@
:local Settings [ /tool/sms/get ]; :local Settings [ /tool/sms/get ];
:if ([ /interface/lte/get ($Settings->"port") running ] != true) do={ :if ([ /interface/lte/get ($Settings->"port") running ] != true) do={
$LogPrintExit2 info $ScriptName ("The LTE interface is not in running state, skipping.") true; $LogPrintExit2 info $ScriptName ("The LTE interface is not in running state, skipping.") false;
:return true;
} }
# forward SMS in a loop # forward SMS in a loop

View file

@ -43,7 +43,9 @@
:global WaitForFile; :global WaitForFile;
:global WaitFullyConnected; :global WaitFullyConnected;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
$WaitFullyConnected; $WaitFullyConnected;

View file

@ -19,7 +19,9 @@
:global LogPrintExit2; :global LogPrintExit2;
:global ScriptLock; :global ScriptLock;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
/interface/gre/set remote-address=0.0.0.0 disabled=yes [ find where !running !disabled ]; /interface/gre/set remote-address=0.0.0.0 disabled=yes [ find where !running !disabled ];

View file

@ -21,7 +21,9 @@
:global ParseKeyValueStore; :global ParseKeyValueStore;
:global ScriptLock; :global ScriptLock;
$ScriptLock $ScriptName; :if ([ $ScriptLock $ScriptName ] = false) do={
:return false;
}
:if ([ $CertificateAvailable "Starfield Secure Certificate Authority - G2" ] = false) do={ :if ([ $CertificateAvailable "Starfield Secure Certificate Authority - G2" ] = false) do={
$LogPrintExit2 error $ScriptName ("Downloading required certificate failed.") true; $LogPrintExit2 error $ScriptName ("Downloading required certificate failed.") true;