diff options
author | Christian Hesse <mail@eworm.de> | 2018-09-10 09:44:36 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2018-09-10 09:44:36 +0200 |
commit | 8f4986af0bb0ecea13594b9ea2bbcfbaa6c8a7e7 (patch) | |
tree | 43018abe95d562d11fc56944908096d382342f33 /script-updates | |
parent | a1951cc86a206abd0b6d46d579a8247af42904f8 (diff) | |
parent | 2de26a6617911d88fe0e4c10b861df670f0f17e6 (diff) |
Merge branch 'fetch-as-value'
Diffstat (limited to 'script-updates')
-rw-r--r-- | script-updates | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/script-updates b/script-updates index ccfdd58..c872cd2 100644 --- a/script-updates +++ b/script-updates @@ -13,35 +13,38 @@ :local ignore 0; :local scriptname [ / system script get $script name ]; :local scriptfile [ / file find where name=("script-updates/" . $scriptname) ]; + :local sourcenew; + :if ([ :len $scriptfile ] > 0) do={ + :set sourcenew [ / file get $scriptfile content ]; + / file remove $scriptfile; + } - :if ([ :len $scriptfile ] = 0 && $"script-updates-fetch" = true) do={ + :if ([ :len $sourcenew ] = 0 && $"script-updates-fetch" = true) do={ :foreach "ignore-loop" in=$"script-updates-ignore" do={ :if ($"ignore-loop" = $scriptname) do={ :set ignore 1; } } :if ($ignore = 0) do={ :log debug ("Fetching script from url: " . $scriptname); - :do { - / tool fetch check-certificate=yes-without-crl \ - dst-path=("script-updates/" . $scriptname) \ - ($"script-updates-baseurl" . $scriptname . $"script-updates-urlsuffix"); - :set scriptfile [ / file find where name=("script-updates/" . $scriptname) ]; - } on-error={ + :local result [ / tool fetch check-certificate=yes-without-crl \ + ($"script-updates-baseurl" . $scriptname . $"script-updates-urlsuffix") \ + output=user as-value ]; + :if ($result->"status" = "finished") do={ + :set sourcenew ($result->"data"); + } else={ :log debug ("Failed fetching " . $scriptname); } } } - :if ([ :len $scriptfile ] > 0) do={ - :local filecontent [ / file get $scriptfile content ]; - :local scriptsource [ / system script get $script source ]; - :if ($filecontent = $scriptsource) do={ + :if ([ :len $sourcenew ] > 0) do={ + :local sourcecurrent [ / system script get $script source ]; + :if ($sourcenew = $sourcecurrent) do={ :log debug ("Script " . $scriptname . " did not change"); } else={ :log info ("Updating script: " . $scriptname); - / system script set owner=$scriptname source=$filecontent $script; + / system script set owner=$scriptname source=$sourcenew $script; } - / file remove $scriptfile; } else={ :log debug ("No update for script " . $scriptname); } |