summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@open-infrastructure.net>2022-06-05 05:25:06 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2022-06-05 06:19:27 +0000
commitdb50ab50085f35952f49d4b7c009e1303862d965 (patch)
treee8d9a98681a23d57c52d6cc755976a8f7430c505
parentUsing variables in directory paths in container key command. (diff)
downloadcompute-tools-db50ab50085f35952f49d4b7c009e1303862d965.tar.xz
compute-tools-db50ab50085f35952f49d4b7c009e1303862d965.zip
Adding default interactive mode for container stop command.
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
Diffstat (limited to '')
-rwxr-xr-xlibexec/container/stop30
-rw-r--r--share/bash-completion/container2
-rw-r--r--share/man/container-stop.1.rst3
3 files changed, 31 insertions, 4 deletions
diff --git a/libexec/container/stop b/libexec/container/stop
index cb85c8d..59c8b76 100755
--- a/libexec/container/stop
+++ b/libexec/container/stop
@@ -34,8 +34,8 @@ Parameters ()
{
OPTIONS_ALL=""
- GETOPT_LONGOPTIONS="name:,force,clean,verbose,"
- GETOPT_OPTIONS="n:,f,v,"
+ GETOPT_LONGOPTIONS="name:,force,interactive,clean,verbose,"
+ GETOPT_OPTIONS="n:,f,i,v,"
PARAMETERS="$(getopt --longoptions ${GETOPT_LONGOPTIONS} --name=${COMMAND} --options ${GETOPT_OPTIONS} --shell sh -- ${@})"
@@ -62,6 +62,13 @@ Parameters ()
OPTIONS_ALL="${OPTIONS_ALL} --force"
;;
+ -i|--interactive)
+ INTERACTIVE="true"
+ shift 1
+
+ OPTIONS_ALL="${OPTIONS_ALL} --interactive"
+ ;;
+
--clean)
# internal option
CLEAN="true"
@@ -92,7 +99,7 @@ Parameters ()
Usage ()
{
- echo "Usage: ${PROGRAM} ${COMMAND} -n|--name NAME [-f|--force] [-v|--verbose]" >&2
+ echo "Usage: ${PROGRAM} ${COMMAND} -n|--name NAME [-f|--force] [-i|--interactive] [-v|--verbose]" >&2
echo
echo "See ${COMMAND}(1), ${PROGRAM}(1) and ${PROJECT}(7) for more information."
@@ -273,6 +280,23 @@ case "${FORCE}" in
;;
esac
+if [ "${FORCE}" != "true" ] || [ "${INTERACTIVE}" = "true" ]
+then
+ echo -n "'${NAME}': stop container '${NAME}' [y|N]? "
+ read STOP
+
+ STOP="$(echo ${STOP} | tr '[A-Z]' '[a-z]')"
+
+ case "${STOP}" in
+ y|yes)
+ ;;
+
+ *)
+ exit 1
+ ;;
+ esac
+fi
+
# Run
case "${VERBOSE}" in
true)
diff --git a/share/bash-completion/container b/share/bash-completion/container
index 8a1f43d..e08b7f8 100644
--- a/share/bash-completion/container
+++ b/share/bash-completion/container
@@ -257,7 +257,7 @@ _container()
;;
*)
- opts="-n --name -f --force"
+ opts="-n --name -f --force -i --interactive"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
diff --git a/share/man/container-stop.1.rst b/share/man/container-stop.1.rst
index 31b24b4..567b2f4 100644
--- a/share/man/container-stop.1.rst
+++ b/share/man/container-stop.1.rst
@@ -51,6 +51,9 @@ The following **container stop** options are available:
-f, --force:
Instead of running the proper shutdown sequence, terminate all processes of the container imediatly.
+-i, --interactive:
+ Prompt before every stopping (default).
+
-v, --verbose:
Explain what is being done.