mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
Merge branch 'no-error-on-exit' into next
This commit is contained in:
commit
c462c0b598
57 changed files with 210 additions and 80 deletions
|
@ -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={
|
||||
|
|
|
@ -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={
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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={
|
||||
|
|
|
@ -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 ] ];
|
||||
|
|
|
@ -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 ] ];
|
||||
|
|
|
@ -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 ] ];
|
||||
|
|
|
@ -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 ] ];
|
||||
|
|
|
@ -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 ];
|
||||
|
||||
|
|
|
@ -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 ];
|
||||
|
||||
|
|
|
@ -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 ];
|
||||
|
||||
|
|
|
@ -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 ];
|
||||
|
||||
|
|
|
@ -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 ];
|
||||
|
|
|
@ -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={
|
||||
|
|
|
@ -39,7 +39,9 @@
|
|||
:return ($T->0 * 10 + $T->1);
|
||||
}
|
||||
|
||||
$ScriptLock $ScriptName;
|
||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||
:return false;
|
||||
}
|
||||
|
||||
:local Resource [ /system/resource/get ];
|
||||
|
||||
|
@ -75,7 +77,8 @@
|
|||
}
|
||||
|
||||
: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={
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
|
||||
:global ScriptLock;
|
||||
|
||||
$ScriptLock $ScriptName;
|
||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||
:return false;
|
||||
}
|
||||
|
||||
:if ([ :typeof $SentLteFirmwareUpgradeNotification ] != "array") do={
|
||||
:global SentLteFirmwareUpgradeNotification ({});
|
||||
|
|
|
@ -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={
|
||||
|
@ -53,7 +55,8 @@
|
|||
:local Update [ /system/package/update/get ];
|
||||
|
||||
: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") ];
|
||||
|
@ -129,7 +132,8 @@
|
|||
|
||||
:if ($SentRouterosUpdateNotification = $Update->"latest-version") do={
|
||||
$LogPrintExit2 info $ScriptName ("Already sent the RouterOS update notification for version " . \
|
||||
$Update->"latest-version" . ".") true;
|
||||
$Update->"latest-version" . ".") false;
|
||||
:return true;
|
||||
}
|
||||
|
||||
$SendNotification2 ({ origin=$ScriptName; \
|
||||
|
@ -143,7 +147,8 @@
|
|||
:if ($NumInstalled > $NumLatest) do={
|
||||
:if ($SentRouterosUpdateNotification = $Update->"latest-version") do={
|
||||
$LogPrintExit2 info $ScriptName ("Already sent the RouterOS downgrade notification for version " . \
|
||||
$Update->"latest-version" . ".") true;
|
||||
$Update->"latest-version" . ".") false;
|
||||
:return true;
|
||||
}
|
||||
|
||||
$SendNotification2 ({ origin=$ScriptName; \
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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={
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -30,7 +30,9 @@
|
|||
:global WaitForFile;
|
||||
:global WaitFullyConnected;
|
||||
|
||||
$ScriptLock $ScriptName;
|
||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||
:return false;
|
||||
}
|
||||
$WaitFullyConnected;
|
||||
|
||||
# return pseudo-random string for PSK
|
||||
|
|
|
@ -30,7 +30,9 @@
|
|||
:global WaitForFile;
|
||||
:global WaitFullyConnected;
|
||||
|
||||
$ScriptLock $ScriptName;
|
||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||
:return false;
|
||||
}
|
||||
$WaitFullyConnected;
|
||||
|
||||
# return pseudo-random string for PSK
|
||||
|
|
|
@ -31,7 +31,9 @@
|
|||
:global WaitForFile;
|
||||
:global WaitFullyConnected;
|
||||
|
||||
$ScriptLock $ScriptName;
|
||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||
:return false;
|
||||
}
|
||||
$WaitFullyConnected;
|
||||
|
||||
# return pseudo-random string for PSK
|
||||
|
|
|
@ -30,7 +30,9 @@
|
|||
:global WaitForFile;
|
||||
:global WaitFullyConnected;
|
||||
|
||||
$ScriptLock $ScriptName;
|
||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||
:return false;
|
||||
}
|
||||
$WaitFullyConnected;
|
||||
|
||||
# return pseudo-random string for PSK
|
||||
|
|
|
@ -30,7 +30,9 @@
|
|||
:global WaitForFile;
|
||||
:global WaitFullyConnected;
|
||||
|
||||
$ScriptLock $ScriptName;
|
||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||
:return false;
|
||||
}
|
||||
$WaitFullyConnected;
|
||||
|
||||
# return pseudo-random string for PSK
|
||||
|
|
|
@ -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 ];
|
||||
|
|
|
@ -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 ];
|
||||
|
|
|
@ -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 ];
|
||||
|
|
|
@ -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 ];
|
||||
|
|
|
@ -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 ];
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -18,15 +18,19 @@
|
|||
: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={
|
||||
$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={
|
||||
$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={
|
||||
|
|
|
@ -34,7 +34,9 @@
|
|||
}
|
||||
}
|
||||
|
||||
$ScriptLock $ScriptName;
|
||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||
:return false;
|
||||
}
|
||||
$WaitFullyConnected;
|
||||
|
||||
:local ListComment ("managed by " . $ScriptName);
|
||||
|
|
|
@ -328,7 +328,8 @@
|
|||
}
|
||||
|
||||
: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);
|
||||
|
@ -1169,8 +1170,7 @@
|
|||
# lock script against multiple invocation
|
||||
:set ScriptLock do={
|
||||
:local Script [ :tostr $1 ];
|
||||
:local DoReturn $2;
|
||||
:local WaitMax ([ :tonum $3 ] * 10);
|
||||
:local WaitMax ([ :tonum $3 ] * 10);
|
||||
|
||||
:global GetRandom20CharAlNum;
|
||||
:global IfThenElse;
|
||||
|
@ -1285,13 +1285,13 @@
|
|||
:if ([ $IsFirstTicket $Script $MyTicket ] = true && [ $TicketCount $Script ] = [ $JobCount $Script ]) do={
|
||||
$RemoveTicket $Script $MyTicket;
|
||||
$CleanupTickets $Script;
|
||||
:return false;
|
||||
:return true;
|
||||
}
|
||||
|
||||
$RemoveTicket $Script $MyTicket;
|
||||
$LogPrintExit2 info $0 ("Script '" . $Script . "' started more than once" . [ $IfThenElse ($WaitCount > 0) \
|
||||
" and timed out waiting for lock" "" ] . "... Aborting.") [ $IfThenElse ($DoReturn = true) false true ];
|
||||
:return true;
|
||||
" and timed out waiting for lock" "" ] . "...") false;
|
||||
:return false;
|
||||
}
|
||||
|
||||
# send notification via NotificationFunctions - expects at least two string arguments
|
||||
|
|
|
@ -21,7 +21,9 @@
|
|||
:global ScriptLock;
|
||||
:global WaitFullyConnected;
|
||||
|
||||
$ScriptLock $ScriptName;
|
||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||
:return false;
|
||||
}
|
||||
$WaitFullyConnected;
|
||||
|
||||
:local CoordinateFormat [ /system/gps/get coordinate-format ];
|
||||
|
|
|
@ -22,7 +22,9 @@
|
|||
:global ParseKeyValueStore;
|
||||
:global ScriptLock;
|
||||
|
||||
$ScriptLock $ScriptName false 10;
|
||||
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
|
||||
:return false;
|
||||
}
|
||||
|
||||
:local DHCPServers ({});
|
||||
:foreach Server in=[ /ip/dhcp-server/find where comment~"hotspot-to-wpa" ] do={
|
||||
|
|
|
@ -23,7 +23,9 @@
|
|||
:global ParseKeyValueStore;
|
||||
:global ScriptLock;
|
||||
|
||||
$ScriptLock $ScriptName false 10;
|
||||
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
|
||||
:return false;
|
||||
}
|
||||
|
||||
:local DHCPServers ({});
|
||||
:foreach Server in=[ /ip/dhcp-server/find where comment~"hotspot-to-wpa" ] do={
|
||||
|
|
|
@ -22,7 +22,9 @@
|
|||
:global ParseKeyValueStore;
|
||||
:global ScriptLock;
|
||||
|
||||
$ScriptLock $ScriptName false 10;
|
||||
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
|
||||
:return false;
|
||||
}
|
||||
|
||||
:local DHCPServers ({});
|
||||
:foreach Server in=[ /ip/dhcp-server/find where comment~"hotspot-to-wpa" ] do={
|
||||
|
|
|
@ -22,7 +22,9 @@
|
|||
:global ParseKeyValueStore;
|
||||
:global ScriptLock;
|
||||
|
||||
$ScriptLock $ScriptName false 10;
|
||||
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
|
||||
:return false;
|
||||
}
|
||||
|
||||
:local DHCPServers ({});
|
||||
:foreach Server in=[ /ip/dhcp-server/find where comment~"hotspot-to-wpa" ] do={
|
||||
|
|
|
@ -23,7 +23,9 @@
|
|||
:global ParseKeyValueStore;
|
||||
:global ScriptLock;
|
||||
|
||||
$ScriptLock $ScriptName;
|
||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||
:return false;
|
||||
}
|
||||
|
||||
:if ([ :len $MacAddress ] = 0 || [ :len $UserName ] = 0) do={
|
||||
$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) ];
|
||||
|
||||
: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
|
||||
|
|
|
@ -24,7 +24,9 @@
|
|||
:global ParseKeyValueStore;
|
||||
:global ScriptLock;
|
||||
|
||||
$ScriptLock $ScriptName;
|
||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||
:return false;
|
||||
}
|
||||
|
||||
:if ([ :len $MacAddress ] = 0 || [ :len $UserName ] = 0) do={
|
||||
$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) ];
|
||||
|
||||
: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
|
||||
|
|
|
@ -23,7 +23,9 @@
|
|||
:global ParseKeyValueStore;
|
||||
:global ScriptLock;
|
||||
|
||||
$ScriptLock $ScriptName;
|
||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||
:return false;
|
||||
}
|
||||
|
||||
:if ([ :len $MacAddress ] = 0 || [ :len $UserName ] = 0) do={
|
||||
$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) ];
|
||||
|
||||
: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
|
||||
|
|
|
@ -23,7 +23,9 @@
|
|||
:global ParseKeyValueStore;
|
||||
:global ScriptLock;
|
||||
|
||||
$ScriptLock $ScriptName;
|
||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||
:return false;
|
||||
}
|
||||
|
||||
:if ([ :len $MacAddress ] = 0 || [ :len $UserName ] = 0) do={
|
||||
$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) ];
|
||||
|
||||
: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
|
||||
|
|
|
@ -25,7 +25,9 @@
|
|||
:global LogPrintExit2;
|
||||
:global ScriptLock;
|
||||
|
||||
$ScriptLock $ScriptName;
|
||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||
:return false;
|
||||
}
|
||||
|
||||
:local Zone \
|
||||
([ $IfThenElse ($PrefixInZone = true) "ipsec." ] . \
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
:global ParseKeyValueStore;
|
||||
:global ScriptLock;
|
||||
|
||||
$ScriptLock $ScriptName;
|
||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||
:return false;
|
||||
}
|
||||
|
||||
:if ([ :typeof $PdPrefix ] = "nothing") do={
|
||||
$LogPrintExit2 error $ScriptName ("This script is supposed to run from ipv6 dhcp-client.") true;
|
||||
|
|
|
@ -34,10 +34,13 @@
|
|||
$LogPrintExit2 debug $ScriptName ("DHCP Server " . $leaseServerName . " " . [ $IfThenElse ($leaseBound = 0) \
|
||||
"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={
|
||||
$LogPrintExit2 debug $ScriptName ("More invocations are waiting, exiting early.") true;
|
||||
$LogPrintExit2 debug $ScriptName ("More invocations are waiting, exiting early.") false;
|
||||
:return true;
|
||||
}
|
||||
|
||||
:local RunOrder ({});
|
||||
|
|
|
@ -32,7 +32,9 @@
|
|||
:global SendNotification2;
|
||||
:global SymbolForNotification;
|
||||
|
||||
$ScriptLock $ScriptName;
|
||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||
:return false;
|
||||
}
|
||||
|
||||
:if ([ :typeof $LogForwardRateLimit ] = "nothing") do={
|
||||
:set LogForwardRateLimit 0;
|
||||
|
@ -40,7 +42,8 @@
|
|||
|
||||
:if ($LogForwardRateLimit > 30) do={
|
||||
: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;
|
||||
|
|
|
@ -20,11 +20,14 @@
|
|||
:global ParseKeyValueStore;
|
||||
:global ScriptLock;
|
||||
|
||||
$ScriptLock $ScriptName;
|
||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||
:return false;
|
||||
}
|
||||
|
||||
:local SettleTime (5m30s - [ /system/resource/get uptime ]);
|
||||
: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 ({});
|
||||
|
@ -80,7 +83,8 @@
|
|||
}
|
||||
|
||||
: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;
|
||||
|
@ -116,7 +120,8 @@
|
|||
:if ([ :typeof [ :find $Data "doh-check-OK" ] ] = "num") do={
|
||||
/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")) true;
|
||||
$LogPrintExit2 info $ScriptName ("Setting DoH server: " . ($DohServer->"doh-url")) false;
|
||||
:return true;
|
||||
} else={
|
||||
$LogPrintExit2 warning $ScriptName ("Received unexpected response from DoH server: " . \
|
||||
($DohServer->"doh-url")) false;
|
||||
|
|
|
@ -75,7 +75,9 @@
|
|||
:return false;
|
||||
}
|
||||
|
||||
$ScriptLock $ScriptName;
|
||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||
:return false;
|
||||
}
|
||||
|
||||
:local ScriptFromTerminalCached [ $ScriptFromTerminal $ScriptName ];
|
||||
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
:global ParseKeyValueStore;
|
||||
:global ScriptLock;
|
||||
|
||||
$ScriptLock $ScriptName;
|
||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||
:return false;
|
||||
}
|
||||
|
||||
:foreach Instance in=[ /routing/ospf/instance/find where comment~"^ospf-to-leds," ] do={
|
||||
:local InstanceVal [ /routing/ospf/instance/get $Instance ];
|
||||
|
|
|
@ -39,10 +39,13 @@
|
|||
on-event=("/system/scheduler/remove \"_RebootForUpdate\"; " . \
|
||||
":global RebootForUpdate; \$RebootForUpdate;");
|
||||
$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 ];
|
||||
|
||||
|
@ -51,7 +54,8 @@
|
|||
}
|
||||
|
||||
: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") ];
|
||||
|
|
|
@ -27,7 +27,9 @@
|
|||
:global ValidateSyntax;
|
||||
:global WaitFullyConnected;
|
||||
|
||||
$ScriptLock $ScriptName;
|
||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||
:return false;
|
||||
}
|
||||
|
||||
:if ([ /tool/sms/get receive-enabled ] = false) do={
|
||||
$LogPrintOnce warning $ScriptName ("Receiving of SMS is not enabled.") true;
|
||||
|
@ -38,7 +40,8 @@
|
|||
:local Settings [ /tool/sms/get ];
|
||||
|
||||
: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
|
||||
|
|
|
@ -43,7 +43,9 @@
|
|||
:global WaitForFile;
|
||||
:global WaitFullyConnected;
|
||||
|
||||
$ScriptLock $ScriptName;
|
||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||
:return false;
|
||||
}
|
||||
|
||||
$WaitFullyConnected;
|
||||
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
:global LogPrintExit2;
|
||||
: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 ];
|
||||
|
||||
|
|
|
@ -21,7 +21,9 @@
|
|||
:global ParseKeyValueStore;
|
||||
:global ScriptLock;
|
||||
|
||||
$ScriptLock $ScriptName;
|
||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||
:return false;
|
||||
}
|
||||
|
||||
:if ([ $CertificateAvailable "Starfield Secure Certificate Authority - G2" ] = false) do={
|
||||
$LogPrintExit2 error $ScriptName ("Downloading required certificate failed.") true;
|
||||
|
|
Loading…
Reference in a new issue