Add message on stdout and quiet mode
This commit is contained in:
parent
baab6c28a4
commit
04946977d9
|
@ -8,6 +8,9 @@ readonly NBARGS="${#}"
|
||||||
## Test if DEBUG is already defined (by parent script,…)
|
## Test if DEBUG is already defined (by parent script,…)
|
||||||
[ -z "${DEBUG}" ] && DEBUG=1
|
[ -z "${DEBUG}" ] && DEBUG=1
|
||||||
|
|
||||||
|
# If output message should be displayed
|
||||||
|
[ -z "${OUTPUT_MESSAGE}" ] && OUTPUT_MESSAGE=0
|
||||||
|
|
||||||
# Maco temp file
|
# Maco temp file
|
||||||
readonly MACO_TMP_FILE="/tmp/.maco.upgrade"
|
readonly MACO_TMP_FILE="/tmp/.maco.upgrade"
|
||||||
readonly MACO_TMP_URGENT_FILE="/tmp/.maco.urgent.upgrade"
|
readonly MACO_TMP_URGENT_FILE="/tmp/.maco.urgent.upgrade"
|
||||||
|
@ -28,10 +31,11 @@ readonly COLOR_DEBUG="${PURPLE}"
|
||||||
usage() { # {{{
|
usage() { # {{{
|
||||||
|
|
||||||
cat <<- EOF
|
cat <<- EOF
|
||||||
usage: $PROGNAME [--help|-d,--debug] [hostname]
|
usage: $PROGNAME [--help|-d,--debug|-q,--quiet] [hostname]
|
||||||
|
|
||||||
Try to enable all SGE queues of the current host (default)
|
Try to enable all SGE queues of the current host (default),
|
||||||
or the one passed as first argument.
|
if no pending upgrades (Maco, APT) are present,
|
||||||
|
or to the one passed as first argument (no upgrades checking).
|
||||||
|
|
||||||
EXAMPLES :
|
EXAMPLES :
|
||||||
- Enable SGE's queue(s) of the current host
|
- Enable SGE's queue(s) of the current host
|
||||||
|
@ -39,6 +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
|
||||||
|
|
||||||
|
OPTIONS :
|
||||||
|
--help
|
||||||
|
Print this help message.
|
||||||
|
|
||||||
|
-d,--debug
|
||||||
|
Enable debug messages.
|
||||||
|
|
||||||
|
-q,--quiet
|
||||||
|
Disable messages on standard output (except for error).
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -50,6 +65,17 @@ debug_message() { # {{{
|
||||||
## Print message if DEBUG is enable (=0)
|
## Print message if DEBUG is enable (=0)
|
||||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6b\e[m\n' "DEBUG − ${PROGNAME} : ${local_debug_message}"
|
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6b\e[m\n' "DEBUG − ${PROGNAME} : ${local_debug_message}"
|
||||||
|
|
||||||
|
}
|
||||||
|
# }}}
|
||||||
|
message() { # {{{
|
||||||
|
|
||||||
|
local_message="${1}"
|
||||||
|
|
||||||
|
## Print message if OUTPUT_MESSAGE is enable (=0)
|
||||||
|
[ "${OUTPUT_MESSAGE}" -eq "0" ] && printf '%b\n' "${local_message}"
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
is_apt_upgrade_present() { # {{{
|
is_apt_upgrade_present() { # {{{
|
||||||
|
@ -208,7 +234,7 @@ Try to enable SGE queue: ${RED}${local_sge_queue_name:=/dev/null}@${local_sge_ho
|
||||||
qmod --enable "${local_sge_queue_name}@${local_sge_hostname}" \
|
qmod --enable "${local_sge_queue_name}@${local_sge_hostname}" \
|
||||||
&& return_enable_queue="${?}"
|
&& return_enable_queue="${?}"
|
||||||
else
|
else
|
||||||
debug_message "SGE queue: ${RED}${local_sge_queue_name:=/dev/null}@${local_sge_hostname:=/dev/null}${RESET} was manually disabled, please re-enable it ${RED}manually${RESET}."
|
message "SGE queue: ${RED}${local_sge_queue_name:=/dev/null}@${local_sge_hostname:=/dev/null}${RESET} was manually disabled, please re-enable it ${RED}manually${RESET}."
|
||||||
return_enable_queue="1"
|
return_enable_queue="1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -302,8 +328,10 @@ if [ ! "${NBARGS}" -eq "0" ]; then
|
||||||
;;
|
;;
|
||||||
-d|--debug ) ## debug
|
-d|--debug ) ## debug
|
||||||
DEBUG=0
|
DEBUG=0
|
||||||
## Re-export new DEBUG value
|
;;
|
||||||
export DEBUG
|
-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
|
## End the while loop
|
||||||
|
|
Loading…
Reference in New Issue