diff options
author | Christian Hesse <mail@eworm.de> | 2020-01-29 21:38:17 +0100 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2020-01-29 21:44:41 +0100 |
commit | c500243c97ec888a72d41b77fa3f7c8f14341ac8 (patch) | |
tree | 21683a503ee17858582a7ef01b1df7a05020d8fe /global-functions | |
parent | 352818ea48438383216a783ef9448570b343c29b (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][,...]
Diffstat (limited to 'global-functions')
-rw-r--r-- | global-functions | 14 |
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; +} |