mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-08-29 14:28:36 +02:00
Compare commits
No commits in common. "main" and "routeros-7.20beta2-1" have entirely different histories.
main
...
routeros-7
21 changed files with 55 additions and 107 deletions
|
@ -35,7 +35,6 @@ Add yourself to the list,
|
||||||
[donate with PayPal ↗️](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J)!
|
[donate with PayPal ↗️](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J)!
|
||||||
|
|
||||||
* Abdul Mannan Abbasi
|
* Abdul Mannan Abbasi
|
||||||
* Alex Maier
|
|
||||||
* Andrea Ruffini Perico
|
* Andrea Ruffini Perico
|
||||||
* Andrew Cox
|
* Andrew Cox
|
||||||
* Christoph Boss (@Kampfwurst)
|
* Christoph Boss (@Kampfwurst)
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
:foreach AccList in=[ /caps-man/access-list/find where mac-address!="00:00:00:00:00:00" ] do={
|
:foreach AccList in=[ /caps-man/access-list/find where mac-address!="00:00:00:00:00:00" ] do={
|
||||||
:local Mac [ /caps-man/access-list/get $AccList mac-address ];
|
:local Mac [ /caps-man/access-list/get $AccList mac-address ];
|
||||||
:if ($Seen->$Mac = 1) do={
|
:if ($Seen->$Mac = 1) do={
|
||||||
/caps-man/access-list/print without-paging where mac-address=$Mac;
|
/caps-man/access-list/print where mac-address=$Mac;
|
||||||
:local Remove [ :tonum [ /terminal/ask prompt="\nNumeric id to remove, any key to skip!" ] ];
|
:local Remove [ :tonum [ /terminal/ask prompt="\nNumeric id to remove, any key to skip!" ] ];
|
||||||
|
|
||||||
:if ([ :typeof $Remove ] = "num") do={
|
:if ([ :typeof $Remove ] = "num") do={
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
:foreach AccList in=[ /interface/wireless/access-list/find where mac-address!="00:00:00:00:00:00" ] do={
|
:foreach AccList in=[ /interface/wireless/access-list/find where mac-address!="00:00:00:00:00:00" ] do={
|
||||||
:local Mac [ /interface/wireless/access-list/get $AccList mac-address ];
|
:local Mac [ /interface/wireless/access-list/get $AccList mac-address ];
|
||||||
:if ($Seen->$Mac = 1) do={
|
:if ($Seen->$Mac = 1) do={
|
||||||
/interface/wireless/access-list/print without-paging where mac-address=$Mac;
|
/interface/wireless/access-list/print where mac-address=$Mac;
|
||||||
:local Remove [ :tonum [ /terminal/ask prompt="\nNumeric id to remove, any key to skip!" ] ];
|
:local Remove [ :tonum [ /terminal/ask prompt="\nNumeric id to remove, any key to skip!" ] ];
|
||||||
|
|
||||||
:if ([ :typeof $Remove ] = "num") do={
|
:if ([ :typeof $Remove ] = "num") do={
|
||||||
|
|
|
@ -27,9 +27,9 @@
|
||||||
:local Mac [ /interface/wifi/access-list/get $AccList mac-address ];
|
:local Mac [ /interface/wifi/access-list/get $AccList mac-address ];
|
||||||
:local Mac [ /interface/wireless/access-list/get $AccList mac-address ];
|
:local Mac [ /interface/wireless/access-list/get $AccList mac-address ];
|
||||||
:if ($Seen->$Mac = 1) do={
|
:if ($Seen->$Mac = 1) do={
|
||||||
/caps-man/access-list/print without-paging where mac-address=$Mac;
|
/caps-man/access-list/print where mac-address=$Mac;
|
||||||
/interface/wifi/access-list/print without-paging where mac-address=$Mac;
|
/interface/wifi/access-list/print where mac-address=$Mac;
|
||||||
/interface/wireless/access-list/print without-paging where mac-address=$Mac;
|
/interface/wireless/access-list/print where mac-address=$Mac;
|
||||||
:local Remove [ :tonum [ /terminal/ask prompt="\nNumeric id to remove, any key to skip!" ] ];
|
:local Remove [ :tonum [ /terminal/ask prompt="\nNumeric id to remove, any key to skip!" ] ];
|
||||||
|
|
||||||
:if ([ :typeof $Remove ] = "num") do={
|
:if ([ :typeof $Remove ] = "num") do={
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
:foreach AccList in=[ /interface/wifi/access-list/find where mac-address!="00:00:00:00:00:00" ] do={
|
:foreach AccList in=[ /interface/wifi/access-list/find where mac-address!="00:00:00:00:00:00" ] do={
|
||||||
:local Mac [ /interface/wifi/access-list/get $AccList mac-address ];
|
:local Mac [ /interface/wifi/access-list/get $AccList mac-address ];
|
||||||
:if ($Seen->$Mac = 1) do={
|
:if ($Seen->$Mac = 1) do={
|
||||||
/interface/wifi/access-list/print without-paging where mac-address=$Mac;
|
/interface/wifi/access-list/print where mac-address=$Mac;
|
||||||
:local Remove [ :tonum [ /terminal/ask prompt="\nNumeric id to remove, any key to skip!" ] ];
|
:local Remove [ :tonum [ /terminal/ask prompt="\nNumeric id to remove, any key to skip!" ] ];
|
||||||
|
|
||||||
:if ([ :typeof $Remove ] = "num") do={
|
:if ([ :typeof $Remove ] = "num") do={
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# Michael Gisbers <michael@gisbers.de>
|
# Michael Gisbers <michael@gisbers.de>
|
||||||
# https://rsc.eworm.de/COPYING.md
|
# https://rsc.eworm.de/COPYING.md
|
||||||
#
|
#
|
||||||
# requires RouterOS, version=7.15
|
# requires RouterOS, version=7.18
|
||||||
#
|
#
|
||||||
# download and cleanup packages for CAP installation from CAPsMAN
|
# download and cleanup packages for CAP installation from CAPsMAN
|
||||||
# https://rsc.eworm.de/doc/capsman-download-packages.md
|
# https://rsc.eworm.de/doc/capsman-download-packages.md
|
||||||
|
@ -54,8 +54,8 @@
|
||||||
"). Please place your packages!");
|
"). Please place your packages!");
|
||||||
}
|
}
|
||||||
|
|
||||||
:foreach Package in=[ /file/find where type="package" \
|
:foreach Package in=[ /file/find recursive where path=$PackagePath \
|
||||||
package-version!=$InstalledVersion name~("^" . $PackagePath) ] do={
|
type="package" package-version!=$InstalledVersion ] do={
|
||||||
:local File [ /file/get $Package ];
|
:local File [ /file/get $Package ];
|
||||||
:if ($File->"package-architecture" = "mips") do={
|
:if ($File->"package-architecture" = "mips") do={
|
||||||
:set ($File->"package-architecture") "mipsbe";
|
:set ($File->"package-architecture") "mipsbe";
|
||||||
|
@ -67,7 +67,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:if ([ :len [ /file/find where type="package" name~("^" . $PackagePath) ] ] = 0) do={
|
:if ([ :len [ /file/find recursive where path=$PackagePath type="package" ] ] = 0) do={
|
||||||
$LogPrint info $ScriptName ("No packages available, downloading default set.");
|
$LogPrint info $ScriptName ("No packages available, downloading default set.");
|
||||||
:foreach Arch in={ "arm"; "mipsbe" } do={
|
:foreach Arch in={ "arm"; "mipsbe" } do={
|
||||||
:foreach Package in={ "routeros"; "wireless" } do={
|
:foreach Package in={ "routeros"; "wireless" } do={
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# Michael Gisbers <michael@gisbers.de>
|
# Michael Gisbers <michael@gisbers.de>
|
||||||
# https://rsc.eworm.de/COPYING.md
|
# https://rsc.eworm.de/COPYING.md
|
||||||
#
|
#
|
||||||
# requires RouterOS, version=7.15
|
# requires RouterOS, version=7.18
|
||||||
#
|
#
|
||||||
# download and cleanup packages for CAP installation from CAPsMAN
|
# download and cleanup packages for CAP installation from CAPsMAN
|
||||||
# https://rsc.eworm.de/doc/capsman-download-packages.md
|
# https://rsc.eworm.de/doc/capsman-download-packages.md
|
||||||
|
@ -56,8 +56,8 @@
|
||||||
"). Please place your packages!");
|
"). Please place your packages!");
|
||||||
}
|
}
|
||||||
|
|
||||||
:foreach Package in=[ /file/find where type="package" \
|
:foreach Package in=[ /file/find recursive where path=$PackagePath \
|
||||||
package-version!=$InstalledVersion name~("^" . $PackagePath) ] do={
|
type="package" package-version!=$InstalledVersion ] do={
|
||||||
:local File [ /file/get $Package ];
|
:local File [ /file/get $Package ];
|
||||||
:if ($File->"package-architecture" = "mips") do={
|
:if ($File->"package-architecture" = "mips") do={
|
||||||
:set ($File->"package-architecture") "mipsbe";
|
:set ($File->"package-architecture") "mipsbe";
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:if ([ :len [ /file/find where type="package" name~("^" . $PackagePath) ] ] = 0) do={
|
:if ([ :len [ /file/find recursive where path=$PackagePath type="package" ] ] = 0) do={
|
||||||
$LogPrint info $ScriptName ("No packages available, downloading default set.");
|
$LogPrint info $ScriptName ("No packages available, downloading default set.");
|
||||||
# NOT /interface/wifi/ #
|
# NOT /interface/wifi/ #
|
||||||
:foreach Arch in={ "arm"; "mipsbe" } do={
|
:foreach Arch in={ "arm"; "mipsbe" } do={
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# Michael Gisbers <michael@gisbers.de>
|
# Michael Gisbers <michael@gisbers.de>
|
||||||
# https://rsc.eworm.de/COPYING.md
|
# https://rsc.eworm.de/COPYING.md
|
||||||
#
|
#
|
||||||
# requires RouterOS, version=7.15
|
# requires RouterOS, version=7.18
|
||||||
#
|
#
|
||||||
# download and cleanup packages for CAP installation from CAPsMAN
|
# download and cleanup packages for CAP installation from CAPsMAN
|
||||||
# https://rsc.eworm.de/doc/capsman-download-packages.md
|
# https://rsc.eworm.de/doc/capsman-download-packages.md
|
||||||
|
@ -54,8 +54,8 @@
|
||||||
"). Please place your packages!");
|
"). Please place your packages!");
|
||||||
}
|
}
|
||||||
|
|
||||||
:foreach Package in=[ /file/find where type="package" \
|
:foreach Package in=[ /file/find recursive where path=$PackagePath \
|
||||||
package-version!=$InstalledVersion name~("^" . $PackagePath) ] do={
|
type="package" package-version!=$InstalledVersion ] do={
|
||||||
:local File [ /file/get $Package ];
|
:local File [ /file/get $Package ];
|
||||||
:if ($File->"package-architecture" = "mips") do={
|
:if ($File->"package-architecture" = "mips") do={
|
||||||
:set ($File->"package-architecture") "mipsbe";
|
:set ($File->"package-architecture") "mipsbe";
|
||||||
|
@ -67,7 +67,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:if ([ :len [ /file/find where type="package" name~("^" . $PackagePath) ] ] = 0) do={
|
:if ([ :len [ /file/find recursive where path=$PackagePath type="package" ] ] = 0) do={
|
||||||
$LogPrint info $ScriptName ("No packages available, downloading default set.");
|
$LogPrint info $ScriptName ("No packages available, downloading default set.");
|
||||||
:foreach Arch in={ "arm"; "arm64" } do={
|
:foreach Arch in={ "arm"; "arm64" } do={
|
||||||
:local Packages { "arm"={ "routeros"; "wifi-qcom"; "wifi-qcom-ac" };
|
:local Packages { "arm"={ "routeros"; "wifi-qcom"; "wifi-qcom-ac" };
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
:set ($CheckHealthPlugins->[ :jobname ]) do={
|
:set ($CheckHealthPlugins->[ :jobname ]) do={
|
||||||
:local FuncName [ :tostr $0 ];
|
:local FuncName [ :tostr $0 ];
|
||||||
:local ScriptName [ :tostr $1 ];
|
|
||||||
|
|
||||||
:global CheckHealthLast;
|
:global CheckHealthLast;
|
||||||
:global Identity;
|
:global Identity;
|
||||||
|
@ -33,13 +32,13 @@
|
||||||
:if ([ :typeof ($CheckHealthLast->$Name) ] != "nothing") do={
|
:if ([ :typeof ($CheckHealthLast->$Name) ] != "nothing") do={
|
||||||
:if ($CheckHealthLast->$Name = "ok" && \
|
:if ($CheckHealthLast->$Name = "ok" && \
|
||||||
$Value != "ok") do={
|
$Value != "ok") do={
|
||||||
$SendNotification2 ({ origin=$ScriptName; \
|
$SendNotification2 ({ origin=$FuncName; \
|
||||||
subject=([ $SymbolForNotification "cross-mark" ] . "Health warning: " . $Name); \
|
subject=([ $SymbolForNotification "cross-mark" ] . "Health warning: " . $Name); \
|
||||||
message=("The device '" . $Name . "' on " . $Identity . " failed!") });
|
message=("The device '" . $Name . "' on " . $Identity . " failed!") });
|
||||||
}
|
}
|
||||||
:if ($CheckHealthLast->$Name != "ok" && \
|
:if ($CheckHealthLast->$Name != "ok" && \
|
||||||
$Value = "ok") do={
|
$Value = "ok") do={
|
||||||
$SendNotification2 ({ origin=$ScriptName; \
|
$SendNotification2 ({ origin=$FuncName; \
|
||||||
subject=([ $SymbolForNotification "white-heavy-check-mark" ] . "Health recovery: " . $Name); \
|
subject=([ $SymbolForNotification "white-heavy-check-mark" ] . "Health recovery: " . $Name); \
|
||||||
message=("The device '" . $Name . "' on " . $Identity . " recovered!") });
|
message=("The device '" . $Name . "' on " . $Identity . " recovered!") });
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
:set ($CheckHealthPlugins->[ :jobname ]) do={
|
:set ($CheckHealthPlugins->[ :jobname ]) do={
|
||||||
:local FuncName [ :tostr $0 ];
|
:local FuncName [ :tostr $0 ];
|
||||||
:local ScriptName [ :tostr $1 ];
|
|
||||||
|
|
||||||
:global CheckHealthLast;
|
:global CheckHealthLast;
|
||||||
:global CheckHealthTemperature;
|
:global CheckHealthTemperature;
|
||||||
|
@ -55,7 +54,7 @@
|
||||||
}
|
}
|
||||||
:if ($Value > $CheckHealthTemperature->$Name && \
|
:if ($Value > $CheckHealthTemperature->$Name && \
|
||||||
$CheckHealthTemperatureNotified->$Name != true) do={
|
$CheckHealthTemperatureNotified->$Name != true) do={
|
||||||
$SendNotification2 ({ origin=$ScriptName; \
|
$SendNotification2 ({ origin=$FuncName; \
|
||||||
subject=([ $SymbolForNotification "fire" ] . "Health warning: " . $Name); \
|
subject=([ $SymbolForNotification "fire" ] . "Health warning: " . $Name); \
|
||||||
message=("The " . $Name . " on " . $Identity . " is above threshold: " . \
|
message=("The " . $Name . " on " . $Identity . " is above threshold: " . \
|
||||||
$Value . "\C2\B0" . "C") });
|
$Value . "\C2\B0" . "C") });
|
||||||
|
@ -63,7 +62,7 @@
|
||||||
}
|
}
|
||||||
:if ($Value <= ($CheckHealthTemperature->$Name - $CheckHealthTemperatureDeviation) && \
|
:if ($Value <= ($CheckHealthTemperature->$Name - $CheckHealthTemperatureDeviation) && \
|
||||||
$CheckHealthTemperatureNotified->$Name = true) do={
|
$CheckHealthTemperatureNotified->$Name = true) do={
|
||||||
$SendNotification2 ({ origin=$ScriptName; \
|
$SendNotification2 ({ origin=$FuncName; \
|
||||||
subject=([ $SymbolForNotification "white-heavy-check-mark" ] . "Health recovery: " . $Name); \
|
subject=([ $SymbolForNotification "white-heavy-check-mark" ] . "Health recovery: " . $Name); \
|
||||||
message=("The " . $Name . " on " . $Identity . " dropped below threshold: " . \
|
message=("The " . $Name . " on " . $Identity . " dropped below threshold: " . \
|
||||||
$Value . "\C2\B0" . "C") });
|
$Value . "\C2\B0" . "C") });
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
:set ($CheckHealthPlugins->[ :jobname ]) do={
|
:set ($CheckHealthPlugins->[ :jobname ]) do={
|
||||||
:local FuncName [ :tostr $0 ];
|
:local FuncName [ :tostr $0 ];
|
||||||
:local ScriptName [ :tostr $1 ];
|
|
||||||
|
|
||||||
:global CheckHealthLast;
|
:global CheckHealthLast;
|
||||||
:global CheckHealthVoltageLow;
|
:global CheckHealthVoltageLow;
|
||||||
|
@ -40,7 +39,7 @@
|
||||||
|
|
||||||
:if ($NumLast * (100 + $CheckHealthVoltagePercent) < $NumCurr * 100 || \
|
:if ($NumLast * (100 + $CheckHealthVoltagePercent) < $NumCurr * 100 || \
|
||||||
$NumLast * 100 > $NumCurr * (100 + $CheckHealthVoltagePercent)) do={
|
$NumLast * 100 > $NumCurr * (100 + $CheckHealthVoltagePercent)) do={
|
||||||
$SendNotification2 ({ origin=$ScriptName; \
|
$SendNotification2 ({ origin=$FuncName; \
|
||||||
subject=([ $SymbolForNotification ("high-voltage-sign,chart-" . [ $IfThenElse ($NumLast < \
|
subject=([ $SymbolForNotification ("high-voltage-sign,chart-" . [ $IfThenElse ($NumLast < \
|
||||||
$NumCurr) "in" "de" ] . "creasing") ] . "Health warning: " . $Name); \
|
$NumCurr) "in" "de" ] . "creasing") ] . "Health warning: " . $Name); \
|
||||||
message=("The " . $Name . " on " . $Identity . " jumped more than " . $CheckHealthVoltagePercent . "%.\n\n" . \
|
message=("The " . $Name . " on " . $Identity . " jumped more than " . $CheckHealthVoltagePercent . "%.\n\n" . \
|
||||||
|
@ -48,12 +47,12 @@
|
||||||
[ $FormatLine "new value" ($Value . " V") 12 ]) });
|
[ $FormatLine "new value" ($Value . " V") 12 ]) });
|
||||||
} else={
|
} else={
|
||||||
:if ($NumCurr <= $CheckHealthVoltageLow && $NumLast > $CheckHealthVoltageLow) do={
|
:if ($NumCurr <= $CheckHealthVoltageLow && $NumLast > $CheckHealthVoltageLow) do={
|
||||||
$SendNotification2 ({ origin=$ScriptName; \
|
$SendNotification2 ({ origin=$FuncName; \
|
||||||
subject=([ $SymbolForNotification "high-voltage-sign,chart-decreasing" ] . "Health warning: Low " . $Name); \
|
subject=([ $SymbolForNotification "high-voltage-sign,chart-decreasing" ] . "Health warning: Low " . $Name); \
|
||||||
message=("The " . $Name . " on " . $Identity . " dropped to " . $Value . " V below hard limit.") });
|
message=("The " . $Name . " on " . $Identity . " dropped to " . $Value . " V below hard limit.") });
|
||||||
}
|
}
|
||||||
:if ($NumCurr > $CheckHealthVoltageLow && $NumLast <= $CheckHealthVoltageLow) do={
|
:if ($NumCurr > $CheckHealthVoltageLow && $NumLast <= $CheckHealthVoltageLow) do={
|
||||||
$SendNotification2 ({ origin=$ScriptName; \
|
$SendNotification2 ({ origin=$FuncName; \
|
||||||
subject=([ $SymbolForNotification "high-voltage-sign,chart-increasing" ] . "Health recovery: Low " . $Name); \
|
subject=([ $SymbolForNotification "high-voltage-sign,chart-increasing" ] . "Health recovery: Low " . $Name); \
|
||||||
message=("The " . $Name . " on " . $Identity . " recovered to " . $Value . " V above hard limit.") });
|
message=("The " . $Name . " on " . $Identity . " recovered to " . $Value . " V above hard limit.") });
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,16 +92,16 @@
|
||||||
:onerror Err {
|
:onerror Err {
|
||||||
/system/script/run $Plugin;
|
/system/script/run $Plugin;
|
||||||
} do={
|
} do={
|
||||||
$LogPrint error $ScriptName ("Plugin '" . $PluginVal->"name" . "' failed to run: " . $Err);
|
$LogPrint error $ScriptName ("Plugin '" . $ScriptVal->"name" . "' failed to run: " . $Err);
|
||||||
}
|
}
|
||||||
} else={
|
} else={
|
||||||
$LogPrint error $ScriptName ("Plugin '" . $PluginVal->"name" . "' failed syntax validation, skipping.");
|
$LogPrint error $ScriptName ("Plugin '" . $ScriptVal->"name" . "' failed syntax validation, skipping.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:foreach PluginName,Discard in=$CheckHealthPlugins do={
|
:foreach PluginName,Discard in=$CheckHealthPlugins do={
|
||||||
($CheckHealthPlugins->$PluginName) \
|
($CheckHealthPlugins->$PluginName) \
|
||||||
("\$CheckHealthPlugins->\"" . $PluginName . "\"") $ScriptName;
|
("\$CheckHealthPlugins->\"" . $PluginName . "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
:set CheckHealthPlugins;
|
:set CheckHealthPlugins;
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
:global EscapeForRegEx;
|
:global EscapeForRegEx;
|
||||||
:global FetchUserAgentStr;
|
:global FetchUserAgentStr;
|
||||||
:global LogPrint;
|
:global LogPrint;
|
||||||
:global RebootForUpdate;
|
|
||||||
:global ScriptFromTerminal;
|
:global ScriptFromTerminal;
|
||||||
:global ScriptLock;
|
:global ScriptLock;
|
||||||
:global SendNotification2;
|
:global SendNotification2;
|
||||||
|
@ -63,15 +62,10 @@
|
||||||
$WaitFullyConnected;
|
$WaitFullyConnected;
|
||||||
|
|
||||||
:if ([ :len [ /system/scheduler/find where name="_RebootForUpdate" ] ] > 0) do={
|
:if ([ :len [ /system/scheduler/find where name="_RebootForUpdate" ] ] > 0) do={
|
||||||
:if ([ :typeof $RebootForUpdate ] = "nothing") do={
|
|
||||||
$LogPrint info $ScriptName ("Found a stale scheduler for reboot, removing.");
|
|
||||||
/system/scheduler/remove "_RebootForUpdate";
|
|
||||||
} else={
|
|
||||||
$LogPrint info $ScriptName ("A reboot for update is already scheduled.");
|
$LogPrint info $ScriptName ("A reboot for update is already scheduled.");
|
||||||
:set ExitOK true;
|
:set ExitOK true;
|
||||||
:error false;
|
:error false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$LogPrint debug $ScriptName ("Checking for updates...");
|
$LogPrint debug $ScriptName ("Checking for updates...");
|
||||||
/system/package/update/check-for-updates without-paging as-value;
|
/system/package/update/check-for-updates without-paging as-value;
|
||||||
|
|
|
@ -4,7 +4,7 @@ Download packages for CAP upgrade from CAPsMAN
|
||||||
[](https://github.com/eworm-de/routeros-scripts/stargazers)
|
[](https://github.com/eworm-de/routeros-scripts/stargazers)
|
||||||
[](https://github.com/eworm-de/routeros-scripts/network)
|
[](https://github.com/eworm-de/routeros-scripts/network)
|
||||||
[](https://github.com/eworm-de/routeros-scripts/watchers)
|
[](https://github.com/eworm-de/routeros-scripts/watchers)
|
||||||
[](https://mikrotik.com/download/changelogs/)
|
[](https://mikrotik.com/download/changelogs/)
|
||||||
[](https://t.me/routeros_scripts)
|
[](https://t.me/routeros_scripts)
|
||||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J)
|
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J)
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,6 @@ certificate is checked.
|
||||||
> ⚠️ **Warning**: The script does not limit the size of a list, but keep in
|
> ⚠️ **Warning**: The script does not limit the size of a list, but keep in
|
||||||
> mind that huge lists can exhaust your device's resources (RAM and CPU),
|
> mind that huge lists can exhaust your device's resources (RAM and CPU),
|
||||||
> and may take a long time to process.
|
> and may take a long time to process.
|
||||||
> Even crashes for the complete scripting (and CLI) subsystem are possible.
|
|
||||||
> This should be logged accordingly with warnings when global functions are
|
|
||||||
> reloaded from scheduler.
|
|
||||||
|
|
||||||
Requirements and installation
|
Requirements and installation
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
|
@ -46,8 +46,8 @@ Configuration
|
||||||
|
|
||||||
The configuration goes to `global-config-overlay`, this is the only parameter:
|
The configuration goes to `global-config-overlay`, this is the only parameter:
|
||||||
|
|
||||||
* `PackagesUpdateDeferReboot`: defer the reboot for night (between 3 AM and
|
* `PackagesUpdateDeferReboot`: defer the reboot for night (between 3 AM
|
||||||
5 AM), use a numerical value in days suffixed with a `d` to defer further
|
and 5 AM)
|
||||||
|
|
||||||
By modifying the scheduler's `start-time` you can force the reboot at
|
By modifying the scheduler's `start-time` you can force the reboot at
|
||||||
different time.
|
different time.
|
||||||
|
|
|
@ -48,12 +48,6 @@
|
||||||
}
|
}
|
||||||
$WaitFullyConnected;
|
$WaitFullyConnected;
|
||||||
|
|
||||||
:if ([ :len [ /log/find where topics=({"script"; "warning"}) \
|
|
||||||
message=("\$LogPrintOnce: The message is already in log, scripting subsystem may have crashed before!") ] ] > 0) do={
|
|
||||||
$LogPrintOnce warning $ScriptName ("Scripting subsystem may have crashed, possibly caused by us. Delaying!");
|
|
||||||
:delay 5m;
|
|
||||||
}
|
|
||||||
|
|
||||||
:local ListComment ("managed by " . $ScriptName);
|
:local ListComment ("managed by " . $ScriptName);
|
||||||
|
|
||||||
:foreach FwListName,FwList in=$FwAddrLists do={
|
:foreach FwListName,FwList in=$FwAddrLists do={
|
||||||
|
|
|
@ -133,11 +133,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:if ([ :len [ /certificate/find where common-name=$CommonName ] ] > 1) do={
|
|
||||||
$LogPrint info $0 ("There are " . $CertCount . " Certificates with CommonName '" . $CommonName . "'. Should be ok.");
|
|
||||||
:return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
:local CertVal [ /certificate/get [ find where common-name=$CommonName ] ];
|
:local CertVal [ /certificate/get [ find where common-name=$CommonName ] ];
|
||||||
:while (($CertVal->"akid") != "" && ($CertVal->"akid") != ($CertVal->"skid")) do={
|
:while (($CertVal->"akid") != "" && ($CertVal->"akid") != ($CertVal->"skid")) do={
|
||||||
:if ([ :len [ /certificate/find where skid=($CertVal->"akid") ] ] = 0) do={
|
:if ([ :len [ /certificate/find where skid=($CertVal->"akid") ] ] = 0) do={
|
||||||
|
@ -564,12 +559,6 @@
|
||||||
:set FileGet do={
|
:set FileGet do={
|
||||||
:local FileName [ :tostr $1 ];
|
:local FileName [ :tostr $1 ];
|
||||||
|
|
||||||
:global WaitForFile;
|
|
||||||
|
|
||||||
:if ([ $WaitForFile $FileName 0s ] = false) do={
|
|
||||||
:return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
:local FileVal false;
|
:local FileVal false;
|
||||||
:do {
|
:do {
|
||||||
:set FileVal [ /file/get $FileName ];
|
:set FileVal [ /file/get $FileName ];
|
||||||
|
@ -1613,9 +1602,7 @@
|
||||||
|
|
||||||
:global LogPrintOnce;
|
:global LogPrintOnce;
|
||||||
|
|
||||||
:global SymbolsExtra;
|
:local Symbols {
|
||||||
|
|
||||||
:local Symbols ({
|
|
||||||
"abacus"="\F0\9F\A7\AE";
|
"abacus"="\F0\9F\A7\AE";
|
||||||
"alarm-clock"="\E2\8F\B0";
|
"alarm-clock"="\E2\8F\B0";
|
||||||
"arrow-down"="\E2\AC\87";
|
"arrow-down"="\E2\AC\87";
|
||||||
|
@ -1650,7 +1637,7 @@
|
||||||
"star"="\E2\AD\90";
|
"star"="\E2\AD\90";
|
||||||
"warning-sign"="\E2\9A\A0";
|
"warning-sign"="\E2\9A\A0";
|
||||||
"white-heavy-check-mark"="\E2\9C\85"
|
"white-heavy-check-mark"="\E2\9C\85"
|
||||||
}, $SymbolsExtra);
|
}
|
||||||
|
|
||||||
:if ([ :len ($Symbols->$Name) ] = 0) do={
|
:if ([ :len ($Symbols->$Name) ] = 0) do={
|
||||||
$LogPrintOnce warning $0 ("No symbol available for name '" . $Name . "'!");
|
$LogPrintOnce warning $0 ("No symbol available for name '" . $Name . "'!");
|
||||||
|
@ -1784,26 +1771,14 @@
|
||||||
:global MAX;
|
:global MAX;
|
||||||
|
|
||||||
:set FileName [ $CleanFilePath $FileName ];
|
:set FileName [ $CleanFilePath $FileName ];
|
||||||
:local Delay ([ $MAX [ $EitherOr $WaitTime 2s ] 100ms ] / 9);
|
:local Delay ([ $MAX [ $EitherOr $WaitTime 2s ] 100ms ] / 10);
|
||||||
|
|
||||||
:do {
|
:do {
|
||||||
:retry {
|
:retry {
|
||||||
:if ([ :len [ /file/find where name=$FileName ] ] = 0) do={
|
|
||||||
:error false;
|
|
||||||
}
|
|
||||||
} delay=$Delay max=10;
|
|
||||||
} on-error={
|
|
||||||
:return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
:while ([ :len [ /file/find where name=$FileName ] ] > 0) do={
|
|
||||||
:do {
|
|
||||||
/file/get $FileName;
|
/file/get $FileName;
|
||||||
:return true;
|
:return true;
|
||||||
|
} delay=$Delay max=10;
|
||||||
} on-error={ }
|
} on-error={ }
|
||||||
:delay $Delay;
|
|
||||||
:set Delay ($Delay * 3 / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
:return false;
|
:return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,13 +119,11 @@
|
||||||
|
|
||||||
:local Data false;
|
:local Data false;
|
||||||
:onerror Err {
|
:onerror Err {
|
||||||
:retry {
|
|
||||||
:set Data ([ /tool/fetch check-certificate=yes-without-crl output=user \
|
:set Data ([ /tool/fetch check-certificate=yes-without-crl output=user \
|
||||||
http-header-field=({ "accept: application/dns-message" }) \
|
http-header-field=({ "accept: application/dns-message" }) \
|
||||||
url=(($DohServer->"doh-url") . "?dns=" . [ :convert to=base64 ([ :rndstr length=2 ] . \
|
url=(($DohServer->"doh-url") . "?dns=" . [ :convert to=base64 ([ :rndstr length=2 ] . \
|
||||||
"\01\00" . "\00\01" . "\00\00" . "\00\00" . "\00\00" . "\09doh-check\05eworm\02de\00" . \
|
"\01\00" . "\00\01" . "\00\00" . "\00\00" . "\00\00" . "\09doh-check\05eworm\02de\00" . \
|
||||||
"\00\10" . "\00\01") ]) as-value ]->"data");
|
"\00\10" . "\00\01") ]) as-value ]->"data");
|
||||||
} delay=1s max=3;
|
|
||||||
} do={
|
} do={
|
||||||
$LogPrint warning $ScriptName ("Request to DoH server " . ($DohServer->"doh-url") . \
|
$LogPrint warning $ScriptName ("Request to DoH server " . ($DohServer->"doh-url") . \
|
||||||
" failed: " . $Err);
|
" failed: " . $Err);
|
||||||
|
|
|
@ -62,14 +62,14 @@
|
||||||
|
|
||||||
:local FwAddrList ($ScriptName . "-" . [ $GetRandom20CharAlNum ]);
|
:local FwAddrList ($ScriptName . "-" . [ $GetRandom20CharAlNum ]);
|
||||||
:if ([ :typeof [ :toip $Expected ] ] = "ip") do={
|
:if ([ :typeof [ :toip $Expected ] ] = "ip") do={
|
||||||
/ip/firewall/address-list/add address=$Name list=$FwAddrList dynamic=yes timeout=30s;
|
/ip/firewall/address-list/add address=$Name list=$FwAddrList dynamic=yes timeout=10s;
|
||||||
:delay 20ms;
|
:delay 20ms;
|
||||||
:if ([ :len [ /ip/firewall/address-list/find where list=$FwAddrList address=$Expected ] ] > 0) do={
|
:if ([ :len [ /ip/firewall/address-list/find where list=$FwAddrList address=$Expected ] ] > 0) do={
|
||||||
:return true;
|
:return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
:if ([ :typeof [ :toip6 $Expected ] ] = "ip6") do={
|
:if ([ :typeof [ :toip6 $Expected ] ] = "ip6") do={
|
||||||
/ipv6/firewall/address-list/add address=$Name list=$FwAddrList dynamic=yes timeout=30s;
|
/ipv6/firewall/address-list/add address=$Name list=$FwAddrList dynamic=yes timeout=10s;
|
||||||
:delay 20ms;
|
:delay 20ms;
|
||||||
:if ([ :len [ /ipv6/firewall/address-list/find where list=$FwAddrList address=$Expected ] ] > 0) do={
|
:if ([ :len [ /ipv6/firewall/address-list/find where list=$FwAddrList address=$Expected ] ] > 0) do={
|
||||||
:return true;
|
:return true;
|
||||||
|
@ -127,7 +127,7 @@
|
||||||
$LogPrint [ $IfThenElse ($HostInfo->"no-resolve-fail" != true) warning debug ] \
|
$LogPrint [ $IfThenElse ($HostInfo->"no-resolve-fail" != true) warning debug ] \
|
||||||
$ScriptName ("Resolving name '" . $HostInfo->"resolve" . [ $IfThenElse \
|
$ScriptName ("Resolving name '" . $HostInfo->"resolve" . [ $IfThenElse \
|
||||||
($HostInfo->"resolve" != $HostInfo->"name") ("' for " . $Type . " '" . \
|
($HostInfo->"resolve" != $HostInfo->"name") ("' for " . $Type . " '" . \
|
||||||
$HostInfo->"name") "" ] . "' failed third time: " . $Err);
|
$HostInfo->"name") "" ] . "' failed: " . $Err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,25 +31,19 @@
|
||||||
:local Schedule do={
|
:local Schedule do={
|
||||||
:local ScriptName [ :tostr $1 ];
|
:local ScriptName [ :tostr $1 ];
|
||||||
|
|
||||||
:global PackagesUpdateDeferReboot;
|
|
||||||
|
|
||||||
:global GetRandomNumber;
|
:global GetRandomNumber;
|
||||||
:global IfThenElse;
|
|
||||||
:global LogPrint;
|
:global LogPrint;
|
||||||
|
|
||||||
:global RebootForUpdate do={
|
:global RebootForUpdate do={
|
||||||
/system/reboot;
|
/system/reboot;
|
||||||
}
|
}
|
||||||
|
|
||||||
:local Interval [ $IfThenElse ([ :totime $PackagesUpdateDeferReboot ] >= 1d) \
|
|
||||||
$PackagesUpdateDeferReboot 1d ];
|
|
||||||
:local StartTime [ :tostr [ :totime (10800 + [ $GetRandomNumber 7200 ]) ] ];
|
:local StartTime [ :tostr [ :totime (10800 + [ $GetRandomNumber 7200 ]) ] ];
|
||||||
/system/scheduler/add name="_RebootForUpdate" start-time=$StartTime interval=$Interval \
|
/system/scheduler/add name="_RebootForUpdate" start-time=$StartTime interval=1d \
|
||||||
on-event=("/system/scheduler/remove \"_RebootForUpdate\"; " . \
|
on-event=("/system/scheduler/remove \"_RebootForUpdate\"; " . \
|
||||||
":global RebootForUpdate; \$RebootForUpdate;");
|
":global RebootForUpdate; \$RebootForUpdate;");
|
||||||
$LogPrint info $ScriptName ("Scheduled reboot for update at " . $StartTime . \
|
$LogPrint info $ScriptName ("Scheduled reboot for update at " . $StartTime . \
|
||||||
" local time (" . [ /system/clock/get time-zone-name ] . ")" . \
|
" local time (" . [ /system/clock/get time-zone-name ] . ").");
|
||||||
[ $IfThenElse ($Interval > 1d) (" deferred by " . $Interval) ] . ".");
|
|
||||||
:return true;
|
:return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +153,7 @@
|
||||||
:error true;
|
:error true;
|
||||||
}
|
}
|
||||||
} else={
|
} else={
|
||||||
:if ($PackagesUpdateDeferReboot = true || [ :totime $PackagesUpdateDeferReboot ] >= 1d) do={
|
:if ($PackagesUpdateDeferReboot = true) do={
|
||||||
$Schedule $ScriptName;
|
$Schedule $ScriptName;
|
||||||
:set ExitOK true;
|
:set ExitOK true;
|
||||||
:error true;
|
:error true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue