aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2020-01-29 21:38:17 +0100
committerGravatar Christian Hesse <mail@eworm.de>2020-01-29 21:44:41 +0100
commitc500243c97ec888a72d41b77fa3f7c8f14341ac8 (patch)
tree21683a503ee17858582a7ef01b1df7a05020d8fe
parent352818ea48438383216a783ef9448570b343c29b (diff)
global-functions: add $ScriptInstallUpdate
Just call without parameters to update scripts: [admin@MikroTik] > $InstallAndUpdate Add comma separated list of scripts to install and update: [admin@MikroTik] > $InstallAndUpdate cloud-backup[,upload-backup][,...]
-rw-r--r--global-functions14
1 files changed, 14 insertions, 0 deletions
diff --git a/global-functions b/global-functions
index 5f80c0b..60f72a4 100644
--- a/global-functions
+++ b/global-functions
@@ -32,6 +32,7 @@
:global GetRandom;
:global RandomDelay;
:global DeviceInfo;
+:global ScriptInstallUpdate;
# url encoding
:set UrlEncode do={
@@ -412,3 +413,16 @@
:return $Info;
}
+
+# install new scripts, update existing scripts
+:set ScriptInstallUpdate do={
+ :local Scripts [ :toarray $1 ];
+
+ :foreach Script in=$Scripts do={
+ :if ([ / system script print count-only where name=$Script ] = 0) do={
+ :log info ("Adding new script: " . $Script);
+ / system script add name=$Script source="#!rsc";
+ }
+ }
+ / system script run script-updates;
+}