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 | |
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>
35 files changed, 163 insertions, 63 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 581e46d..e18df83 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,22 @@ +2018-05-27 Daniel Baumann <daniel.baumann@open-infrastructure.net> + + * Releasing version 20180527. + + [ Daniel Baumann ] + * Calling commands without exec to make multiple commands in a row work properly. + * Updating documentation for multiple commands in a row. + * Calling shell in container enter command directly, replacing container-nsenter helper program. + * Correcting and simplifying nsenter call in container enter command. + * Clarify differences between container enter and console commands in manpages. + * Improving comment in procps configuration. + * Improving comment in systemd container-auto.service description. + * Updating author section in manpages. + * Adding missing command variable in some container commands. + * Setting dummy SSH_CLIENT variable during container enter to enable conditional shell prompts such as powerline. + * Correcting typo in verbose option handling of container remove command. + * Adding 'ALL' as pseudo container name for container start, stop, restart, and remove commands to act on all available container respectivly. + * Adding check in container create command to not create any container named 'ALL'. + 2018-05-03 Daniel Baumann <daniel.baumann@open-infrastructure.net> * Releasing version 20180503. diff --git a/VERSION.txt b/VERSION.txt index 9e4322f..3d0e1cf 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -20180503 +20180527 diff --git a/bin/container b/bin/container index 9634d05..849bbec 100755 --- a/bin/container +++ b/bin/container @@ -31,6 +31,7 @@ PARAMETER="${1}" if [ -z "${PARAMETER}" ] then echo "Usage: ${PROGRAM} COMMAND [OPTIONS]" >&2 + echo "Usage: ${PROGRAM} COMMAND1,COMMAND2,... [COMMON_OPTIONS]" >&2 exit 1 fi @@ -90,7 +91,7 @@ do fi # Run - exec "/usr/lib/${SOFTWARE}/${PROGRAM}/${COMMAND}" "${OPTIONS}" + "/usr/lib/${SOFTWARE}/${PROGRAM}/${COMMAND}" "${OPTIONS}" # Post hooks for FILE in "${HOOKS}/post-${PROGRAM}".* "${HOOKS}/${NAME}.post-${PROGRAM}" diff --git a/bin/container-nsenter b/bin/container-nsenter deleted file mode 100755 index a12bb0d..0000000 --- a/bin/container-nsenter +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh - -# container-tools - Manage systemd-nspawn containers -# Copyright (C) 2014-2018 Daniel Baumann <daniel.baumann@open-infrastructure.net> -# -# SPDX-License-Identifier: GPL-3.0+ -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -set -e - -# Run -script -c "/bin/bash -l" -q /dev/null 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" diff --git a/share/man/container-auto.1.txt b/share/man/container-auto.1.txt index 43713be..f1ab951 100644 --- a/share/man/container-auto.1.txt +++ b/share/man/container-auto.1.txt @@ -83,4 +83,4 @@ Debian specific bugs can also be reported in the Debian Bug Tracking System at h AUTHORS ------- -container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net>. +container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net> and others. diff --git a/share/man/container-console.1.txt b/share/man/container-console.1.txt index f327097..4ea8216 100644 --- a/share/man/container-console.1.txt +++ b/share/man/container-console.1.txt @@ -38,6 +38,9 @@ DESCRIPTION ----------- The container console command attaches a console to a container. +While 'container enter' bypasses the login prompt and drops to a root shell, +the 'container console' command shows a full login prompt where any valid user and password combination can be used. + OPTIONS ------- @@ -74,4 +77,4 @@ Debian specific bugs can also be reported in the Debian Bug Tracking System at h AUTHORS ------- -container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net>. +container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net> and others. diff --git a/share/man/container-create-curl.1.txt b/share/man/container-create-curl.1.txt index 543a261..6486c9b 100644 --- a/share/man/container-create-curl.1.txt +++ b/share/man/container-create-curl.1.txt @@ -127,4 +127,4 @@ Debian specific bugs can also be reported in the Debian Bug Tracking System at h AUTHORS ------- -container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net>. +container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net> and others. diff --git a/share/man/container-create-debconf.1.txt b/share/man/container-create-debconf.1.txt index db4028b..a86d964 100644 --- a/share/man/container-create-debconf.1.txt +++ b/share/man/container-create-debconf.1.txt @@ -153,4 +153,4 @@ Debian specific bugs can also be reported in the Debian Bug Tracking System at h AUTHORS ------- -container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net>. +container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net> and others. diff --git a/share/man/container-create-debootstrap.1.txt b/share/man/container-create-debootstrap.1.txt index 56d6f65..da578bd 100644 --- a/share/man/container-create-debootstrap.1.txt +++ b/share/man/container-create-debootstrap.1.txt @@ -95,4 +95,4 @@ Debian specific bugs can also be reported in the Debian Bug Tracking System at h AUTHORS ------- -container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net>. +container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net> and others. diff --git a/share/man/container-create.1.txt b/share/man/container-create.1.txt index d21bd58..4e88175 100644 --- a/share/man/container-create.1.txt +++ b/share/man/container-create.1.txt @@ -120,4 +120,4 @@ Debian specific bugs can also be reported in the Debian Bug Tracking System at h AUTHORS ------- -container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net>. +container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net> and others. diff --git a/share/man/container-enter.1.txt b/share/man/container-enter.1.txt index d200295..5051d74 100644 --- a/share/man/container-enter.1.txt +++ b/share/man/container-enter.1.txt @@ -38,6 +38,9 @@ DESCRIPTION ----------- The container enter enters a container namespace. +While 'container console' shows a full login prompt where any valid user and password combination can be used, +the 'container enter' command bypasses this and drops to a root shell. + OPTIONS ------- @@ -74,4 +77,4 @@ Debian specific bugs can also be reported in the Debian Bug Tracking System at h AUTHORS ------- -container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net>. +container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net> and others. diff --git a/share/man/container-key.1.txt b/share/man/container-key.1.txt index 0cd26b2..448bd56 100644 --- a/share/man/container-key.1.txt +++ b/share/man/container-key.1.txt @@ -84,4 +84,4 @@ Debian specific bugs can also be reported in the Debian Bug Tracking System at h AUTHORS ------- -container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net>. +container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net> and others. diff --git a/share/man/container-limit.1.txt b/share/man/container-limit.1.txt index 7af59e7..a36328a 100644 --- a/share/man/container-limit.1.txt +++ b/share/man/container-limit.1.txt @@ -107,4 +107,4 @@ Debian specific bugs can also be reported in the Debian Bug Tracking System at h AUTHORS ------- -container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net>. +container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net> and others. diff --git a/share/man/container-list.1.txt b/share/man/container-list.1.txt index 10f9ac3..8a018b0 100644 --- a/share/man/container-list.1.txt +++ b/share/man/container-list.1.txt @@ -124,4 +124,4 @@ Debian specific bugs can also be reported in the Debian Bug Tracking System at h AUTHORS ------- -container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net>. +container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net> and others. diff --git a/share/man/container-move.1.txt b/share/man/container-move.1.txt index 2f90433..172bd67 100644 --- a/share/man/container-move.1.txt +++ b/share/man/container-move.1.txt @@ -85,4 +85,4 @@ Debian specific bugs can also be reported in the Debian Bug Tracking System at h AUTHORS ------- -container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net>. +container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net> and others. diff --git a/share/man/container-remove.1.txt b/share/man/container-remove.1.txt index ab807f4..94d167b 100644 --- a/share/man/container-remove.1.txt +++ b/share/man/container-remove.1.txt @@ -46,7 +46,7 @@ OPTIONS The following container options are available: *-n, --name='NAME'*:: - Specify container name. + Specify container name. Specifying 'ALL' will remove all stopped container. *--allow-stop*:: Stop container prior removal. @@ -69,6 +69,9 @@ EXAMPLES *Remove a running container from the system, without prompt:*:: sudo container remove -n example.net -f --allow-stop +*Remove all container:*:: + sudo container remove -n ALL + SEE ALSO -------- @@ -91,4 +94,4 @@ Debian specific bugs can also be reported in the Debian Bug Tracking System at h AUTHORS ------- -container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net>. +container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net> and others. diff --git a/share/man/container-restart.1.txt b/share/man/container-restart.1.txt index 922bbe4..99b461d 100644 --- a/share/man/container-restart.1.txt +++ b/share/man/container-restart.1.txt @@ -44,7 +44,7 @@ OPTIONS The following container options are available: *-n, --name='NAME'*:: - Specify container name. + Specify container name. Specifying 'ALL' will restart all started container. EXAMPLES @@ -52,6 +52,9 @@ EXAMPLES *Restart example.net container:*:: sudo container restart -n example.net +*Restart all container:*:: + sudo container restart -n ALL + SEE ALSO -------- @@ -74,4 +77,4 @@ Debian specific bugs can also be reported in the Debian Bug Tracking System at h AUTHORS ------- -container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net>. +container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net> and others. diff --git a/share/man/container-shell.1.txt b/share/man/container-shell.1.txt index d36c93d..bd0f4e1 100644 --- a/share/man/container-shell.1.txt +++ b/share/man/container-shell.1.txt @@ -110,4 +110,4 @@ Debian specific bugs can also be reported in the Debian Bug Tracking System at h AUTHORS ------- -container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net>. +container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net> and others. diff --git a/share/man/container-start.1.txt b/share/man/container-start.1.txt index 8aa7d28..ae4ff89 100644 --- a/share/man/container-start.1.txt +++ b/share/man/container-start.1.txt @@ -44,7 +44,7 @@ OPTIONS The following container options are available: *-n, --name='NAME'*:: - Specify container name. + Specify container name. Specifying 'ALL' will start all stopped container. *-f, --force'*:: Removing stray lock file if existing. @@ -55,6 +55,9 @@ EXAMPLES *Start example.net container:*:: sudo container start -n example.net +*Start all container:*:: + sudo container start -n ALL + SEE ALSO -------- @@ -77,4 +80,4 @@ Debian specific bugs can also be reported in the Debian Bug Tracking System at h AUTHORS ------- -container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net>. +container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net> and others. diff --git a/share/man/container-status.1.txt b/share/man/container-status.1.txt index 2cfd28d..b403769 100644 --- a/share/man/container-status.1.txt +++ b/share/man/container-status.1.txt @@ -74,4 +74,4 @@ Debian specific bugs can also be reported in the Debian Bug Tracking System at h AUTHORS ------- -container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net>. +container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net> and others. diff --git a/share/man/container-stop.1.txt b/share/man/container-stop.1.txt index 22589be..ec169d8 100644 --- a/share/man/container-stop.1.txt +++ b/share/man/container-stop.1.txt @@ -44,7 +44,7 @@ OPTIONS The following container options are available: *-n, --name='NAME'*:: - Specify container name. + 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. @@ -58,6 +58,9 @@ EXAMPLES *Immediately stop example.net container:*:: sudo container stop -n example.net -f +*Stop all container:*:: + sudo container stop -n ALL + SEE ALSO -------- @@ -80,4 +83,4 @@ Debian specific bugs can also be reported in the Debian Bug Tracking System at h AUTHORS ------- -container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net>. +container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net> and others. diff --git a/share/man/container-tools.7.txt b/share/man/container-tools.7.txt index 1d17dec..8195ea4 100644 --- a/share/man/container-tools.7.txt +++ b/share/man/container-tools.7.txt @@ -131,4 +131,4 @@ LINKS AUTHORS ------- - * Daniel Baumann <daniel.baumann@open-infrastructure.net> +container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net> and others. diff --git a/share/man/container-top.1.txt b/share/man/container-top.1.txt index 93e83e8..2f99c5b 100644 --- a/share/man/container-top.1.txt +++ b/share/man/container-top.1.txt @@ -74,4 +74,4 @@ Debian specific bugs can also be reported in the Debian Bug Tracking System at h AUTHORS ------- -container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net>. +container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net> and others. diff --git a/share/man/container-version.1.txt b/share/man/container-version.1.txt index 170e3c4..19a1138 100644 --- a/share/man/container-version.1.txt +++ b/share/man/container-version.1.txt @@ -73,4 +73,4 @@ Debian specific bugs can also be reported in the Debian Bug Tracking System at h AUTHORS ------- -container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net>. +container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net> and others. diff --git a/share/man/container.1.txt b/share/man/container.1.txt index 5161154..5cc83f2 100644 --- a/share/man/container.1.txt +++ b/share/man/container.1.txt @@ -145,4 +145,4 @@ Debian specific bugs can also be reported in the Debian Bug Tracking System at h AUTHORS ------- -container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net>. +container-tools was written by Daniel Baumann <daniel.baumann@open-infrastructure.net> and others. diff --git a/share/procps/zz-container-tools.conf b/share/procps/zz-container-tools.conf index 2396dfc..8b15f11 100644 --- a/share/procps/zz-container-tools.conf +++ b/share/procps/zz-container-tools.conf @@ -1,6 +1,7 @@ -# The default limits are set to small and eventually lead to errors like -# the following on container start: -# Failed to allocate directory watch: Too many open files +# The default limits are set to low for running many containers +# and eventually lead to errors like the following on container start: +# +# Failed to allocate directory watch: Too many open files # /proc/sys/fs/inotify/max_queued_events defaults to 16384 fs.inotify.max_queued_events=1048576 diff --git a/share/systemd/container-auto.service b/share/systemd/container-auto.service index b3384df..99decf6 100644 --- a/share/systemd/container-auto.service +++ b/share/systemd/container-auto.service @@ -1,5 +1,5 @@ [Unit] -Description=container-tools automatic start +Description=container-tools automatic start and stop Documentation=man:container-auto After=network.target |