From e9d69622b3a06141e2a44288b6c8612484b56b56 Mon Sep 17 00:00:00 2001 From: Samuel Philipp Date: Sat, 20 Feb 2021 21:52:20 +0000 Subject: [PATCH] Update 'update-mods.sh' --- update-mods.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/update-mods.sh b/update-mods.sh index 6e2eb4c..316b68e 100644 --- a/update-mods.sh +++ b/update-mods.sh @@ -11,13 +11,15 @@ do 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" + unzip -oq temp.zip -d temp + rm -rf "$BASE/${mod[0]}/" + mkdir -p "$BASE/${mod[0]}/" + if [[ $(find temp/* -maxdepth 0 -type d | 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