1
0
mirror of https://github.com/gilbN/theme.park.git synced 2024-07-15 00:57:32 +02:00
theme.park/fetch.sh
2023-10-11 21:33:26 +02:00

23 lines
717 B
Bash

#!/usr/bin/env bash
# Downloads all docker mod scripts
MODS=$(curl https://theme-park.dev/themes.json | jq -r '.["docker-mods"]')
if [[ "$0" == "bash" ]]; then
DIR="/tmp/theme-park-mods"
else
DIR="$0"
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
download_file="$DIR/98-themepark-$key"
curl "$value" --create-dirs --output "$download_file" --silent
echo "Fetched $key script"
# 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
done
chmod -R +x "$DIR"