2024-08-05 20:04:32 -05:00
|
|
|
#!/usr/bin/env nix-shell
|
|
|
|
#! nix-shell -i bash -p bash curl jq
|
|
|
|
mods="Krastorio2 Krastorio2Assets flib Big_Brother AtomicArtillery AutoDeconstruct nixie-tubes"
|
|
|
|
download_dir=./mods
|
|
|
|
username=$(cat ../keys.toml | grep factorio-username | cut -d'"' -f2)
|
|
|
|
token=$(cat ../keys.toml | grep factorio-token | cut -d'"' -f2)
|
|
|
|
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")
|
2024-08-05 20:04:50 -05:00
|
|
|
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"
|
2024-08-05 20:04:32 -05:00
|
|
|
done
|