mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
backup-upload: build file info in a function
This commit is contained in:
parent
4d70b7fea4
commit
5f457e5c37
1 changed files with 18 additions and 14 deletions
|
@ -25,8 +25,6 @@
|
||||||
|
|
||||||
:global CharacterReplace;
|
:global CharacterReplace;
|
||||||
:global DeviceInfo;
|
:global DeviceInfo;
|
||||||
:global FormatLine;
|
|
||||||
:global HumanReadableNum;
|
|
||||||
:global IfThenElse;
|
:global IfThenElse;
|
||||||
:global LogPrintExit2;
|
:global LogPrintExit2;
|
||||||
:global MkDir;
|
:global MkDir;
|
||||||
|
@ -122,24 +120,30 @@ $WaitFullyConnected;
|
||||||
/file/remove ($FilePath . ".conf.txt");
|
/file/remove ($FilePath . ".conf.txt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:local FileInfo do={
|
||||||
|
:local Name $1;
|
||||||
|
:local File $2;
|
||||||
|
|
||||||
|
:global FormatLine;
|
||||||
|
:global HumanReadableNum;
|
||||||
|
:global IfThenElse;
|
||||||
|
|
||||||
|
:return \
|
||||||
|
[ $IfThenElse ([ :typeof $File ] = "array") \
|
||||||
|
($Name . ":\n" . [ $FormatLine " name" ($File->"name") ] . "\n" . \
|
||||||
|
[ $FormatLine " size" ([ $HumanReadableNum ($File->"size") 1024 ] . "iB") ]) \
|
||||||
|
[ $FormatLine $Name $File ] ];
|
||||||
|
}
|
||||||
|
|
||||||
$SendNotification2 ({ origin=$0; \
|
$SendNotification2 ({ origin=$0; \
|
||||||
subject=[ $IfThenElse ($Failed > 0) \
|
subject=[ $IfThenElse ($Failed > 0) \
|
||||||
([ $SymbolForNotification "floppy-disk,warning-sign" ] . "Backup & Config upload with failure") \
|
([ $SymbolForNotification "floppy-disk,warning-sign" ] . "Backup & Config upload with failure") \
|
||||||
([ $SymbolForNotification "floppy-disk,up-arrow" ] . "Backup & Config upload") ]; \
|
([ $SymbolForNotification "floppy-disk,up-arrow" ] . "Backup & Config upload") ]; \
|
||||||
message=("Backup and config export upload for " . $Identity . ".\n\n" . \
|
message=("Backup and config export upload for " . $Identity . ".\n\n" . \
|
||||||
[ $DeviceInfo ] . "\n\n" . \
|
[ $DeviceInfo ] . "\n\n" . \
|
||||||
[ $IfThenElse ([ :typeof $BackupFile ] = "array") \
|
[ $FileInfo "Backup file" $BackupFile ] . "\n" . \
|
||||||
("Backup file:\n" . [ $FormatLine " name" ($BackupFile->"name") ] . "\n" . \
|
[ $FileInfo "Export file" $ExportFile ] . "\n" . \
|
||||||
[ $FormatLine " size" [ $HumanReadableNum ($BackupFile->"size") 1024 ] ]) \
|
[ $FileInfo "Config file" $ConfigFile ]); silent=true });
|
||||||
[ $FormatLine "Backup file" $BackupFile ] ] . "\n" . \
|
|
||||||
[ $IfThenElse ([ :typeof $ExportFile ] = "array") \
|
|
||||||
("Export file:\n" . [ $FormatLine " name" ($ExportFile->"name") ] . "\n" . \
|
|
||||||
[ $FormatLine " size" [ $HumanReadableNum ($ExportFile->"size") 1024 ] ]) \
|
|
||||||
[ $FormatLine "Export file" $ExportFile ] ] . "\n" . \
|
|
||||||
[ $IfThenElse ([ :typeof $ConfigFile ] = "array") \
|
|
||||||
("Config file:\n" . [ $FormatLine " name" ($ConfigFile->"name") ] . "\n" . \
|
|
||||||
[ $FormatLine " size" [ $HumanReadableNum ($ConfigFile->"size") 1024 ] ]) \
|
|
||||||
[ $FormatLine "Config file" $ConfigFile ] ]); silent=true });
|
|
||||||
|
|
||||||
:if ($Failed = 1) do={
|
:if ($Failed = 1) do={
|
||||||
:error "An error occured!";
|
:error "An error occured!";
|
||||||
|
|
Loading…
Reference in a new issue