- Script pro automatický upgrade RouterOS v6 a Firmware s upozorněním na e-mail
- Stačí vložit do Schelduleru nebo do Scripts
- Je potřeba nastavit /tools/email, aby chodily notifikace o provedení na e-mail
:local FWcurrent [/system routerboard get current-firmware]
:local FWupgrade [/system routerboard get upgrade-firmware]
:local d [/system clock get date]
:local t [/system clock get time]
:local mk [/system identity get name]
:local emailTo "muj@email.cz"
### Pro upgrade ROS
/system package update
check-for-updates once
:delay 3s
:local novaVerze [get latest-version]
:if ( [get status] = "New version is available") \
do={ \
:log info "Nova verze ROS $novaVerze je dostupna, stahuji..."
:tool e-mail send to=$emailTo subject="$mk upgrade RoS" body="V $t $d, na verzi RouterOS: $novaVerze"
install
:log info "Restartuji..."
} \
else={ \
:log info "Aktualni ROS, kontroluji aktualnost Firmware..."
### Pro upgrade Firmware
:if ($FWcurrent = $FWupgrade) \
do={ \
:log info "Aktualni Firmware" \
} \
else={ \
:log info "Neaktualni Firmware"
:delay 2
:log info "Nastavuji upgrade"
/system routerboard upgrade
:tool e-mail send to=$emailTo subject="$mk upgrade Firmware" body="V $t $d, na verzi firmware: $FWupgrade"
:delay 10
:log info "Restartuji..."
/system reboot
}
}
Kompletní kod. Stačí vše vložit do terminálu a nastaví se.
/system script
add dont-require-permissions=no name=upgradeROS owner=spravce policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=":lo\
cal FWcurrent [/system routerboard get current-firmware]\r\
\n:local FWupgrade [/system routerboard get upgrade-firmware]\r\
\n:local d [/system clock get date]\r\
\n:local t [/system clock get time]\r\
\n:local mk [/system identity get name]\r\
\n:local emailTo \"muj@email.cz\" \r\
\n### Pro upgrade ROS\r\
\n/system package update\r\
\ncheck-for-updates once\r\
\n:delay 3s\r\
\n:local novaVerze [get latest-version]\r\
\n:if ( [get status] = \"New version is available\") \\\r\
\ndo={ \\\r\
\n:log info \"Nova verze ROS \$novaVerze je dostupna, stahuji...\" \r\
\n:tool e-mail send to=\$emailTo subject=\"\$mk upgrade RoS\" body=\"V \$t \
\$d, na verzi RouterOS: \$novaVerze\"\r\
\ninstall \r\
\n:log info \"Restartuji...\" \r\
\n} \\\r\
\nelse={ \\\r\
\n:log info \"Aktualni ROS, kontroluji aktualnost Firmware...\" \r\
\n### Pro upgrade Firmware\r\
\n:if (\$FWcurrent = \$FWupgrade) \\\r\
\n do={ \\\r\
\n :log info \"Aktualni Firmware\" \\\r\
\n } \\\r\
\n else={ \\\r\
\n :log info \"Neaktualni Firmware\" \r\
\n :delay 2 \r\
\n :log info \"Nastavuji upgrade\" \r\
\n /system routerboard upgrade\r\
\n :tool e-mail send to=\$emailTo subject=\"\$mk upgrade Firmware\" bod\
y=\"V \$t \$d, na verzi firmware: \$FWupgrade\"\r\
\n :delay 10 \r\
\n :log info \"Restartuji...\"\r\
\n /system reboot\r\
\n } \r\
\n} \r\
\n"
/system scheduler
add interval=2d name="upgrade ROS new" on-event=\
"/system script run \"upgradeROS\"" policy=\
reboot,read,write,policy,test,password,sensitive \
start-date=2022-01-01 start-time=04:44:44
Aktualizováno: 10.11.2023