script-updates: make sure new script starts with magic

This commit is contained in:
Christian Hesse 2018-09-27 00:23:24 +02:00
parent be673737d3
commit 5303c034b9

View file

@ -50,12 +50,16 @@
} }
:if ([ :len $sourcenew ] > 0) do={ :if ([ :len $sourcenew ] > 0) do={
:local sourcecurrent [ / system script get $script source ]; :if ([ :pick $sourcenew 0 5 ] = "#!rsc") do={
:if ($sourcenew = $sourcecurrent) do={ :local sourcecurrent [ / system script get $script source ];
:log debug ("Script " . $scriptname . " did not change"); :if ($sourcenew != $sourcecurrent) do={
:log info ("Updating script: " . $scriptname);
/ system script set owner=$scriptname source=$sourcenew $script;
} else={
:log debug ("Script " . $scriptname . " did not change");
}
} else={ } else={
:log info ("Updating script: " . $scriptname); :log warning ("Looks like new script " . $scriptname . " is not valid. Ignoring!");
/ system script set owner=$scriptname source=$sourcenew $script;
} }
} else={ } else={
:log debug ("No update for script " . $scriptname); :log debug ("No update for script " . $scriptname);