From ac9d7da1d6f69a0a6fbb8e3729a24b9fa775f923 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 1 Jun 2016 15:56:36 +0200 Subject: Adding upstream version 20160601. Signed-off-by: Daniel Baumann --- lib/container/create | 31 +++++++++++++++++++++++++++---- lib/container/remove | 2 +- lib/container/stop | 17 ++++++++++++++++- 3 files changed, 44 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/container/create b/lib/container/create index 0b0aa3a..dea1e76 100755 --- a/lib/container/create +++ b/lib/container/create @@ -103,11 +103,34 @@ then exit 1 fi -SCRIPT="${SCRIPT:-debian}" - -if [ ! -e "/usr/share/container-tools/scripts/${SCRIPT}" ] +if [ -z "${SCRIPT}" ] then - echo "'${SCRIPT}': no such script" >&2 + if [ -e /usr/share/container-tools/scripts/default ] + then + TARGET="$(basename $(readlink /usr/share/container-tools/scripts/default))" + + case "${TARGET}" in + container-tools_script) + TARGET="$(basename $(readlink /etc/alternatives/container-tools_script))" + ;; + esac + + if [ -e "/usr/share/container-tools/scripts/${TARGET}" ] + then + SCRIPT="${TARGET}" + else + echo "default -> '${TARGET}': no such script" >&2 + exit 1 + fi + else + SCRIPT="debian" + fi +else + if [ ! -e "/usr/share/container-tools/scripts/${SCRIPT}" ] + then + echo "'${SCRIPT}': no such script" >&2 + exit 1 + fi fi CNT_AUTO="${CNT_AUTO:-$(hostname -f)}" diff --git a/lib/container/remove b/lib/container/remove index d171d87..4f26d43 100755 --- a/lib/container/remove +++ b/lib/container/remove @@ -127,5 +127,5 @@ then fi # Run -rm -rf "${MACHINES}/${NAME}" +rm --preserve-root --one-file-system -rf "${MACHINES}/${NAME}" rm -f "${CONFIG}/${NAME}.conf" 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