From 2ac0de9343e94682fecfcf6d96ead1b0fc40e443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Mon, 22 Jun 2020 14:20:45 +0200 Subject: [PATCH] Add --hostname option --- cluster/sge.enable.host.queue.sh | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/cluster/sge.enable.host.queue.sh b/cluster/sge.enable.host.queue.sh index b35a725..2816ed5 100755 --- a/cluster/sge.enable.host.queue.sh +++ b/cluster/sge.enable.host.queue.sh @@ -31,7 +31,7 @@ readonly COLOR_DEBUG="${PURPLE}" usage() { # {{{ cat <<- EOF -usage: $PROGNAME [--help|-d,--debug|-q,--quiet] [hostname] +usage: $PROGNAME [--help] [-d|-h|-q] [hostname] Try to enable all SGE queues of the current host (default), if no pending upgrades (Maco, APT) are present, @@ -43,13 +43,17 @@ EXAMPLES : - Enable SGE's queue(s) of "marvin.domain.tld" host ${PROGNAME} marvin.domain.tld + ${PROGNAME} -h marvin.domain.tld OPTIONS : + -d,--debug + Enable debug messages. + --help Print this help message. - -d,--debug - Enable debug messages. + -h,--host,--hostname SGE_HOST_TO_MANAGE + Manage SGE's queue(s) of "SGE_HOST_TO_MANAGE" host. -q,--quiet Disable messages on standard output (except for error). @@ -309,7 +313,7 @@ if [ ! "${NBARGS}" -eq "0" ]; then ## No way to monitor pending upgrades on a remote host CHECK_UPGRADE="1" - ## Switch to next arg + ## Switch to the next argument shift manage_arg=$((manage_arg+1)) else @@ -321,23 +325,29 @@ if [ ! "${NBARGS}" -eq "0" ]; then while printf -- '%s' "${1}" | grep -q -E -- "^-*"; do case "${1}" in - --help ) ## help + -d|--debug ) ## debug + DEBUG=0 + ;; + --help ) ## help usage ## Exit after help informations exit 0 ;; - -d|--debug ) ## debug - DEBUG=0 + -h|--host|--hostname ) ## Specify a different host to manage + ## Move to the next argument + shift + ## Override previous definition of sge_hostname + sge_hostname="${1}" ;; - -q|--quiet ) ## Silent mode + -q|--quiet ) ## Silent mode ## Avoid to display any message on standard output OUTPUT_MESSAGE=1 ;; - -- ) ## End of options list + -- ) ## End of options list ## End the while loop break ;; - * ) ## unknow option + * ) ## unknow option printf '%b\n' "${RED}Invalid option: ${1}${RESET}" printf '%b\n' "---" usage @@ -348,7 +358,7 @@ if [ ! "${NBARGS}" -eq "0" ]; then debug_message "Arguments management − \ ${RED}${1}${COLOR_DEBUG} option managed." - ## Next arg + ## Move to the next argument shift manage_arg=$((manage_arg+1))