Add --hostname option

This commit is contained in:
Jeremy Gardais 2020-06-22 14:20:45 +02:00
parent 04946977d9
commit 2ac0de9343
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 21 additions and 11 deletions

View File

@ -31,7 +31,7 @@ readonly COLOR_DEBUG="${PURPLE}"
usage() { # {{{ usage() { # {{{
cat <<- EOF 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), Try to enable all SGE queues of the current host (default),
if no pending upgrades (Maco, APT) are present, if no pending upgrades (Maco, APT) are present,
@ -43,13 +43,17 @@ EXAMPLES:
- Enable SGE's queue(s) of "marvin.domain.tld" host - Enable SGE's queue(s) of "marvin.domain.tld" host
${PROGNAME} marvin.domain.tld ${PROGNAME} marvin.domain.tld
${PROGNAME} -h marvin.domain.tld
OPTIONS: OPTIONS:
-d,--debug
Enable debug messages.
--help --help
Print this help message. Print this help message.
-d,--debug -h,--host,--hostname SGE_HOST_TO_MANAGE
Enable debug messages. Manage SGE's queue(s) of "SGE_HOST_TO_MANAGE" host.
-q,--quiet -q,--quiet
Disable messages on standard output (except for error). 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 ## No way to monitor pending upgrades on a remote host
CHECK_UPGRADE="1" CHECK_UPGRADE="1"
## Switch to next arg ## Switch to the next argument
shift shift
manage_arg=$((manage_arg+1)) manage_arg=$((manage_arg+1))
else else
@ -321,23 +325,29 @@ if [ ! "${NBARGS}" -eq "0" ]; then
while printf -- '%s' "${1}" | grep -q -E -- "^-*"; do while printf -- '%s' "${1}" | grep -q -E -- "^-*"; do
case "${1}" in case "${1}" in
--help ) ## help -d|--debug ) ## debug
DEBUG=0
;;
--help ) ## help
usage usage
## Exit after help informations ## Exit after help informations
exit 0 exit 0
;; ;;
-d|--debug ) ## debug -h|--host|--hostname ) ## Specify a different host to manage
DEBUG=0 ## 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 ## Avoid to display any message on standard output
OUTPUT_MESSAGE=1 OUTPUT_MESSAGE=1
;; ;;
-- ) ## End of options list -- ) ## End of options list
## End the while loop ## End the while loop
break break
;; ;;
* ) ## unknow option * ) ## unknow option
printf '%b\n' "${RED}Invalid option: ${1}${RESET}" printf '%b\n' "${RED}Invalid option: ${1}${RESET}"
printf '%b\n' "---" printf '%b\n' "---"
usage usage
@ -348,7 +358,7 @@ if [ ! "${NBARGS}" -eq "0" ]; then
debug_message "Arguments management \ debug_message "Arguments management \
${RED}${1}${COLOR_DEBUG} option managed." ${RED}${1}${COLOR_DEBUG} option managed."
## Next arg ## Move to the next argument
shift shift
manage_arg=$((manage_arg+1)) manage_arg=$((manage_arg+1))