aboutsummaryrefslogtreecommitdiffstats
path: root/backup-partition.rsc
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2024-05-22 11:58:26 +0200
committerGravatar Christian Hesse <mail@eworm.de>2024-05-23 12:11:41 +0200
commit6cbe13a135fe39c097b6a7078506d99eedde2e06 (patch)
treee528810bab1afc874cc60320287241d7d57d13b9 /backup-partition.rsc
parent51331ea2acd5f5563ed3641090bbb7f2104d3e96 (diff)
backup-partition: move code to a local function
Diffstat (limited to 'backup-partition.rsc')
-rw-r--r--backup-partition.rsc22
1 files changed, 17 insertions, 5 deletions
diff --git a/backup-partition.rsc b/backup-partition.rsc
index 9eeb1ae..a72dd0b 100644
--- a/backup-partition.rsc
+++ b/backup-partition.rsc
@@ -21,6 +21,22 @@
:global ScriptFromTerminal;
:global ScriptLock;
+ :local CopyTo do={
+ :local ScriptName [ :tostr $1 ];
+ :local FallbackTo [ :tostr $2 ];
+
+ :global LogPrint;
+
+ :do {
+ /partitions/copy-to $FallbackTo;
+ $LogPrint info $ScriptName ("Copied RouterOS to partition '" . $FallbackTo . "'.");
+ :return true;
+ } on-error={
+ $LogPrint error $ScriptName ("Failed copying RouterOS to partition '" . $FallbackTo . "'!");
+ :return false;
+ }
+ }
+
:if ([ $ScriptLock $ScriptName ] = false) do={
:set PackagesUpdateBackupFailure true;
:error false;
@@ -46,11 +62,7 @@
:if ([ $ScriptFromTerminal $ScriptName ] = true) do={
:put ("The partitions have different RouterOS versions. Copy over to '" . $FallbackTo . "'? [y/N]");
:if (([ /terminal/inkey timeout=60 ] % 32) = 25) do={
- :do {
- /partitions/copy-to $FallbackTo;
- $LogPrint info $ScriptName ("Copied RouterOS to partition '" . $FallbackTo . "'.");
- } on-error={
- $LogPrint error $ScriptName ("Failed copying RouterOS to partition '" . $FallbackTo . "'!");
+ :if ([ $CopyTo $ScriptName $FallbackTo ] = false) do={
:set PackagesUpdateBackupFailure true;
:error false;
}