archive : fix tab errors.
This commit is contained in:
parent
604ce79c31
commit
4cdb99fd6d
|
@ -7,10 +7,10 @@ _ARCHIVE_DATE() {
|
||||||
# usage: archive [FILES]
|
# usage: archive [FILES]
|
||||||
archive() {
|
archive() {
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
local targets=("${@}") # target file(s).
|
local targets=("${@}")
|
||||||
local count=0 # processed count.
|
local count=0
|
||||||
local total=${#} # total to process.
|
local total=${#}
|
||||||
local date=$(_ARCHIVE_DATE) # date stamp.
|
local date=$(_ARCHIVE_DATE)
|
||||||
local failed=0
|
local failed=0
|
||||||
|
|
||||||
# Set dafult value to target all directories.
|
# Set dafult value to target all directories.
|
||||||
|
@ -34,7 +34,7 @@ archive() {
|
||||||
tar -c "${target}" | pv -s $(du -sb "${target}" | awk '{print $1}') | xz -9e > "${name}".txz
|
tar -c "${target}" | pv -s $(du -sb "${target}" | awk '{print $1}') | xz -9e > "${name}".txz
|
||||||
|
|
||||||
# append hash to target name.
|
# append hash to target name.
|
||||||
mv "${name}".txz "${name}"_${date}-$(pv "${name}".txz | sha1sum | cut -d\ -f1).txz
|
mv "${name}".txz "${name}"_${date}-$(pv "${name}".txz | sha1sum | cut -d\ -f1).txz
|
||||||
|
|
||||||
# Show error.
|
# Show error.
|
||||||
if [[ ${?} != 0 ]]; then
|
if [[ ${?} != 0 ]]; then
|
||||||
|
@ -54,10 +54,10 @@ archive() {
|
||||||
# usage: archive_fast [FILES]
|
# usage: archive_fast [FILES]
|
||||||
archive_fast() {
|
archive_fast() {
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
local targets=("${@}") # target file(s).
|
local targets=("${@}")
|
||||||
local count=0 # processed count.
|
local count=0
|
||||||
local total=${#} # total to process.
|
local total=${#}
|
||||||
local date=$(_ARCHIVE_DATE) # date stamp.
|
local date=$(_ARCHIVE_DATE)
|
||||||
local failed=0
|
local failed=0
|
||||||
|
|
||||||
# Set dafult value to target all directories.
|
# Set dafult value to target all directories.
|
||||||
|
@ -81,7 +81,7 @@ archive_fast() {
|
||||||
tar -c "${target}" | pv -s $(du -sb "${target}" | awk '{print $1}') | gzip -1 > "${name}".tgz
|
tar -c "${target}" | pv -s $(du -sb "${target}" | awk '{print $1}') | gzip -1 > "${name}".tgz
|
||||||
|
|
||||||
# append hash to target name.
|
# append hash to target name.
|
||||||
mv "${name}".tgz "${name}"_${date}-$(pv "${name}".tgz | sha1sum | cut -d\ -f1).tgz
|
mv "${name}".tgz "${name}"_${date}-$(pv "${name}".tgz | sha1sum | cut -d\ -f1).tgz
|
||||||
|
|
||||||
# Show error.
|
# Show error.
|
||||||
if [[ $? != 0 ]]; then
|
if [[ $? != 0 ]]; then
|
||||||
|
@ -101,9 +101,9 @@ archive_fast() {
|
||||||
# usage: archive_check [FILES]
|
# usage: archive_check [FILES]
|
||||||
archive_check() {
|
archive_check() {
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
local targets=("${@}") # target file(s).
|
local targets=("${@}")
|
||||||
local total=${#} # total to process.
|
local total=${#}
|
||||||
local count=0 # processed count.
|
local count=0
|
||||||
local failed=0
|
local failed=0
|
||||||
|
|
||||||
# set dafult value to target all supported archives.
|
# set dafult value to target all supported archives.
|
||||||
|
@ -126,7 +126,7 @@ archive_check() {
|
||||||
local saved=${data[2]}
|
local saved=${data[2]}
|
||||||
|
|
||||||
# calculate actual hash.
|
# calculate actual hash.
|
||||||
local actual=$(pv "${target}" | sha1sum | cut -d\ -f1)
|
local actual=$(pv "${target}" | sha1sum | cut -d\ -f1)
|
||||||
|
|
||||||
# compare hashes, show error on mismatch.
|
# compare hashes, show error on mismatch.
|
||||||
if [[ "${actual}" != "${saved}" ]]; then
|
if [[ "${actual}" != "${saved}" ]]; then
|
||||||
|
@ -196,9 +196,9 @@ archive_prune() {
|
||||||
# usage: unarchive [FILES]
|
# usage: unarchive [FILES]
|
||||||
unarchive() {
|
unarchive() {
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
local targets=("${@}") # target file(s).
|
local targets=("${@}")
|
||||||
local count=0 # processed count.
|
local count=0
|
||||||
local total=${#} # total to process.
|
local total=${#}
|
||||||
local failed=0
|
local failed=0
|
||||||
|
|
||||||
# set dafult value to target all supported archives.
|
# set dafult value to target all supported archives.
|
||||||
|
@ -221,7 +221,7 @@ unarchive() {
|
||||||
local saved="${data[2]}"
|
local saved="${data[2]}"
|
||||||
|
|
||||||
# calculate actual hash.
|
# calculate actual hash.
|
||||||
local actual=$(pv "${target}" | sha1sum | cut -d\ -f1)
|
local actual=$(pv "${target}" | sha1sum | cut -d\ -f1)
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -262,10 +262,10 @@ unarchive() {
|
||||||
# usage: archive_name [ARCHIVE] [NAME]
|
# usage: archive_name [ARCHIVE] [NAME]
|
||||||
archive_name() {
|
archive_name() {
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
local targets="${1}" # target archive(s).
|
local targets="${1}"
|
||||||
local name="${2}" # new name.
|
local name="${2}"
|
||||||
local total=1 # total targets to process.
|
local total=1
|
||||||
local count=0 # processed targets counter.
|
local count=0
|
||||||
local failed=0
|
local failed=0
|
||||||
|
|
||||||
# set dafult value to target all supported archives.
|
# set dafult value to target all supported archives.
|
||||||
|
|
Reference in a new issue