summaryrefslogtreecommitdiffstats
path: root/lib/container/stop
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2016-05-18 18:28:46 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2016-05-18 18:29:07 +0000
commitb90ddebe1d1cb49c30c3a9d99119e3b0d14995fd (patch)
treea462154b0ea87956dca914338f88544f205ba06a /lib/container/stop
parentReleasing debian version 20160501-1. (diff)
downloadopen-infrastructure-compute-tools-b90ddebe1d1cb49c30c3a9d99119e3b0d14995fd.tar.xz
open-infrastructure-compute-tools-b90ddebe1d1cb49c30c3a9d99119e3b0d14995fd.zip
Merging upstream version 20160515.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'lib/container/stop')
-rwxr-xr-xlib/container/stop41
1 files changed, 40 insertions, 1 deletions
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)
;;