Last active
October 17, 2018 09:31
-
-
Save herbetom/d14d4852e57460b5887678ef27e8dbaf to your computer and use it in GitHub Desktop.
routerOSautoUpdate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mikrotik RouterOS autoUpdate Script to perform an automatic | |
# should be run periodically. Therefore you can use the Scheduler | |
# E-Mail must be configured prior. Some explanation can be found | |
# here https://wiki.mikrotik.com/wiki/Manual:Tools/email#Properties | |
:local mailto "sysinfo@example.org" | |
/log info message="Update Checking for new Updates." | |
/system package update | |
check-for-updates once | |
:delay 5s; | |
:if ( [get status] = "New version is available") do={ | |
/log info message="Update Downloading new RouterOS on router $[/system identity get name] from $[/system package update get installed-version] to $[/system package update get latest-version] (channel:$[/system package update get channel])" | |
/tool e-mail send to="$mailto" subject=([/system identity get name] ." auto Update") body="Installing new RouterOS on router $[/system identity get name] from $[/system package update get installed-version] to $[/system package update get latest-version] (channel:$[/system package update get channel])" | |
# The following Backupscript is used | |
# https://gist.github.com/herbetom/af0310f9e4385f1e838247541a9390a6 | |
/system script run backupToMail | |
/log info message="Update Upgrading RouterOS on router now" | |
install | |
} else={ | |
/log info message="Update Their wasn't found a new version." | |
/log info message="Update Checking firmware..."; | |
/system routerboard | |
:if ([get current-firmware] != [get upgrade-firmware]) do={ | |
/tool e-mail send to="$mailto" subject=([/system identity get name] ." auto Update - Firmware") body="Installing new available Firmware on the device.\n\nUpgrading the Firmware of $[/system identity get name] from $[/system routerboard get current-firmware] to $[/system routerboard get upgrade-firmware]. The device will reboot in a few seconds." | |
/log info "Update Updating firmware. The device will reboot after the upgrade"; | |
upgrade; | |
:delay 5s | |
/system reboot | |
} else={ | |
/log info "Update No firmware update available" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment