diff --git a/.linux/bash/module/archive.sh b/.linux/bash/module/archive.sh index 25ea876..de4f595 100644 --- a/.linux/bash/module/archive.sh +++ b/.linux/bash/module/archive.sh @@ -144,15 +144,26 @@ unarchive() saved="${saved%%.*}" # calculate actual hash. - local actual=$(sha1sum "${target}" | cut -d\ -f1) + local actual=$(pv "${target}" | sha1sum | cut -d\ -f1) # extract if hash matched or show error if not. if [[ "${saved}" = "${actual}" ]]; then - echo "${status}: OK." - tar -xf "${target}" + echo "${status}: validation OK." + case "${target##*.}" in + "xz") + pv "${target}" | xz -d | tar -xf - + ;; + "gz") + pv "${target}" | gzip -d | tar -xf - + ;; + esac else - echo "${status}: failed." + echo "${status}: validation failed." + return 1 fi + + # report extraction complete. + echo "${status}: done." done }