summaryrefslogtreecommitdiffstats
path: root/lib/container/remove
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2017-07-01 07:29:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2017-07-01 07:31:33 +0000
commit63458fc4eeac5839b7f0ec07e4debbcff0f97a0e (patch)
treef13375842e7ba14fdfe3f7064d31c5d72a743da6 /lib/container/remove
parentReleasing debian version 20170629-1. (diff)
downloadopen-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/remove')
-rwxr-xr-xlib/container/remove25
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/container/remove b/lib/container/remove
index 1b1ba7d..c9a45a6 100755
--- a/lib/container/remove
+++ b/lib/container/remove
@@ -76,6 +76,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}" ]
@@ -152,7 +173,7 @@ then
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
@@ -167,7 +188,7 @@ then
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
fi