aboutsummaryrefslogtreecommitdiffstats
path: root/packages-update
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2019-02-19 16:41:27 +0100
committerGravatar Christian Hesse <mail@eworm.de>2019-02-19 16:47:41 +0100
commite991c82016ce0ef54c8c11feccc4348b80240e11 (patch)
tree3708c9ce057267d25fe0dd8aaa816bf97a29964f /packages-update
parentc92ff8f9a6b84ead59b21b026f5c2ef11408f43c (diff)
add script 'packages-update'
Diffstat (limited to 'packages-update')
-rw-r--r--packages-update29
1 files changed, 29 insertions, 0 deletions
diff --git a/packages-update b/packages-update
new file mode 100644
index 0000000..683e9f8
--- /dev/null
+++ b/packages-update
@@ -0,0 +1,29 @@
+#!rsc
+# RouterOS script: packages-update
+# Copyright (c) 2019 Christian Hesse <mail@eworm.de>
+#
+# download packages and reboot for installation
+
+:global DownloadPackage;
+
+:local InstalledVersion [ / system package update get installed-version ];
+:local LatestVersion [ / system package update get latest-version ];
+
+:if ($InstalledVersion = $LatestVersion) do={
+ :error ("Version " . $LatestVersion . " is already installed.");
+}
+
+:foreach Package in=[ / system package find where !bundle ] do={
+ :local PkgName [ / system package get $Package name ];
+ if ([ $DownloadPackage $PkgName $LatestVersion ] = false) do={
+ :error ("Download for package " . $PkgName . " failed.");
+ }
+}
+
+:if ([ / system script print count-only where name="email-backup" ] > 0) do={
+ / system script run email-backup;
+}
+
+:log info ("Rebooting for update.");
+:delay 1s;
+/ system reboot;