diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2018-05-27 18:57:08 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2018-05-27 18:57:08 +0000 |
commit | 34f9dde6d7bc82cef01eb7b3ab001f3e058782f2 (patch) | |
tree | bebd390e420aa1556459c192836e271417411273 /lib | |
parent | Adding upstream version 20180503. (diff) | |
download | open-infrastructure-compute-tools-34f9dde6d7bc82cef01eb7b3ab001f3e058782f2.tar.xz open-infrastructure-compute-tools-34f9dde6d7bc82cef01eb7b3ab001f3e058782f2.zip |
Adding upstream version 20180527.upstream/20180527
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-x | lib/container/create | 7 | ||||
-rwxr-xr-x | lib/container/enter | 15 | ||||
-rwxr-xr-x | lib/container/remove | 23 | ||||
-rwxr-xr-x | lib/container/restart | 15 | ||||
-rwxr-xr-x | lib/container/start | 17 | ||||
-rwxr-xr-x | lib/container/stop | 20 | ||||
-rwxr-xr-x | lib/container/top | 2 | ||||
-rwxr-xr-x | lib/container/version | 2 |
8 files changed, 93 insertions, 8 deletions
diff --git a/lib/container/create b/lib/container/create index 2ffcfda..561584c 100755 --- a/lib/container/create +++ b/lib/container/create @@ -121,6 +121,13 @@ then Usage fi +case "${NAME}" in + ALL) + echo "'${NAME}': name 'ALL' is reserved to expand to all available container" >&2 + exit 1 + ;; +esac + if [ -e "${CONFIG}/${NAME}.conf" ] then echo "'${NAME}': container already exists or ${CONFIG}/${NAME}.conf has not been removed" >&2 diff --git a/lib/container/enter b/lib/container/enter index faf5d35..72b3b1c 100755 --- a/lib/container/enter +++ b/lib/container/enter @@ -103,15 +103,16 @@ do fi done +SSH_CLIENT="${SSH_CLIENT:-127.0.0.1 0 0}" + # Run -if [ -e "${MACHINES}/${NAME}/usr/bin/container-nsenter" ] -then - OPTIONS="/usr/bin/container-nsenter" -else - OPTIONS="" -fi +nsenter --all --target "${LEADER}" --wd="${MACHINES}/${NAME}/root" /usr/bin/script -c "/bin/bash -l" -q /dev/null -nsenter --target ${LEADER} --mount --uts --ipc --net --pid --root --wd=/root ${OPTIONS} +case "${SSH_CLIENT}" in + 127.0.0.1*) + unset SSH_CLIENT + ;; +esac # Post hooks for FILE in "${HOOKS}/post-${COMMAND}".* "${HOOKS}/${NAME}.post-${COMMAND}" diff --git a/lib/container/remove b/lib/container/remove index e8dd653..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" ;; - -f|--verbose) + -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 diff --git a/lib/container/restart b/lib/container/restart index a507cc0..a22b970 100755 --- a/lib/container/restart +++ b/lib/container/restart @@ -27,6 +27,8 @@ MACHINES="/var/lib/machines" Parameters () { + OPTIONS_ALL="" + GETOPT_LONGOPTIONS="name:," GETOPT_OPTIONS="n:," @@ -74,6 +76,19 @@ then Usage fi +case "${NAME}" in + ALL) + NAMES="$(container list --format shell --started)" + + for NAME in ${NAMES} + do + container restart --name ${NAME} || true + done + + exit 0 + ;; +esac + if [ ! -e "${MACHINES}/${NAME}" ] then echo "'${NAME}': no such container" >&2 diff --git a/lib/container/start b/lib/container/start index e4b2ee6..62fb926 100755 --- a/lib/container/start +++ b/lib/container/start @@ -31,6 +31,8 @@ SYSTEMCTL="true" Parameters () { + OPTIONS_ALL="" + GETOPT_LONGOPTIONS="name:,force,nspawn,start," GETOPT_OPTIONS="n:f," @@ -55,6 +57,8 @@ Parameters () -f|--force) FORCE="true" shift 1 + + OPTIONS_ALL="${OPTIONS_ALL} --force" ;; --nspawn) @@ -96,6 +100,19 @@ then Usage fi +case "${NAME}" in + ALL) + NAMES="$(container list --format shell --stopped)" + + for NAME in ${NAMES} + do + container start --name ${NAME} ${OPTIONS_ALL} || true + done + + exit 0 + ;; +esac + if [ ! -e "${MACHINES}/${NAME}" ] then echo "'${NAME}': no such container" >&2 diff --git a/lib/container/stop b/lib/container/stop index 5099005..d996282 100755 --- a/lib/container/stop +++ b/lib/container/stop @@ -30,6 +30,8 @@ CLEAN="false" Parameters () { + OPTIONS_ALL="" + GETOPT_LONGOPTIONS="name:,force,clean," GETOPT_OPTIONS="n:,f," @@ -53,12 +55,17 @@ Parameters () -f|--force) FORCE="true" + shift 1 + + OPTIONS_ALL="${OPTIONS_ALL} --force" ;; --clean) # internal option CLEAN="true" shift 1 + + OPTONS_ALL="${OPTIONS_ALL} --clean" ;; --) @@ -108,6 +115,19 @@ then Usage fi +case "${NAME}" in + ALL) + NAMES="$(container list --format shell --started)" + + for NAME in ${NAMES} + do + container stop --name ${NAME} ${OPTIONS_ALL} || true + done + + exit 0 + ;; +esac + if [ ! -e "${MACHINES}/${NAME}" ] then echo "'${NAME}': no such container" >&2 diff --git a/lib/container/top b/lib/container/top index 22a224a..31ec005 100755 --- a/lib/container/top +++ b/lib/container/top @@ -20,6 +20,8 @@ set -e +COMMAND="$(basename ${0})" + Parameters () { GETOPT_LONGOPTIONS="delay:," diff --git a/lib/container/version b/lib/container/version index fe42216..543d6dc 100755 --- a/lib/container/version +++ b/lib/container/version @@ -20,6 +20,8 @@ set -e +COMMAND="$(basename ${0})" + HOOKS="/etc/container-tools/hooks" SHARE="/usr/share/container-tools" |