diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2017-07-01 07:29:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2017-07-01 07:31:33 +0000 |
commit | 63458fc4eeac5839b7f0ec07e4debbcff0f97a0e (patch) | |
tree | f13375842e7ba14fdfe3f7064d31c5d72a743da6 /lib/container/stop | |
parent | Releasing debian version 20170629-1. (diff) | |
download | open-infrastructure-compute-tools-63458fc4eeac5839b7f0ec07e4debbcff0f97a0e.tar.xz open-infrastructure-compute-tools-63458fc4eeac5839b7f0ec07e4debbcff0f97a0e.zip |
Merging upstream version 20170701.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/container/stop')
-rwxr-xr-x | lib/container/stop | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/lib/container/stop b/lib/container/stop index 359a136..12cf7fa 100755 --- a/lib/container/stop +++ b/lib/container/stop @@ -78,6 +78,27 @@ Usage () exit 1 } +Rmdir () +{ + DIRECTORIES="${@}" + + for DIRECTORY in ${DIRECTORIES} + do + PARENT_DIRECTORY="/$(echo ${DIRECTORY} | cut -d / -f 2)" + + if [ "${PARENT_DIRECTORY}" != "${DIRECTORY}" ] + then + # the directory is at least two levels down from / + cd "${PARENT_DIRECTORY}" + + CRUFT="$(echo ${DIRECTORY} | cut -d / -f 3-)" + rmdir --ignore-fail-on-non-empty --parents "${CRUFT}" > /dev/null 2>&1 || true + + cd "${OLDPWD}" + fi + done +} + Parameters "${@}" if [ -z "${NAME}" ] @@ -120,10 +141,7 @@ case "${CLEAN}" in umount -f "${DIRECTORY_MERGED}" - for DIRECTORY in "${DIRECTORY_LOWER}" "${DIRECTORY_UPPER}" "${DIRECTORY_WORK}" "${DIRECTORY_MERGED}" - do - rmdir --ignore-fail-on-non-empty --parents ${DIRECTORY} > /dev/null 2>&1 || true - done + Rmdir "${DIRECTORY_LOWER}" "${DIRECTORY_UPPER}" "${DIRECTORY_WORK}" "${DIRECTORY_MERGED}" done fi @@ -138,7 +156,7 @@ case "${CLEAN}" in do DIRECTORY="$(echo ${BIND} | awk -F: '{ print $1 }')" - rmdir --ignore-fail-on-non-empty --parents ${DIRECTORY} > /dev/null 2>&1 || true + Rmdir "${DIRECTORY}" done fi @@ -153,7 +171,7 @@ case "${CLEAN}" in do DIRECTORY="$(echo ${BIND_RO} | awk -F: '{ print $1 }')" - rmdir --ignore-fail-on-non-empty --parents ${DIRECTORY} > /dev/null 2>&1 || true + Rmdir "${DIRECTORY}" done fi |