Simplify removal code
Signed-off-by: Nico Schottelius <nico@ikn.schottelius.org>
This commit is contained in:
parent
9aa111d21b
commit
e6a0300b9b
1 changed files with 11 additions and 15 deletions
26
ccollect.sh
26
ccollect.sh
|
@ -250,6 +250,7 @@ while [ "${i}" -lt "${no_sources}" ]; do
|
||||||
# Start subshell for easy log editing
|
# Start subshell for easy log editing
|
||||||
#
|
#
|
||||||
(
|
(
|
||||||
|
backup="${CSOURCES}/${name}"
|
||||||
#
|
#
|
||||||
# Stderr to stdout, so we can produce nice logs
|
# Stderr to stdout, so we can produce nice logs
|
||||||
#
|
#
|
||||||
|
@ -278,7 +279,6 @@ while [ "${i}" -lt "${no_sources}" ]; do
|
||||||
#
|
#
|
||||||
# Read / create configuration
|
# Read / create configuration
|
||||||
#
|
#
|
||||||
backup="${CSOURCES}/${name}"
|
|
||||||
c_source="${backup}/source"
|
c_source="${backup}/source"
|
||||||
c_dest="${backup}/destination"
|
c_dest="${backup}/destination"
|
||||||
c_pre_exec="${backup}/pre_exec"
|
c_pre_exec="${backup}/pre_exec"
|
||||||
|
@ -459,20 +459,16 @@ while [ "${i}" -lt "${no_sources}" ]; do
|
||||||
head -n "${remove}" > "${TMP}" || \
|
head -n "${remove}" > "${TMP}" || \
|
||||||
_exit_err "Listing old backups failed"
|
_exit_err "Listing old backups failed"
|
||||||
|
|
||||||
i=0
|
#
|
||||||
while read to_remove; do
|
# ssh-"feature": we cannot do '... read ...; ssh ...; < file',
|
||||||
eval remove_$i=\"${to_remove}\"
|
# because ssh reads stdin! -n does not work -> does not ask for password
|
||||||
i="$(($i+1))"
|
#
|
||||||
done < "${TMP}"
|
(
|
||||||
|
set -- ""
|
||||||
j=0
|
while read to_remove; do set -- "$@" "${ddir}/${to_remove}"; done < "${TMP}"
|
||||||
while [ "${j}" -lt "${i}" ]; do
|
_techo "Removing $@ ..."
|
||||||
eval to_remove=\"\$remove_$j\"
|
pcmd rm ${VVERBOSE} -rf "$@"
|
||||||
_techo "Removing ${to_remove} ..."
|
) || _exit_err "Removing $@ failed."
|
||||||
pcmd rm ${VVERBOSE} -rf "${ddir}/${to_remove}" || \
|
|
||||||
_exit_err "Removing ${to_remove} failed."
|
|
||||||
j="$(($j+1))"
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in a new issue