Skip to content

Commit

Permalink
Set line feed in fetch script
Browse files Browse the repository at this point in the history
  • Loading branch information
GilbN committed Oct 11, 2023
1 parent 8d8589c commit ad5a877
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions fetch.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
#!/usr/bin/env bash
# Downloads all docker mod scripts

# 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"
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
curl "$value" --create-dirs --output "$DIR/98-themepark-$key" --silent
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
chmod -R +x "$DIR"

0 comments on commit ad5a877

Please sign in to comment.