From 9005f8a27ffc7bff682b0e627eeaa76ef5bf95fb Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 30 Oct 2020 17:37:56 +0100 Subject: Cleaning up and harmonizing verbose output for container remove, restart, start, and stop commands. Signed-off-by: Daniel Baumann --- lib/container/restart | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'lib/container/restart') diff --git a/lib/container/restart b/lib/container/restart index f78cfff..83859e2 100755 --- a/lib/container/restart +++ b/lib/container/restart @@ -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 -- cgit v1.2.3