mirror of
https://github.com/pothi/mikrotik-scripts.git
synced 2025-07-01 18:24:31 +02:00
Better docs and logic
This commit is contained in:
parent
97345bd33b
commit
b8ab558f6f
1 changed files with 21 additions and 11 deletions
|
@ -1,22 +1,25 @@
|
||||||
# Alert upon new version
|
# Alert upon new version
|
||||||
|
|
||||||
# requirement/s: $adminEmailAddress
|
# requirement/s:
|
||||||
:local adminEmailAddress "admin@example.com"
|
:local adminEmailAddress "admin@example.com"
|
||||||
|
:local startDelay "100s"
|
||||||
:log info "Checking for new version of RouterOS..."
|
|
||||||
|
|
||||||
# if you run this script at "startup",
|
# if you run this script at "startup",
|
||||||
# the following indicates the time for the internet to go "up"
|
# the following indicates the time for the internet to go "up"
|
||||||
:delay 60s
|
# ToDo: Find it out dynamically
|
||||||
|
:delay $startDelay
|
||||||
|
|
||||||
|
:log info "Checking for new version of RouterOS..."
|
||||||
|
|
||||||
/system package update
|
/system package update
|
||||||
|
|
||||||
check-for-updates once
|
check-for-updates once
|
||||||
|
|
||||||
:local verionStatus
|
:local versionStatus
|
||||||
|
:local deviceIdentity [/system identity get name]
|
||||||
|
|
||||||
:do {
|
:do {
|
||||||
:delay 2s
|
:delay 3s
|
||||||
|
|
||||||
:set $versionStatus [get status]
|
:set $versionStatus [get status]
|
||||||
# alternative way to get the above info
|
# alternative way to get the above info
|
||||||
|
@ -27,13 +30,20 @@ check-for-updates once
|
||||||
# :put $versionStatus
|
# :put $versionStatus
|
||||||
# :put $adminEmailAddress
|
# :put $adminEmailAddress
|
||||||
|
|
||||||
|
:local installedVersion [get installed-version]
|
||||||
|
:local latestVersion [get latest-version]
|
||||||
|
|
||||||
:if ( $versionStatus = "New version is available" ) do={
|
:if ( $versionStatus = "New version is available" ) do={
|
||||||
# alternative method
|
# alternative method
|
||||||
# :if ( [get installed-version] != [get latest-version] ) do={
|
# :if ( installedVersion != $latestVersion ) do={
|
||||||
:log info "A new firmware is available for Router OS and an email is probably sent to $adminEmailAddress."
|
:log info "A new update is available for Router OS and an email is probably sent to $adminEmailAddress."
|
||||||
/tool e-mail send to="$adminEmailAddress" \
|
/tool e-mail send to="$adminEmailAddress" \
|
||||||
subject="[Mikrotik] Software Update is Available" \
|
subject="[Mikrotik $deviceIdentity] Software Update is Available" \
|
||||||
body="A new update is available for your MikroTik device"
|
body="A new update is available for your MikroTik device: \"$deviceIdentity\" ...
|
||||||
|
|
||||||
|
Installed Version: $installedVersion
|
||||||
|
Latest Version: $latestVersion
|
||||||
|
"
|
||||||
} else={
|
} else={
|
||||||
:log info "System is already up to date"
|
:log info "Router OS is already up to date."
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue