{"id":1801,"date":"2021-03-08T18:21:11","date_gmt":"2021-03-08T17:21:11","guid":{"rendered":"http:\/\/blog.chury721.cz\/?p=1801"},"modified":"2023-11-10T11:07:48","modified_gmt":"2023-11-10T10:07:48","slug":"auto-upgrade-mikrotik-routeros-firmware","status":"publish","type":"post","link":"https:\/\/blog.chury721.cz\/?p=1801","title":{"rendered":"Auto upgrade MikroTik RouterOS v6 + v7 &#038; Firmware"},"content":{"rendered":"<ul>\n<li>Script pro automatick\u00fd upgrade RouterOS v6 a Firmware s upozorn\u011bn\u00edm na e-mail<\/li>\n<li>Sta\u010d\u00ed vlo\u017eit do Schelduleru nebo do Scripts<\/li>\n<li>Je pot\u0159eba nastavit \/tools\/email, aby chodily notifikace o proveden\u00ed na e-mail<\/li>\n<\/ul>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n:local 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 &quot;muj@email.cz&quot; \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] = &quot;New version is available&quot;) \\\r\ndo={ \\\r\n:log info &quot;Nova verze ROS $novaVerze je dostupna, stahuji...&quot; \r\n:tool e-mail send to=$emailTo subject=&quot;$mk upgrade RoS&quot; body=&quot;V $t $d, na verzi RouterOS: $novaVerze&quot;\r\ninstall \r\n:log info &quot;Restartuji...&quot; \r\n} \\\r\nelse={ \\\r\n:log info &quot;Aktualni ROS, kontroluji aktualnost Firmware...&quot; \r\n### Pro upgrade Firmware\r\n:if ($FWcurrent = $FWupgrade) \\\r\n       do={ \\\r\n      :log info &quot;Aktualni Firmware&quot; \\\r\n       } \\\r\n      else={ \\\r\n      :log info &quot;Neaktualni Firmware&quot; \r\n      :delay 2 \r\n      :log info &quot;Nastavuji upgrade&quot; \r\n      \/system routerboard upgrade\r\n      :tool e-mail send to=$emailTo subject=&quot;$mk upgrade Firmware&quot; body=&quot;V $t $d, na verzi firmware: $FWupgrade&quot;\r\n      :delay 10 \r\n      :log info &quot;Restartuji...&quot;\r\n      \/system reboot\r\n      } \r\n} \r\n\r\n\r\n<\/pre>\n<h3>Kompletn\u00ed kod. Sta\u010d\u00ed v\u0161e vlo\u017eit do termin\u00e1lu a nastav\u00ed se.<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\/system script\r\nadd dont-require-permissions=no name=upgradeROS owner=spravce policy=\\\r\n    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=&quot;:lo\\\r\n    cal FWcurrent [\/system routerboard get current-firmware]\\r\\\r\n    \\n:local FWupgrade [\/system routerboard get upgrade-firmware]\\r\\\r\n    \\n:local d [\/system clock get date]\\r\\\r\n    \\n:local t [\/system clock get time]\\r\\\r\n    \\n:local mk [\/system identity get name]\\r\\\r\n    \\n:local emailTo \\&quot;muj@email.cz\\&quot; \\r\\\r\n    \\n### Pro upgrade ROS\\r\\\r\n    \\n\/system package update\\r\\\r\n    \\ncheck-for-updates once\\r\\\r\n    \\n:delay 3s\\r\\\r\n    \\n:local novaVerze [get latest-version]\\r\\\r\n    \\n:if ( [get status] = \\&quot;New version is available\\&quot;) \\\\\\r\\\r\n    \\ndo={ \\\\\\r\\\r\n    \\n:log info \\&quot;Nova verze ROS \\$novaVerze je dostupna, stahuji...\\&quot; \\r\\\r\n    \\n:tool e-mail send to=\\$emailTo subject=\\&quot;\\$mk upgrade RoS\\&quot; body=\\&quot;V \\$t \\\r\n    \\$d, na verzi RouterOS: \\$novaVerze\\&quot;\\r\\\r\n    \\ninstall \\r\\\r\n    \\n:log info \\&quot;Restartuji...\\&quot; \\r\\\r\n    \\n} \\\\\\r\\\r\n    \\nelse={ \\\\\\r\\\r\n    \\n:log info \\&quot;Aktualni ROS, kontroluji aktualnost Firmware...\\&quot; \\r\\\r\n    \\n### Pro upgrade Firmware\\r\\\r\n    \\n:if (\\$FWcurrent = \\$FWupgrade) \\\\\\r\\\r\n    \\n       do={ \\\\\\r\\\r\n    \\n      :log info \\&quot;Aktualni Firmware\\&quot; \\\\\\r\\\r\n    \\n       } \\\\\\r\\\r\n    \\n      else={ \\\\\\r\\\r\n    \\n      :log info \\&quot;Neaktualni Firmware\\&quot; \\r\\\r\n    \\n      :delay 2 \\r\\\r\n    \\n      :log info \\&quot;Nastavuji upgrade\\&quot; \\r\\\r\n    \\n      \/system routerboard upgrade\\r\\\r\n    \\n      :tool e-mail send to=\\$emailTo subject=\\&quot;\\$mk upgrade Firmware\\&quot; bod\\\r\n    y=\\&quot;V \\$t \\$d, na verzi firmware: \\$FWupgrade\\&quot;\\r\\\r\n    \\n      :delay 10 \\r\\\r\n    \\n      :log info \\&quot;Restartuji...\\&quot;\\r\\\r\n    \\n      \/system reboot\\r\\\r\n    \\n      } \\r\\\r\n    \\n} \\r\\\r\n    \\n&quot;\r\n\/system scheduler\r\nadd interval=2d name=&quot;upgrade ROS new&quot; on-event=\\\r\n    &quot;\/system script run \\&quot;upgradeROS\\&quot;&quot; policy=\\\r\n    reboot,read,write,policy,test,password,sensitive \\\r\n    start-date=2022-01-01 start-time=04:44:44\r\n<\/pre>\n<p><small>Aktualizov\u00e1no: 10.11.2023<\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Script pro automatick\u00fd upgrade RouterOS v6 a Firmware s upozorn\u011bn\u00edm na e-mail Sta\u010d\u00ed vlo\u017eit do Schelduleru nebo do Scripts Je pot\u0159eba nastavit \/tools\/email, aby chodily notifikace o proveden\u00ed na e-mail Kompletn\u00ed kod. Sta\u010d\u00ed v\u0161e vlo\u017eit do termin\u00e1lu a nastav\u00ed se. Aktualizov\u00e1no: 10.11.2023<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[],"class_list":["post-1801","post","type-post","status-publish","format-standard","hentry","category-mikrotik"],"_links":{"self":[{"href":"https:\/\/blog.chury721.cz\/index.php?rest_route=\/wp\/v2\/posts\/1801"}],"collection":[{"href":"https:\/\/blog.chury721.cz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.chury721.cz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.chury721.cz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.chury721.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1801"}],"version-history":[{"count":15,"href":"https:\/\/blog.chury721.cz\/index.php?rest_route=\/wp\/v2\/posts\/1801\/revisions"}],"predecessor-version":[{"id":1805,"href":"https:\/\/blog.chury721.cz\/index.php?rest_route=\/wp\/v2\/posts\/1801\/revisions\/1805"}],"wp:attachment":[{"href":"https:\/\/blog.chury721.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1801"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.chury721.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1801"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.chury721.cz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1801"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}