Add EMPTY_ONLY_MODE (exit if slots not empty)

This commit is contained in:
Jeremy Gardais 2020-12-03 12:49:55 +01:00
parent 06f7dadcd8
commit 4e87760e43
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 24 additions and 20 deletions

View File

@ -29,7 +29,7 @@ readonly COLOR_DEBUG="${PURPLE}"
usage() { # {{{
cat <<- EOF
usage: $PROGNAME [-d|-h|-t]
usage: $PROGNAME [-d|-e|-h|-t]
Verify if any APT package upgrade is available and
try to prepare the host by:
@ -43,6 +43,9 @@ OPTIONS:
-d,--debug
Enable debug messages.
-e,--empty
Check APT upgrades only if SGE slots are empty
-h,--help
Print this help message.
EOF
@ -149,33 +152,31 @@ main() { # {{{
## If NO APT package upgrade is available {{{
### Ensure to remove any temp file related to APT upgrades
### Exit
### AND Exit
is_apt_upgrade_absent \
&& rm -f -- "${APT_TMP_FILE}" \
&& exit 0
## }}}
## If APT package upgrade(s) is available AND
is_apt_upgrade_present \
&& {
## If SGE used slots is NULL {{{
## APT package upgrade is available
### Create a temp file
### Disable SGE queue
## If EMPTY_ONLY_MODE is set {{{
### Verify empty slots
### OR Exit
if [ "${EMPTY_ONLY_MODE}" -eq "0" ]; then
### If SGE slots are not empty
### Exit
is_sge_slots_empty \
&& touch "${APT_TMP_FILE}" && echo "APT upgrade is available." >> "${APT_TMP_FILE}" \
|| exit 0
fi
## }}}
## If APT package upgrade is available {{{
### Disable SGE queue
### AND Exit
is_apt_upgrade_present \
&& sh "${sge_disable_host_queue_script}" \
&& exit 0
## }}}
## After all just add content to a temp file (+1 attempt) {{{
touch "${APT_TMP_FILE}" && echo "APT upgrade is available." >> "${APT_TMP_FILE}" \
&& debug_message "main Add content to temp file for pending upgrade(s)." \
&& exit 0
## }}}
}
}
# }}}
@ -204,6 +205,9 @@ if [ ! "${NBARGS}" -eq "0" ]; then
-d|--debug ) ## debug
DEBUG=0
;;
-e|--empty ) ## Empty only mode
EMPTY_ONLY_MODE=0
;;
-h|--help ) ## help
usage
## Exit after help informations