mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2025-12-06 01:49:28 +00:00
check-routeros-update: split off check-perpetual-license...
... and also add documentation, screenshot, etc.
This commit is contained in:
parent
16c9ce437e
commit
3c30276e23
8 changed files with 152 additions and 39 deletions
78
check-perpetual-license.rsc
Normal file
78
check-perpetual-license.rsc
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
#!rsc by RouterOS
|
||||
# RouterOS script: check-perpetual-license
|
||||
# Copyright (c) 2025 Christian Hesse <mail@eworm.de>
|
||||
# https://rsc.eworm.de/COPYING.md
|
||||
#
|
||||
# requires RouterOS, version=7.15
|
||||
#
|
||||
# check perpetual license on CHR
|
||||
# https://rsc.eworm.de/doc/check-perpetual-license.md
|
||||
|
||||
:global GlobalFunctionsReady;
|
||||
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
|
||||
|
||||
:local ExitOK false;
|
||||
:do {
|
||||
:local ScriptName [ :jobname ];
|
||||
|
||||
:global Identity;
|
||||
:global SentCertificateNotification;
|
||||
|
||||
:global LogPrint;
|
||||
:global ScriptLock;
|
||||
:global SendNotification2;
|
||||
:global SymbolForNotification;
|
||||
:global WaitFullyConnected;
|
||||
|
||||
:if ([ $ScriptLock $ScriptName ] = false) do={
|
||||
:set ExitOK true;
|
||||
:error false;
|
||||
}
|
||||
|
||||
$WaitFullyConnected;
|
||||
|
||||
:local License [ /system/license/get ];
|
||||
:if ([ :typeof ($License->"deadline-at") ] != "str") do={
|
||||
$LogPrint info $ScriptName ("This device does not have a perpetual license.");
|
||||
:set ExitOK true;
|
||||
:error true;
|
||||
}
|
||||
|
||||
:if ([ :len ($License->"next-renewal-at") ] = 0 && ($License->"limited-upgrades") = true) do={
|
||||
$LogPrint warning $ScriptName ("Your license expired on " . ($License->"deadline-at") . "!");
|
||||
:if ($SentCertificateNotification != "expired") do={
|
||||
$SendNotification2 ({ origin=$ScriptName; \
|
||||
subject=([ $SymbolForNotification "warning-sign" ] . "License expired!"); \
|
||||
message=("Your license expired on " . ($License->"deadline-at") . \
|
||||
", can no longer update RouterOS on " . $Identity . "...") });
|
||||
:set SentCertificateNotification "expired";
|
||||
}
|
||||
:set ExitOK true;
|
||||
:error true;
|
||||
}
|
||||
|
||||
:if ([ :totime ($License->"deadline-at") ] - 3w < [ :timestamp ]) do={
|
||||
$LogPrint warning $ScriptName ("Your license will expire on " . ($License->"deadline-at") . "!");
|
||||
:if ($SentCertificateNotification != "warning") do={
|
||||
$SendNotification2 ({ origin=$ScriptName; \
|
||||
subject=([ $SymbolForNotification "warning-sign" ] . "License about to expire!"); \
|
||||
message=("Your license failed to renew and is about to expire on " . \
|
||||
($License->"deadline-at") . " on " . $Identity . "...") });
|
||||
:set SentCertificateNotification "warning";
|
||||
}
|
||||
:set ExitOK true;
|
||||
:error true;
|
||||
}
|
||||
|
||||
:if ([ :typeof $SentCertificateNotification ] = "str" && \
|
||||
[ :totime ($License->"deadline-at") ] - 4w > [ :timestamp ]) do={
|
||||
$LogPrint info $ScriptName ("Your license was successfully renewed.");
|
||||
$SendNotification2 ({ origin=$ScriptName; \
|
||||
subject=([ $SymbolForNotification "white-heavy-check-mark" ] . "License renewed"); \
|
||||
message=("Your license was successfully renewed on " . $Identity . \
|
||||
". It is now valid until " . ($License->"deadline-at") . ".") });
|
||||
:set SentCertificateNotification;
|
||||
}
|
||||
} on-error={
|
||||
:global ExitError; $ExitError $ExitOK [ :jobname ];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue