2018-02-03 21:01:15 -07:00
|
|
|
#!/bin/sh
|
|
|
|
|
2020-06-29 20:04:33 -06:00
|
|
|
set -e
|
|
|
|
|
2022-06-02 16:50:17 -06:00
|
|
|
df_tardest="df.tar.bz2"
|
|
|
|
save_tardest="test_save.tgz"
|
2018-02-03 21:01:15 -07:00
|
|
|
|
2018-02-03 21:56:44 -07:00
|
|
|
selfmd5=$(openssl md5 < "$0")
|
|
|
|
echo $selfmd5
|
|
|
|
|
2018-02-03 21:01:15 -07:00
|
|
|
cd "$(dirname "$0")"
|
|
|
|
echo "DF_VERSION: $DF_VERSION"
|
|
|
|
echo "DF_FOLDER: $DF_FOLDER"
|
|
|
|
mkdir -p "$DF_FOLDER"
|
2019-01-02 16:40:34 -07:00
|
|
|
# back out of df_linux
|
2019-01-02 17:15:19 -07:00
|
|
|
cd "$DF_FOLDER/.."
|
2018-02-03 21:01:15 -07:00
|
|
|
|
2018-02-04 00:13:20 -07:00
|
|
|
if [ -f receipt ]; then
|
|
|
|
if [ "$selfmd5" != "$(cat receipt)" ]; then
|
2022-06-02 16:50:17 -06:00
|
|
|
echo "download-df.sh changed; re-downloading tarballs"
|
2018-12-30 15:47:10 -07:00
|
|
|
rm receipt
|
2018-02-03 21:56:44 -07:00
|
|
|
else
|
2022-06-02 16:50:17 -06:00
|
|
|
echo "Already downloaded $DF_VERSION tarballs"
|
2018-02-03 21:56:44 -07:00
|
|
|
fi
|
2018-02-03 21:01:15 -07:00
|
|
|
fi
|
|
|
|
|
2018-12-30 15:47:10 -07:00
|
|
|
if [ ! -f receipt ]; then
|
2022-06-02 16:50:17 -06:00
|
|
|
rm -f "$df_tardest" "$save_tardest"
|
2018-12-30 15:47:10 -07:00
|
|
|
minor=$(echo "$DF_VERSION" | cut -d. -f2)
|
|
|
|
patch=$(echo "$DF_VERSION" | cut -d. -f3)
|
2022-06-02 16:50:17 -06:00
|
|
|
echo "Downloading DF $DF_VERSION"
|
2020-06-29 20:35:23 -06:00
|
|
|
while read url; do
|
|
|
|
echo "Attempting download: ${url}"
|
2022-06-02 16:50:17 -06:00
|
|
|
if wget -v "$url" -O "$df_tardest"; then
|
2020-06-29 20:35:23 -06:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done <<URLS
|
|
|
|
https://www.bay12games.com/dwarves/df_${minor}_${patch}_linux.tar.bz2
|
|
|
|
https://files.dfhack.org/DF/0.${minor}.${patch}/df_${minor}_${patch}_linux.tar.bz2
|
|
|
|
URLS
|
2022-06-02 16:50:17 -06:00
|
|
|
echo $df_tardest
|
|
|
|
if ! test -f "$df_tardest"; then
|
|
|
|
echo "DF failed to download: $df_tardest not found"
|
2020-06-29 20:35:23 -06:00
|
|
|
exit 1
|
|
|
|
fi
|
2022-06-02 16:50:17 -06:00
|
|
|
echo "Downloading test save"
|
|
|
|
#test_save_url="https://files.dfhack.org/DF/0.${minor}.${patch}/test_save.tgz"
|
|
|
|
test_save_url="https://drive.google.com/uc?export=download&id=1XvYngl-DFONiZ9SD9OC4B2Ooecu8rPFz"
|
|
|
|
if ! wget -v "$test_save_url" -O "$save_tardest"; then
|
|
|
|
echo "failed to download test save"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo $save_tardest
|
2018-12-30 15:47:10 -07:00
|
|
|
fi
|
2018-02-03 21:01:15 -07:00
|
|
|
|
2018-12-30 15:47:10 -07:00
|
|
|
rm -rf df_linux
|
2022-06-02 16:50:17 -06:00
|
|
|
mkdir -p df_linux/data/save
|
2018-02-03 21:01:15 -07:00
|
|
|
|
|
|
|
echo Extracting
|
2022-06-02 16:50:17 -06:00
|
|
|
tar xf "$df_tardest" --strip-components=1 -C df_linux
|
|
|
|
tar xf "$save_tardest" -C df_linux/data/save
|
2018-02-03 21:01:15 -07:00
|
|
|
echo Done
|
|
|
|
|
2018-02-03 21:56:44 -07:00
|
|
|
echo "$selfmd5" > receipt
|
2018-12-30 15:47:10 -07:00
|
|
|
ls
|