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() { # {{{
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))