送朋友一个AP,长时间不更新固件没问题,不过还是想给定时更新下。于是结合大佬的脚本,自己写了一个:
# 仅适用于RouterOS 7.x, 固件更新脚本参考https://www.roszj.com/1797.html
# 每三天03:33:00重启下AP,每两周检查固件更新和boot更新
# ~~~ 复制粘贴到txt或者Sublime中,另存为system.rsc,然后导入winbox中,再im file=system.rsc即可 ~~~
# aug/15/2022 17:33:21 by RouterOS 7.4.1
#
# model = RBD52G-5HacD2HnD
/system clock
set time-zone-autodetect=no time-zone-name=Asia/Shanghai
/system identity
set name=RBD52Gap220815
/system ntp client
set enabled=yes
/system ntp client servers
add address=pool.ntp.org
add address=cn.ntp.org.cn
add address=ntp.aliyun.com
/system routerboard settings
set force-backup-booter=yes
/system scheduler
add interval=3d name=RbootSch on-event="/system script run \"RbootScr\"" \
policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
start-date=jan/01/1970 start-time=03:33:00
add interval=2w name=Package_Updt_Sch on-event=\
"/system script run \"Package_Updt\"" policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
start-date=jan/01/1970 start-time=04:10:00
add interval=2w name=RouterBT_Upgd_Sch on-event=\
"/system script run \"RouterBT_Upgd\"" policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
start-date=jan/01/1970 start-time=05:00:00
/system script
add dont-require-permissions=no name=RouterBT_Upgd owner=admin policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=":\
log info \"::Checking RouterBOOT upgrade...\"\r\
\n:local crouterbt;\r\
\n:local urouterbt\r\
\n:set crouterbt [system routerboard get current-firmware];\r\
\n:set urouterbt [system routerboard get upgrade-firmware];\r\
\n:log info ( \"::current-firmware is \" . \$crouterbt . \", upgrade-firm\
ware is \" . \$urouterbt);\r\
\n\r\
\n:if ( \"\$crouterbt\" != \"\$urouterbt\" ) \\\r\
\ndo={\r\
\n:log info \"::Will update MT RouterBOOT\";\r\
\n/system routerboard upgrade;\r\
\n:delay 10s;\r\
\n/system reboot\r\
\n} else={\r\
\n:log info \"::No MT RouterBOOT upgrade\";\r\
\n};"
add dont-require-permissions=no name=Package_Updt owner=admin policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=":\
log info \"::Checking MT_Package firmware...\";\r\
\n/system package update check-for-updates\r\
\n:delay 10s;\r\
\n:if ([/system package update get status]=\"New version is available\") d\
o={\r\
\n :log info \"::Downloading MT_Package firmware...\";\r\
\n /system package update download\r\
\n :delay 20s;\r\
\n :if ([/system package update get status]=\"Downloaded, please reboot r\
outer to upgrade it\") do={\r\
\n :log info \"::MT_Package Download finish, Rebooting\";\r\
\n :delay 10s;\r\
\n /system reboot\r\
\n } else={\r\
\n :log info \":::Downloading firmware......\";\r\
\n /system package update download\r\
\n :delay 20s;\r\
\n :if ( [/system package update get status]=\"Downloaded, please reboo\
t router to upgrade it\" ) do={\r\
\n :log info \"MT_Package Download finish, Rebooting\";\r\
\n /system reboot } else={\r\
\n :log info \"::Download MT_Package fail...\";\r\
\n }\r\
\n }\r\
\n} else={\r\
\n :if ([/system package update get status]=\"System is already up to dat\
e\") do={\r\
\n :log info \"::No MT_Package update. System is already up to date.\"\r\
\n }\r\
\n}\r\
\n"
add dont-require-permissions=no name=RbootScr owner=gd policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=\
":log info \"::Reboot Sch\";\r\
\n:delay 2;\r\
\n/system reboot\r\
\n/\r\
\n"
# ~~~ 复制粘贴到txt或者Sublime中,另存为system.rsc,然后导入winbox中,再im file=system.rsc即可 ~~~ |