From 6dfbd8d9b0b55ebe052f91ae5823d8108799983a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 18 Feb 2018 16:12:38 +0100 Subject: Merging upstream version 20180218. Signed-off-by: Daniel Baumann --- lib/container/auto | 2 +- lib/container/console | 2 +- lib/container/create | 2 +- lib/container/enter | 2 +- lib/container/key | 2 +- lib/container/limit | 2 +- lib/container/list | 2 +- lib/container/move | 2 +- lib/container/remove | 24 +++++++++++++++++++----- lib/container/restart | 2 +- lib/container/start | 2 +- lib/container/stop | 2 +- lib/container/top | 2 +- lib/container/version | 2 +- 14 files changed, 32 insertions(+), 18 deletions(-) (limited to 'lib') diff --git a/lib/container/auto b/lib/container/auto index 9bdd484..8477915 100755 --- a/lib/container/auto +++ b/lib/container/auto @@ -1,7 +1,7 @@ #!/bin/sh # container-tools - Manage systemd-nspawn containers -# Copyright (C) 2014-2017 Daniel Baumann +# Copyright (C) 2014-2018 Daniel Baumann # # SPDX-License-Identifier: GPL-3.0+ # diff --git a/lib/container/console b/lib/container/console index 9ec3db8..dfc9b5c 100755 --- a/lib/container/console +++ b/lib/container/console @@ -1,7 +1,7 @@ #!/bin/sh # container-tools - Manage systemd-nspawn containers -# Copyright (C) 2014-2017 Daniel Baumann +# Copyright (C) 2014-2018 Daniel Baumann # # SPDX-License-Identifier: GPL-3.0+ # diff --git a/lib/container/create b/lib/container/create index 6f9a240..5878e7e 100755 --- a/lib/container/create +++ b/lib/container/create @@ -1,7 +1,7 @@ #!/bin/sh # container-tools - Manage systemd-nspawn containers -# Copyright (C) 2014-2017 Daniel Baumann +# Copyright (C) 2014-2018 Daniel Baumann # # SPDX-License-Identifier: GPL-3.0+ # diff --git a/lib/container/enter b/lib/container/enter index e52a8e1..faf5d35 100755 --- a/lib/container/enter +++ b/lib/container/enter @@ -1,7 +1,7 @@ #!/bin/sh # container-tools - Manage systemd-nspawn containers -# Copyright (C) 2014-2017 Daniel Baumann +# Copyright (C) 2014-2018 Daniel Baumann # # SPDX-License-Identifier: GPL-3.0+ # diff --git a/lib/container/key b/lib/container/key index 8a73ae1..3f0f57b 100755 --- a/lib/container/key +++ b/lib/container/key @@ -1,7 +1,7 @@ #!/bin/sh # container-tools - Manage systemd-nspawn containers -# Copyright (C) 2014-2017 Daniel Baumann +# Copyright (C) 2014-2018 Daniel Baumann # # SPDX-License-Identifier: GPL-3.0+ # diff --git a/lib/container/limit b/lib/container/limit index 71d874f..f2d6bfa 100755 --- a/lib/container/limit +++ b/lib/container/limit @@ -1,7 +1,7 @@ #!/bin/sh # container-tools - Manage systemd-nspawn containers -# Copyright (C) 2014-2017 Daniel Baumann +# Copyright (C) 2014-2018 Daniel Baumann # # SPDX-License-Identifier: GPL-3.0+ # diff --git a/lib/container/list b/lib/container/list index 00eebd1..6fa9eed 100755 --- a/lib/container/list +++ b/lib/container/list @@ -1,7 +1,7 @@ #!/bin/sh # container-tools - Manage systemd-nspawn containers -# Copyright (C) 2014-2017 Daniel Baumann +# Copyright (C) 2014-2018 Daniel Baumann # # SPDX-License-Identifier: GPL-3.0+ # diff --git a/lib/container/move b/lib/container/move index af17b35..e533b0e 100755 --- a/lib/container/move +++ b/lib/container/move @@ -1,7 +1,7 @@ #!/bin/sh # container-tools - Manage systemd-nspawn containers -# Copyright (C) 2014-2017 Daniel Baumann +# Copyright (C) 2014-2018 Daniel Baumann # # SPDX-License-Identifier: GPL-3.0+ # diff --git a/lib/container/remove b/lib/container/remove index 6310597..e8dd653 100755 --- a/lib/container/remove +++ b/lib/container/remove @@ -1,7 +1,7 @@ #!/bin/sh # container-tools - Manage systemd-nspawn containers -# Copyright (C) 2014-2017 Daniel Baumann +# Copyright (C) 2014-2018 Daniel Baumann # # SPDX-License-Identifier: GPL-3.0+ # @@ -28,7 +28,7 @@ MACHINES="/var/lib/machines" Parameters () { - GETOPT_LONGOPTIONS="name:,force,verbose," + GETOPT_LONGOPTIONS="name:,allow-stop,force,verbose," GETOPT_OPTIONS="n:,f,v," PARAMETERS="$(getopt --longoptions ${GETOPT_LONGOPTIONS} --name=${COMMAND} --options ${GETOPT_OPTIONS} --shell sh -- ${@})" @@ -49,6 +49,11 @@ Parameters () shift 2 ;; + --allow-stop) + ALLOW_STOP="true" + shift 1 + ;; + -f|--force) FORCE="true" shift 1 @@ -74,7 +79,7 @@ Parameters () Usage () { - echo "Usage: container ${COMMAND} -n|--name NAME [-f|--force] [-v|--verbose]" >&2 + echo "Usage: container ${COMMAND} -n|--name NAME [--allow-stop] [-f|--force] [-v|--verbose]" >&2 exit 1 } @@ -116,8 +121,17 @@ STATE="$(machinectl show ${NAME} 2>&1 | awk -F= '/^State=/ { print $2 }')" case "${STATE}" in running) - echo "'${NAME}': container is started" >&2 - exit 1 + case "${ALLOW_STOP}" in + true) + echo "'${NAME}': container is started, stopping it now" >&2 + container stop -n ${NAME} + ;; + + *) + echo "'${NAME}': container is started" >&2 + exit 1 + ;; + esac ;; esac diff --git a/lib/container/restart b/lib/container/restart index db7811e..a507cc0 100755 --- a/lib/container/restart +++ b/lib/container/restart @@ -1,7 +1,7 @@ #!/bin/sh # container-tools - Manage systemd-nspawn containers -# Copyright (C) 2014-2017 Daniel Baumann +# Copyright (C) 2014-2018 Daniel Baumann # # SPDX-License-Identifier: GPL-3.0+ # diff --git a/lib/container/start b/lib/container/start index ca88af2..e4b2ee6 100755 --- a/lib/container/start +++ b/lib/container/start @@ -1,7 +1,7 @@ #!/bin/sh # container-tools - Manage systemd-nspawn containers -# Copyright (C) 2014-2017 Daniel Baumann +# Copyright (C) 2014-2018 Daniel Baumann # # SPDX-License-Identifier: GPL-3.0+ # diff --git a/lib/container/stop b/lib/container/stop index f6618d5..5099005 100755 --- a/lib/container/stop +++ b/lib/container/stop @@ -1,7 +1,7 @@ #!/bin/sh # container-tools - Manage systemd-nspawn containers -# Copyright (C) 2014-2017 Daniel Baumann +# Copyright (C) 2014-2018 Daniel Baumann # # SPDX-License-Identifier: GPL-3.0+ # diff --git a/lib/container/top b/lib/container/top index 47725ff..22a224a 100755 --- a/lib/container/top +++ b/lib/container/top @@ -1,7 +1,7 @@ #!/bin/sh # container-tools - Manage systemd-nspawn containers -# Copyright (C) 2014-2017 Daniel Baumann +# Copyright (C) 2014-2018 Daniel Baumann # # SPDX-License-Identifier: GPL-3.0+ # diff --git a/lib/container/version b/lib/container/version index 9f0afd1..fe42216 100755 --- a/lib/container/version +++ b/lib/container/version @@ -1,7 +1,7 @@ #!/bin/sh # container-tools - Manage systemd-nspawn containers -# Copyright (C) 2014-2017 Daniel Baumann +# Copyright (C) 2014-2018 Daniel Baumann # # SPDX-License-Identifier: GPL-3.0+ # -- cgit v1.2.3