gbudny93.RouterOS_Useful_Sc.../RouterOS_Auto_Software_Upgrade.rsc

47 lines
1.7 KiB
Text
Raw Normal View History

2019-08-14 11:09:33 +02:00
# RouterOS Fucntion
2020-02-08 20:03:02 +01:00
# Copyright (c) Grzegorz Budny
# Version 1.0
# Last update: 2/8/2020
2019-08-14 11:09:33 +02:00
# Checks if latest package is available. Downloads it, installs and sends email notification
:global PackageAutoDownload do={
2019-09-30 14:13:05 +02:00
/system package update check-for-updates;
2019-08-14 11:09:33 +02:00
:local packageCurrent [/system package update get installed-version];
:local packageLatest [/system package update get latest-version];
:local packageName [/system package get value-name=name number=0];
:local systemName [/system identity get value-name=name];
:if ($packageCurrent != $packageLatest) do={
:log info ("...:::New package available - ".$packageLatest." Downloading:::...");
/system package update download;
:log info ("...:::".$packageName." ".$packageLatest." downloaded:::...");
:delay 2;
/tool e-mail send server=$smtpServer port=$smtpPort from=($systemName.$domain) \
to=$recipient subject=("Update available on ".$systemName) \
body=($systemName." downloaded latest package ".$packageLatest.". \
\nInstalling package. System is rebooting.");
/system reboot;
}\
else={
:log info ("...:::No updates found. ".$packageCurrent." is the latest version...:::");
2019-10-14 20:49:16 +02:00
/tool e-mail send server=$smtpServer port=$smtpPort from=($systemName.$domain) \
to=$recipient subject=("No update available on ".$systemName) \
body=($systemName." has installed the latest package ".$packageLatest);
2019-08-14 11:09:33 +02:00
}
}
$PackageAutoDownload userName=userName password=password packagePath=path \
smtpServer=ipAddress smtpPort=poty domain=@example.com \
recipient=recipient@example.com;