From a35c42b60e08c6cd0719da017975a7a8eee17ae2 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 26 May 2016 10:56:10 +0200 Subject: Removing empty source directory of bind mounts in container stop command. Signed-off-by: Daniel Baumann --- lib/container/stop | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'lib/container/stop') diff --git a/lib/container/stop b/lib/container/stop index 67cc403..fb470f6 100755 --- a/lib/container/stop +++ b/lib/container/stop @@ -92,9 +92,24 @@ fi STATE="$(machinectl show ${NAME} 2>&1 | awk -F= '/^State=/ { print $2 }')" -# Removing network configuration case "${CLEAN}" in true) + # Removing bind mounts + BIND="$(awk -F= '/^bind=/ { print $2 }' ${CONFIG}/${NAME}.conf)" + + if [ -n "${BIND}" ] + then + BINDS="$(echo ${BIND} | sed -e 's|;| |g')" + + for BIND in ${BINDS} + do + DIRECTORY="$(echo ${BIND} | awk -F: '{ print $1 }')" + + rmdir --ignore-fail-on-non-empty --parents ${DIRECTORY} > /dev/null 2>&1 || true + done + fi + + # Removing network configuration NETWORK_VETH_EXTRA_CONF="$(awk -F= '/^network-veth-extra=/ { print $2 }' ${CONFIG}/${NAME}.conf)" case "${NETWORK_VETH_EXTRA_CONF}" in -- cgit v1.2.3