Validate checksum of Factorio mods

This commit is contained in:
Chandler Swift 2024-08-05 20:04:50 -05:00
parent b74fc406d5
commit 5e3015d5e3
Signed by: chandlerswift
GPG key ID: A851D929D52FB93F

View file

@ -8,6 +8,15 @@ for mod in $mods; do
mod_data=$(curl -s https://mods.factorio.com/api/mods/$mod)
download_url=$(<<<$mod_data jq -r ".releases[-1].download_url")
file_name=$(<<<$mod_data jq -r ".releases[-1].file_name")
sha1=$(<<<$mod_data jq -r ".releases[-1].sha1") # TODO
[ -f $download_dir/$file_name ] || curl --location --no-clobber --output $download_dir/$file_name "https://mods.factorio.com/$download_url?username=$username&token=$token"
sha1=$(<<<$mod_data jq -r ".releases[-1].sha1")
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