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][,...]
This commit is contained in:
Christian Hesse 2020-01-29 21:38:17 +01:00
parent 352818ea48
commit c500243c97

View file

@ -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;
}