bash : archive : add progress for extraction.
This commit is contained in:
parent
fd639dc055
commit
d3209a25ba
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue