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
1 changed files with 9 additions and 5 deletions

View File

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