aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--check-routeros-update12
-rw-r--r--cloud-backup13
-rw-r--r--email-backup17
-rw-r--r--global-functions29
-rw-r--r--upload-backup17
5 files changed, 41 insertions, 47 deletions
diff --git a/check-routeros-update b/check-routeros-update
index 78fd9c6..dccfcbe 100644
--- a/check-routeros-update
+++ b/check-routeros-update
@@ -8,6 +8,7 @@
:global SafeUpdateUrl;
:global SentRouterosUpdateNotification;
+:global DeviceInfo;
:global SendNotification;
:local DoUpdate do={
@@ -36,9 +37,6 @@
}
:if ($Update->"installed-version" != $Update->"latest-version") do={
- :local BoardName [ / system resource get board-name ];
- :local RouterBoard [ / system routerboard get ];
-
:if ([ :len $SafeUpdateUrl ] > 0) do={
:local Result;
:do {
@@ -74,13 +72,7 @@
$SendNotification ("RouterOS update") \
("There is a RouterOS update available.\n\n" . \
- "Board name: " . $BoardName . "\n" . \
- "Model: " . $RouterBoard->"model" . "\n" . \
- "Serial number: " . $RouterBoard->"serial-number" . "\n" . \
- "Hostname: " . $Identity . "\n" . \
- "Channel: " . $Update->"channel" . "\n" . \
- "Installed: " . $Update->"installed-version" . "\n" . \
- "Available: " . $Update->"latest-version" . "\n\n" .\
+ [ $DeviceInfo ] . "\n\n" . \
"https://mikrotik.com/download/changelogs/" . $Update->"channel" . "-release-tree") \
"" "true";
:set SentRouterosUpdateNotification ($Update->"latest-version");
diff --git a/cloud-backup b/cloud-backup
index 5a36f29..d948f99 100644
--- a/cloud-backup
+++ b/cloud-backup
@@ -7,13 +7,9 @@
:global Identity;
:global BackupPassword;
+:global DeviceInfo;
:global SendNotification;
-# get some system information
-:local BoardName [ / system resource get board-name ];
-:local RouterBoard [ / system routerboard get ];
-:local Update [ / system package update get ];
-
:do {
# we are not interested in output, but print without count-only is
# required to fetch information from cloud
@@ -29,12 +25,7 @@
$SendNotification "Cloud backup" \
("Uploaded backup for " . $Identity . " to cloud.\n\n" . \
- "Board name: " . $BoardName . "\n" . \
- "Model: " . $RouterBoard->"model" . "\n" . \
- "Serial number: " . $RouterBoard->"serial-number" . "\n" . \
- "Hostname: " . $Identity . "\n" . \
- "Channel: " . $Update->"channel" . "\n" . \
- "RouterOS: " . $Update->"installed-version" . "\n\n" . \
+ [ $DeviceInfo ] . "\n\n" . \
"Name: " . $Cloud->"name" . "\n" . \
"Size: " . $Cloud->"size" . "\n" . \
"Download key: " . $Cloud->"secret-download-key") "" "true";
diff --git a/email-backup b/email-backup
index f1a2f9a..d5acb44 100644
--- a/email-backup
+++ b/email-backup
@@ -13,6 +13,7 @@
:global BackupPassword;
:global CharacterReplace;
+:global DeviceInfo;
:if ($BackupSendBinary != true && \
$BackupSendExport != true) do={
@@ -26,11 +27,6 @@
:local ConfigFile "none";
:local Attach [ :toarray "" ];
-# get some system information
-:local BoardName [ / system resource get board-name ];
-:local RouterBoard [ / system routerboard get ];
-:local Update [ / system package update get ];
-
# binary backup
:if ($BackupSendBinary = true) do={
/ system backup save encryption=aes-sha256 name=$FileName password=$BackupPassword;
@@ -49,13 +45,8 @@
/ tool e-mail send to=$EmailBackupTo cc=$EmailBackupCc \
subject=("[" . $Identity . "] Backup & Config") \
body=("Backup and config export for " . $Identity . ".\n\n" . \
- "Board name: " . $BoardName . "\n" . \
- "Model: " . $RouterBoard->"model" . "\n" . \
- "Serial number: " . $RouterBoard->"serial-number" . "\n" . \
- "Hostname: " . $Identity . "\n" . \
- "Channel: " . $Update->"channel" . "\n" . \
- "RouterOS: " . $Update->"installed-version" . "\n\n" . \
- "Backup file: " . $BackupFile . "\n" . \
- "Config file: " . $ConfigFile) \
+ [ $DeviceInfo ] . "\n\n" . \
+ "Backup file: " . $BackupFile . "\n" . \
+ "Config file: " . $ConfigFile) \
file=$Attach;
}
diff --git a/global-functions b/global-functions
index 1b73b0a..87cda40 100644
--- a/global-functions
+++ b/global-functions
@@ -294,3 +294,32 @@
:delay ([ $GetRandom $1 ] . "s");
}
+
+# get readable device info
+:global DeviceInfo do={
+ :global Identity;
+
+ :local BoardName [ / system resource get board-name ];
+ :local RouterBoard [ / system routerboard get ];
+ :local Update [ / system package update get ];
+
+ :local Info ( \
+ "Hostname: " . $Identity . "\n" . \
+ "Board name: " . $BoardName);
+ :if ($RouterBoard->"routerboard" = true) do={
+ :set Info ($Info . "\n" . \
+ "Model: " . $RouterBoard->"model" . "\n" . \
+ "Serial number: " . $RouterBoard->"serial-number");
+ }
+ :set Info ($Info . "\n" . \
+ "RouterOS:\n" . \
+ " Channel: " . $Update->"channel" . "\n" . \
+ " Installed: " . $Update->"installed-version");
+ :if ([ :typeof ($Update->"latest-version") ] != "nothing" && \
+ $Update->"installed-version" != $Update->"latest-version") do={
+ :set Info ($Info . "\n" . \
+ " Available: " . $Update->"latest-version");
+ }
+
+ :return $Info;
+}
diff --git a/upload-backup b/upload-backup
index b780299..a75f14a 100644
--- a/upload-backup
+++ b/upload-backup
@@ -14,6 +14,7 @@
:global BackupPassword;
:global CharacterReplace;
+:global DeviceInfo;
:global SendNotification;
:if ($BackupSendBinary != true && \
@@ -27,11 +28,6 @@
:local BackupFile "none";
:local ConfigFile "none";
-# get some system information
-:local BoardName [ / system resource get board-name ];
-:local RouterBoard [ / system routerboard get ];
-:local Update [ / system package update get ];
-
# binary backup
:if ($BackupSendBinary = true) do={
/ system backup save encryption=aes-sha256 name=$FileName password=$BackupPassword;
@@ -62,12 +58,7 @@
$SendNotification "Backup & Config Upload" \
("Backup and config export for " . $Identity . ".\n\n" . \
- "Board name: " . $BoardName . "\n" . \
- "Model: " . $RouterBoard->"model" . "\n" . \
- "Serial number: " . $RouterBoard->"serial-number" . "\n" . \
- "Hostname: " . $Identity . "\n" . \
- "Channel: " . $Update->"channel" . "\n" . \
- "RouterOS: " . $Update->"installed-version" . "\n\n" . \
- "Backup uploaded: " . $BackupFile . "\n" . \
- "Config uploaded: " . $ConfigFile) "" "true";
+ [ $DeviceInfo ] . "\n\n" . \
+ "Backup file: " . $BackupFile . "\n" . \
+ "Config file: " . $ConfigFile) "" "true";
}