From 9dfb6f87d0696fbf1930eda7d1957f52f2551988 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 27 May 2018 20:32:24 +0200 Subject: Adding 'ALL' as pseudo container name for container start, stop, restart, and remove commands to act on all available container respectivly. Signed-off-by: Daniel Baumann --- lib/container/remove | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lib/container/remove') diff --git a/lib/container/remove b/lib/container/remove index 427bf4a..275c867 100755 --- a/lib/container/remove +++ b/lib/container/remove @@ -28,6 +28,8 @@ MACHINES="/var/lib/machines" Parameters () { + OPTIONS_ALL="" + GETOPT_LONGOPTIONS="name:,allow-stop,force,verbose," GETOPT_OPTIONS="n:,f,v," @@ -52,16 +54,22 @@ Parameters () --allow-stop) ALLOW_STOP="true" shift 1 + + OPTIONS_ALL="${OPTIONS_ALL} --allow-stop" ;; -f|--force) FORCE="true" shift 1 + + OPTIONS_ALL="${OPTIONS_ALL} --force" ;; -v|--verbose) VERBOSE="true" shift 1 + + OPTIONS_ALL="${OPTIONS_ALL} --verbose" ;; --) @@ -111,6 +119,19 @@ then Usage fi +case "${NAME}" in + ALL) + NAMES="$(container list --format shell --stopped)" + + for NAME in ${NAMES} + do + container remove --name ${NAME} ${OPTIONS_ALL} || true + done + + exit 0 + ;; +esac + if [ ! -e "${MACHINES}/${NAME}" ] && [ ! -e "${CONFIG}/${NAME}.conf" ] then echo "'${NAME}': no such container" >&2 -- cgit v1.2.3