From e1f134ead584c7b2e9ed406f5520d7f1a23294aa Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 5 Jul 2018 15:29:26 +0200 Subject: add scripts --- check-routeros-update | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 check-routeros-update (limited to 'check-routeros-update') diff --git a/check-routeros-update b/check-routeros-update new file mode 100644 index 0000000..8cd93fe --- /dev/null +++ b/check-routeros-update @@ -0,0 +1,42 @@ +# RouterOS script: check-routeros-update +# Copyright (c) 2013-2018 Christian Hesse +# +# check for RouterOS update, send notification e-mails + +:global "identity"; +:global "email-general-to"; +:global "email-general-cc"; +:global "sent-routeros-update-notification"; + +:if ([ :len [ / system package find where name="wireless" ] ] > 0) do={ + :if ([ / interface wireless cap get enabled ] = true) do={ + :error "System is managed by CAPsMAN, not checking."; + } +} + +:if ($"sent-routeros-update-notification" = true) do={ + :error "Already sent the RouterOS update notification."; +} + +# get some information +:local model [ / system routerboard get model ]; +:local serialnumber [ / system routerboard get serial-number ]; + +# check for RouterOS +/ system package update check-for-updates without-paging; +:local installedversion [ / system package update get installed-version ]; +:local latestversion [ / system package update get latest-version ]; +:local channel [ / system package update get channel ]; + +:if ($installedversion != $latestversion) do={ + / tool e-mail send to=$"email-general-to" cc=$"email-general-cc" \ + subject=("[" . $identity . "] RouterOS update notification") \ + body=("There is a RouterOS update available\n\n" . \ + "Routerboard: " . $model . "\n" . \ + "Serial number: " . $serialnumber . "\n" . \ + "Hostname: " . $identity . "\n" . \ + "Channel: " . $channel . "\n" . \ + "Installed: " . $installedversion . "\n" . \ + "Available: " . $latestversion); + :set "sent-routeros-update-notification" true; +} -- cgit v1.2.3-54-g00ecf