summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@open-infrastructure.net>2022-06-05 06:22:39 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2022-06-05 07:27:23 +0000
commita6b3dc088b186db8a43349dc86853c35b1b05530 (patch)
tree79b5242519687c5c625ffd889cf12a2d77851a73
parentAdding default interactive mode for container stop command. (diff)
downloadcompute-tools-a6b3dc088b186db8a43349dc86853c35b1b05530.tar.xz
compute-tools-a6b3dc088b186db8a43349dc86853c35b1b05530.zip
Renaming force option in container stop command to kill in order to properly separate the three different stop modi (interactive, force, kill).
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
Diffstat (limited to '')
-rwxr-xr-xlibexec/container/auto6
-rwxr-xr-xlibexec/container/remove2
-rwxr-xr-xlibexec/container/stop15
-rw-r--r--share/bash-completion/container2
-rw-r--r--share/man/container-stop.1.rst11
5 files changed, 28 insertions, 8 deletions
diff --git a/libexec/container/auto b/libexec/container/auto
index 927eae0..461e67d 100755
--- a/libexec/container/auto
+++ b/libexec/container/auto
@@ -109,6 +109,12 @@ case "${FORCE}" in
;;
esac
+case "${ACTION}" in
+ stop)
+ OPTIONS="${OPTIONS} -f"
+ ;;
+esac
+
for FILE in "${CONFIG}"/*.conf
do
if grep -Eqs "^ *cnt.auto=force-true" "${FILE}"
diff --git a/libexec/container/remove b/libexec/container/remove
index 86f237d..4cb5d48 100755
--- a/libexec/container/remove
+++ b/libexec/container/remove
@@ -150,7 +150,7 @@ case "${STATE}" in
case "${ALLOW_STOP}" in
true)
echo "'${NAME}': container is started, stopping it now" >&2
- ${PROGRAM} stop -n ${NAME}
+ ${PROGRAM} stop -n ${NAME} -f
;;
*)
diff --git a/libexec/container/stop b/libexec/container/stop
index 59c8b76..2d81523 100755
--- a/libexec/container/stop
+++ b/libexec/container/stop
@@ -34,8 +34,8 @@ Parameters ()
{
OPTIONS_ALL=""
- GETOPT_LONGOPTIONS="name:,force,interactive,clean,verbose,"
- GETOPT_OPTIONS="n:,f,i,v,"
+ GETOPT_LONGOPTIONS="name:,force,interactive,kill,clean,verbose,"
+ GETOPT_OPTIONS="n:,f,i,k,v,"
PARAMETERS="$(getopt --longoptions ${GETOPT_LONGOPTIONS} --name=${COMMAND} --options ${GETOPT_OPTIONS} --shell sh -- ${@})"
@@ -69,6 +69,13 @@ Parameters ()
OPTIONS_ALL="${OPTIONS_ALL} --interactive"
;;
+ -k|--kill)
+ KILL="true"
+ shift 1
+
+ OPTIONS_ALL="${OPTIONS_ALL} --kill"
+ ;;
+
--clean)
# internal option
CLEAN="true"
@@ -270,7 +277,7 @@ case "${STATE}" in
;;
esac
-case "${FORCE}" in
+case "${KILL}" in
true)
MODE="terminate"
;;
@@ -306,7 +313,7 @@ esac
machinectl ${MODE} ${NAME}
-case "${FORCE}" in
+case "${KILL}" in
true)
VETHS="$(awk -Fnetwork-veth-extra= '/^network-veth-extra=/ { print $2 }' ${CONFIG}/${NAME}.conf | awk -F: '{ print $1 }')"
diff --git a/share/bash-completion/container b/share/bash-completion/container
index e08b7f8..5b57193 100644
--- a/share/bash-completion/container
+++ b/share/bash-completion/container
@@ -257,7 +257,7 @@ _container()
;;
*)
- opts="-n --name -f --force -i --interactive"
+ opts="-n --name -f --force -i --interactive -k --kill"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
diff --git a/share/man/container-stop.1.rst b/share/man/container-stop.1.rst
index 567b2f4..bf668be 100644
--- a/share/man/container-stop.1.rst
+++ b/share/man/container-stop.1.rst
@@ -49,11 +49,14 @@ The following **container stop** options are available:
Specify container name. Specifying 'ALL' will stop all started container.
-f, --force:
- Instead of running the proper shutdown sequence, terminate all processes of the container imediatly.
+ Do not prompt before every stopping.
-i, --interactive:
Prompt before every stopping (default).
+-k, --kill:
+ Instead of running the proper shutdown sequence, terminate all processes of the container imediatly.
+
-v, --verbose:
Explain what is being done.
@@ -64,9 +67,13 @@ Shutdown example.net container:
sudo container stop -n example.net
+Shutdown example.net container without prompting:
+
+ sudo container stop -n example.net -f
+
Immediately stop example.net container:
- sudo container stop -n example.net -f
+ sudo container stop -n example.net -k
Stop all container: