#!/bin/bash echo "updating mod list" wget -O mods.txt https://git.sp-codes.de/minetest/minetest-mods/raw/branch/master/mods.txt BASE=mods while IFS="" read -r line || [ -n "$line" ] do IFS=' ' read -ra mod <<< "$line" echo "downloading ${mod[0]}" sleep 1 wget -q "${mod[1]}" -O temp.zip echo "extracting ${mod[0]}" unzip -oq temp.zip -d temp rm -rf "$BASE/${mod[0]}/" mkdir -p "$BASE/${mod[0]}/" if [[ $(find temp/* -maxdepth 0 | wc -l) == 1 ]]; then cp -r temp/*/* "$BASE/${mod[0]}" else cp -r temp/* "$BASE/${mod[0]}" fi echo "cleanup" rm -rf temp rm temp.zip done < mods.txt