Commit 94581741 authored by Christian Hesse's avatar Christian Hesse

global-functions: introduce and use $DeviceInfo

parent 23b38fa1
......@@ -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");
......
......@@ -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";
......
......@@ -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;
}
......@@ -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;
}
......@@ -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";
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment