aboutsummaryrefslogtreecommitdiffstats
path: root/packages-update.rsc
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2023-09-13 01:01:34 +0200
committerGravatar Christian Hesse <mail@eworm.de>2023-09-13 01:14:27 +0200
commitc3f9ad1df7422fb2c508ea4960bd95b4a2ef25b2 (patch)
treeb76551814d6674dae86c9a3de9389cf78e3366a2 /packages-update.rsc
parent50429a0ad8ce02f26f40a69d027ea709480aeb36 (diff)
packages-update: implement backup script order
Diffstat (limited to 'packages-update.rsc')
-rw-r--r--packages-update.rsc18
1 files changed, 14 insertions, 4 deletions
diff --git a/packages-update.rsc b/packages-update.rsc
index 74b1822..ebcbaae 100644
--- a/packages-update.rsc
+++ b/packages-update.rsc
@@ -11,7 +11,9 @@
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
:global DownloadPackage;
+:global Grep;
:global LogPrintExit2;
+:global ParseKeyValueStore;
:global ScriptFromTerminal;
:global ScriptLock;
:global VersionToNum;
@@ -52,13 +54,21 @@ $ScriptLock $0;
}
}
-:foreach Script in=[ /system/script/find where source~"\n# provides: backup-script\n" ] do={
- :local ScriptName [ /system/script/get $Script name ];
+:local RunOrder ({});
+
+:foreach Script in=[ /system/script/find where source~("\n# provides: backup-script, ") ] do={
+ :local ScriptVal [ /system/script/get $Script ];
+ :local Store [ $ParseKeyValueStore [ $Grep ($ScriptVal->"source") ("\23 provides: backup-script, ") ] ];
+
+ :set ($RunOrder->($Store->"order" . "-" . $ScriptVal->"name")) ($ScriptVal->"name");
+}
+
+:foreach Order,Script in=$RunOrder do={
:do {
- $LogPrintExit2 info $0 ("Running backup script " . $ScriptName . " before update.") false;
+ $LogPrintExit2 info $0 ("Running backup script " . $Script . " (order " . $Order . ") before update.") false;
/system/script/run $Script;
} on-error={
- $LogPrintExit2 warning $0 ("Running backup script " . $ScriptName . " before update failed!") false;
+ $LogPrintExit2 warning $0 ("Running backup script " . $Script . " before update failed!") false;
:if ([ $ScriptFromTerminal $0 ] = true) do={
:put "Do you want to continue anyway? [y/N]";
:if (([ /terminal/inkey timeout=60 ] % 32) = 25) do={