diff --git a/cluster/apt.check.update.sh b/cluster/apt.check.update.sh index 3c6c329..6382eb0 100755 --- a/cluster/apt.check.update.sh +++ b/cluster/apt.check.update.sh @@ -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,32 +152,30 @@ 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}" \ - && sh "${sge_disable_host_queue_script}" \ - && exit 0 - ## }}} + || exit 0 + fi + ## }}} - ## 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 - ## }}} - - } + ## If APT package upgrade is available {{{ + ### Disable SGE queue + ### AND Exit + is_apt_upgrade_present \ + && sh "${sge_disable_host_queue_script}" \ + && 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