From 29304d802385787ca4dd04ad6d8d18bb1f01bc2d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 18 May 2016 11:33:34 +0200 Subject: Adding upstream version 20160515. Signed-off-by: Daniel Baumann --- lib/container/stop | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'lib/container/stop') diff --git a/lib/container/stop b/lib/container/stop index cd3de10..67cc403 100755 --- a/lib/container/stop +++ b/lib/container/stop @@ -20,11 +20,14 @@ set -e COMMAND="$(basename ${0})" +CONFIG="/etc/container-tools/config" MACHINES="/var/lib/machines" +CLEAN="false" + Parameters () { - LONG_OPTIONS="name:,force" + LONG_OPTIONS="name:,force,clean" OPTIONS="n:,f" PARAMETERS="$(getopt --longoptions ${LONG_OPTIONS} --name=${COMMAND} --options ${OPTIONS} --shell sh -- ${@})" @@ -49,6 +52,12 @@ Parameters () FORCE="true" ;; + --clean) + # internal option + CLEAN="true" + shift 1 + ;; + --) shift 1 break @@ -83,6 +92,36 @@ fi STATE="$(machinectl show ${NAME} 2>&1 | awk -F= '/^State=/ { print $2 }')" +# Removing network configuration +case "${CLEAN}" in + true) + NETWORK_VETH_EXTRA_CONF="$(awk -F= '/^network-veth-extra=/ { print $2 }' ${CONFIG}/${NAME}.conf)" + + case "${NETWORK_VETH_EXTRA_CONF}" in + "") + ;; + + *) + for VETH in ${NETWORK_VETH_EXTRA_CONF} + do + INTERFACE="$(echo ${VETH} | awk -F: '{ print $1 }')" + FILE="/etc/network/interfaces.d/${INTERFACE}" + + if [ -f "${FILE}" ] + then + rm -f "${FILE}" + fi + done + ;; + esac + + exit 0 + ;; + + *) + ;; +esac + case "${STATE}" in running) ;; -- cgit v1.2.3