Add 'update-mods.sh'

This commit is contained in:
Samuel Philipp 2021-02-20 16:30:10 +00:00
parent 0d161b7cb2
commit d338c34677
1 changed files with 23 additions and 0 deletions

23
update-mods.sh Normal file
View File

@ -0,0 +1,23 @@
#!/bin/bash
echo "updating mod list"
curl https://git.sp-codes.de/minetest/minetest-mods/raw/branch/master/mods.txt > mods.txt
BASE=mods
while IFS="" read -r line || [ -n "$line" ]
do
IFS=' ' read -ra mod <<< "$line"
echo "downloading ${mod[0]}"
wget -q "${mod[1]}" -O temp.zip
echo "extracting ${mod[0]}"
unzip -oq temp.zip -d "$BASE/${mod[0]}"
FIRST=$(zipinfo -1 temp.zip | head -n 1)
if [[ "$FIRST" == */ ]]
then
cp -r "$BASE/${mod[0]}/$FIRST"* "$BASE/${mod[0]}/"
rm -r "$BASE/${mod[0]}/$FIRST"
fi
echo "cleanup"
rm temp.zip
done < mods.txt