From f5c7014231090048cb1eabb984562c8e3ea27e15 Mon Sep 17 00:00:00 2001 From: Michael Parker Date: Sun, 3 Nov 2019 22:34:43 -0500 Subject: [PATCH] add file unpacker This is to unpack files. --- scripts/file_unpacker.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 scripts/file_unpacker.sh diff --git a/scripts/file_unpacker.sh b/scripts/file_unpacker.sh new file mode 100644 index 00000000..42cb8bcc --- /dev/null +++ b/scripts/file_unpacker.sh @@ -0,0 +1,15 @@ +## 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. +## The value for ${DOWNLOAD_LINK##*/} is + +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 \ No newline at end of file