summaryrefslogtreecommitdiffstats
path: root/lib/container/restart
diff options
context:
space:
mode:
Diffstat (limited to 'lib/container/restart')
-rwxr-xr-xlib/container/restart35
1 files changed, 24 insertions, 11 deletions
diff --git a/lib/container/restart b/lib/container/restart
index f78cfff..3c84f4d 100755
--- a/lib/container/restart
+++ b/lib/container/restart
@@ -1,6 +1,6 @@
#!/bin/sh
-# Copyright (C) 2014-2020 Daniel Baumann <daniel.baumann@open-infrastructure.net>
+# Copyright (C) 2014-2021 Daniel Baumann <daniel.baumann@open-infrastructure.net>
#
# SPDX-License-Identifier: GPL-3.0+
#
@@ -30,8 +30,8 @@ Parameters ()
{
OPTIONS_ALL=""
- GETOPT_LONGOPTIONS="name:,"
- GETOPT_OPTIONS="n:,"
+ GETOPT_LONGOPTIONS="name:,verbose,"
+ GETOPT_OPTIONS="n:,v,"
PARAMETERS="$(getopt --longoptions ${GETOPT_LONGOPTIONS} --name=${COMMAND} --options ${GETOPT_OPTIONS} --shell sh -- ${@})"
@@ -51,6 +51,13 @@ Parameters ()
shift 2
;;
+ -v|--verbose)
+ VERBOSE="true"
+ shift 1
+
+ OPTIONS_ALL="${OPTIONS_ALL} --verbose"
+ ;;
+
--)
shift 1
break
@@ -66,7 +73,7 @@ Parameters ()
Usage ()
{
- echo "Usage: ${PROGRAM} ${COMMAND} -n|--name NAME" >&2
+ echo "Usage: ${PROGRAM} ${COMMAND} -n|--name NAME [-v|--verbose]" >&2
exit 1
}
@@ -83,13 +90,7 @@ case "${NAME}" in
for NAME in ${NAMES}
do
- case "${VERBOSE}" in
- true)
- echo "Restarting container ${NAME}..."
- ;;
- esac
-
- ${PROGRAM} restart --name ${NAME} || true
+ ${PROGRAM} restart --name ${NAME} ${OPTIONS_ALL} || true
done
exit 0
@@ -112,8 +113,20 @@ do
done
# Run
+case "${VERBOSE}" in
+ true)
+ echo -n "Restarting container ${NAME}..."
+ ;;
+esac
+
machinectl reboot ${NAME}
+case "${VERBOSE}" in
+ true)
+ echo " done."
+ ;;
+esac
+
# Post hooks
for FILE in "${HOOKS}/post-${COMMAND}".* "${HOOKS}/${NAME}.post-${COMMAND}"
do