From c500243c97ec888a72d41b77fa3f7c8f14341ac8 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 29 Jan 2020 21:38:17 +0100 Subject: 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][,...] --- global-functions | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'global-functions') 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; +} -- cgit v1.2.3-70-g09d2