2019-11-04 11:34:43 +08:00
|
|
|
## only needs to have the file with a file passed into it to get the filetype.
|
|
|
|
## only supports tar.gz/xz and zip currently for unpacking.
|
2019-11-04 11:38:58 +08:00
|
|
|
## The value for ${DOWNLOAD_LINK##*/} is derived from DOWNLOAD_LINK
|
|
|
|
## if the download link is https://launcher.mojang.com/v1/objects/3dc3d84a581f14691199cf6831b71ed1296a9fdf/server.jar then the ##*/ is server.jar
|
2019-11-04 11:34:43 +08:00
|
|
|
|
|
|
|
FILETYPE=$(file -F ',' ${DOWNLOAD_LINK##*/} | cut -d',' -f2 | cut -d' ' -f2)
|
|
|
|
if [ "$FILETYPE" == "gzip" ]; then
|
|
|
|
tar xzvf ${DOWNLOAD_LINK##*/}
|
|
|
|
elif [ "$FILETYPE" == "Zip" ]; then
|
|
|
|
unzip ${DOWNLOAD_LINK##*/}
|
|
|
|
elif [ "$FILETYPE" == "XZ" ]; then
|
|
|
|
tar xvf ${DOWNLOAD_LINK##*/}
|
|
|
|
else
|
|
|
|
echo -e "unknown filetype. Exeting"
|
|
|
|
exit 2
|
|
|
|
fi
|