2022-07-10 18:39:49 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2023-10-11 21:33:26 +02:00
|
|
|
# Downloads all docker mod scripts
|
2022-07-10 18:56:58 +02:00
|
|
|
MODS=$(curl https://theme-park.dev/themes.json | jq -r '.["docker-mods"]')
|
2022-07-10 18:39:49 +02:00
|
|
|
if [[ "$0" == "bash" ]]; then
|
|
|
|
DIR="/tmp/theme-park-mods"
|
|
|
|
else
|
2023-10-11 21:33:26 +02:00
|
|
|
DIR="$0"
|
2022-07-10 18:39:49 +02:00
|
|
|
fi
|
|
|
|
mkdir -p "$DIR"
|
|
|
|
printf "\nSaving mods into $DIR\n\n"
|
|
|
|
jq -r 'to_entries | map(.key + "|" + (.value | tostring)) | .[]' <<< "$MODS" | \
|
|
|
|
while IFS='|' read key value; do
|
2023-10-11 21:33:26 +02:00
|
|
|
download_file="$DIR/98-themepark-$key"
|
|
|
|
curl "$value" --create-dirs --output "$download_file" --silent
|
2022-07-10 18:39:49 +02:00
|
|
|
echo "Fetched $key script"
|
2023-10-11 21:33:26 +02:00
|
|
|
|
|
|
|
# Convert line endings from CRLF to LF manually
|
|
|
|
if [[ "$(tail -c2 "$download_file")" == $'\r\n' ]]; then
|
|
|
|
perl -pi -e 's/\r\n/\n/' "$download_file"
|
|
|
|
fi
|
2022-07-10 18:39:49 +02:00
|
|
|
done
|
2023-10-11 21:33:26 +02:00
|
|
|
chmod -R +x "$DIR"
|