bash : archive : update colors for messages.
This commit is contained in:
parent
bb12e71d67
commit
823a153304
|
@ -30,6 +30,9 @@ archive()
|
||||||
|
|
||||||
# append hash to target name.
|
# append hash to target name.
|
||||||
mv "${target%/*}".tar.xz "${target%/*}"_${date}-$(sha1sum "${target%/*}".tar.xz | cut -d\ -f1).tar.xz
|
mv "${target%/*}".tar.xz "${target%/*}"_${date}-$(sha1sum "${target%/*}".tar.xz | cut -d\ -f1).tar.xz
|
||||||
|
|
||||||
|
# report success.
|
||||||
|
echo -e "${color_green}${status}: done.${color_default}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,6 +65,9 @@ archive_fast()
|
||||||
|
|
||||||
# append hash to target name.
|
# append hash to target name.
|
||||||
mv "${target%/*}".tar.gz "${target%/*}"_${date}-$(sha1sum "${target%/*}".tar.gz | cut -d\ -f1).tar.gz
|
mv "${target%/*}".tar.gz "${target%/*}"_${date}-$(sha1sum "${target%/*}".tar.gz | cut -d\ -f1).tar.gz
|
||||||
|
|
||||||
|
# report success.
|
||||||
|
echo -e "${color_green}${status}: done.${color_default}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,15 +106,15 @@ archive_check()
|
||||||
|
|
||||||
# compare hashes, show error on mismatch.
|
# compare hashes, show error on mismatch.
|
||||||
if [[ "${actual}" = "${saved}" ]]; then
|
if [[ "${actual}" = "${saved}" ]]; then
|
||||||
echo "${status}: OK."
|
echo "${status}: validation OK."
|
||||||
else
|
else
|
||||||
echo -e "${color_red}${status}: failed.${color_default}"
|
echo -e "${color_bred}${status}: validation failed.${color_default}"
|
||||||
((failed++))
|
((failed++))
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# report result.
|
# report result.
|
||||||
if [[ ${count} -gt 1 ]]; then
|
if [[ ${count} -gt 1 ]] || [[ "${*}" = "" ]]; then
|
||||||
if [[ ${failed} -gt 0 ]]; then
|
if [[ ${failed} -gt 0 ]]; then
|
||||||
echo -e "${color_bred}Items failed to validate: ${failed}.${color_default}"
|
echo -e "${color_bred}Items failed to validate: ${failed}.${color_default}"
|
||||||
else
|
else
|
||||||
|
@ -149,21 +155,28 @@ unarchive()
|
||||||
# extract if hash matched or show error if not.
|
# extract if hash matched or show error if not.
|
||||||
if [[ "${saved}" = "${actual}" ]]; then
|
if [[ "${saved}" = "${actual}" ]]; then
|
||||||
echo "${status}: validation OK."
|
echo "${status}: validation OK."
|
||||||
|
|
||||||
|
# figure out the compression tool.
|
||||||
|
local compressor
|
||||||
case "${target##*.}" in
|
case "${target##*.}" in
|
||||||
"xz")
|
"xz")
|
||||||
pv "${target}" | xz -d | tar -xf -
|
compressor="xz -d"
|
||||||
;;
|
;;
|
||||||
"gz")
|
"gz")
|
||||||
pv "${target}" | gzip -d | tar -xf -
|
compressor="gzip -d"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# extract.
|
||||||
|
pv "${target}" | ${compressor} | tar -xf -
|
||||||
else
|
else
|
||||||
echo "${status}: validation failed."
|
# report validation error & exit.
|
||||||
|
echo -e "${color_bred}${status}: validation failed.${color_default}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# report extraction complete.
|
# report extraction complete.
|
||||||
echo "${status}: done."
|
echo -e "${color_green}${status}: done.${color_default}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,12 +224,12 @@ archive_name()
|
||||||
|
|
||||||
# check for existing target.
|
# check for existing target.
|
||||||
if [[ -f "${new_name}" ]]; then
|
if [[ -f "${new_name}" ]]; then
|
||||||
echo -e "${color_red}${status}: already exists.${color_default}"
|
echo -e "${color_bred}${status}: already exists.${color_default}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# rename.
|
# rename.
|
||||||
mv -- "${target}" "${new_name}" && echo "${status}" || echo -e "${color_red}${status}: error.${color_default}"
|
mv -- "${target}" "${new_name}" && echo "${color_green}${status}${color_default}" || echo -e "${color_bred}${status}: error.${color_default}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue