Validate checksum of Factorio mods
This commit is contained in:
parent
b74fc406d5
commit
5e3015d5e3
|
@ -8,6 +8,15 @@ for mod in $mods; do
|
||||||
mod_data=$(curl -s https://mods.factorio.com/api/mods/$mod)
|
mod_data=$(curl -s https://mods.factorio.com/api/mods/$mod)
|
||||||
download_url=$(<<<$mod_data jq -r ".releases[-1].download_url")
|
download_url=$(<<<$mod_data jq -r ".releases[-1].download_url")
|
||||||
file_name=$(<<<$mod_data jq -r ".releases[-1].file_name")
|
file_name=$(<<<$mod_data jq -r ".releases[-1].file_name")
|
||||||
sha1=$(<<<$mod_data jq -r ".releases[-1].sha1") # TODO
|
sha1=$(<<<$mod_data jq -r ".releases[-1].sha1")
|
||||||
[ -f $download_dir/$file_name ] || curl --location --no-clobber --output $download_dir/$file_name "https://mods.factorio.com/$download_url?username=$username&token=$token"
|
if [ -f $download_dir/$file_name ]; then
|
||||||
|
current_sha1=$(sha1sum $download_dir/$file_name | awk '{print $1}')
|
||||||
|
if [[ $current_sha1 = $sha1 ]]; then
|
||||||
|
continue
|
||||||
|
else
|
||||||
|
echo $current_sha1 $sha1
|
||||||
|
>&2 echo "Checksum mismatch; re-downloading"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
curl --location --output $download_dir/$file_name "https://mods.factorio.com/$download_url?username=$username&token=$token"
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue