From ab742e8295028edf923eb986ee44deab242f51f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Mon, 30 Nov 2020 15:48:25 +0100 Subject: [PATCH] Add possibility to check for urgent upgrade only --- cluster/maco.check.update.sh | 54 +++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/cluster/maco.check.update.sh b/cluster/maco.check.update.sh index 55d5c22..24552d2 100755 --- a/cluster/maco.check.update.sh +++ b/cluster/maco.check.update.sh @@ -26,6 +26,9 @@ export OUTPUT_MESSAGE # If modifications should be applied [ -z "${SIMULATE_MODE}" ] && SIMULATE_MODE=1 +# If only urgent upgrade should be checked +[ -z "${URGENT_ONLY_MODE}" ] && URGENT_ONLY_MODE=1 + ## Colors readonly PURPLE='\033[1;35m' readonly RED='\033[0;31m' @@ -42,7 +45,7 @@ readonly MACO_TMP_URGENT_FILE="/tmp/.maco.urgent.upgrade" usage() { # {{{ cat <<- EOF -usage: $PROGNAME [-d|-h|-s|-q] +usage: $PROGNAME [-d|-h|-q|-s|-u] Compare current version of Maco script with the latest and the urgent versions then try to prepare the host by: @@ -52,6 +55,9 @@ EXAMPLES: - Verify Maco's upgrade and prepare the current host ${PROGNAME} + - Verify only urgent upgrade for Maco and prepare the current host + ${PROGNAME} --urgent + OPTIONS : -d,--debug Enable debug messages. @@ -59,11 +65,14 @@ OPTIONS : -h,--help Print this help message. + -q,--quiet + Disable messages on standard output (except for error). + -s,--simulate Only display messages and don't manage temp files. - -q,--quiet - Disable messages on standard output (except for error). + -u,--urgent + Check only for urgent upgrade. EOF @@ -242,13 +251,28 @@ main() { # {{{ is_maco_uptodate \ && exit 0 - is_maco_upgrade_require \ - && prepare_host_for_upgrade \ - && exit 0 + ## If URGENT_ONLY_MODE is set + if [ "${URGENT_ONLY_MODE}" -eq "0" ]; then + ### Check only for urgent upgrade {{{ + is_maco_urgent_upgrade_require \ + && prepare_host_for_upgrade \ + && exit 0 + ### }}} - is_maco_urgent_upgrade_require \ - && prepare_host_for_upgrade \ - && exit 0 + else + ### Check for latest upgrade {{{ + is_maco_upgrade_require \ + && prepare_host_for_upgrade \ + && exit 0 + ### }}} + + ### Check for urgent upgrade {{{ + is_maco_urgent_upgrade_require \ + && prepare_host_for_upgrade \ + && exit 0 + ### }}} + + fi } # }}} @@ -263,17 +287,17 @@ if [ ! "${NBARGS}" -eq "0" ]; then while printf -- '%s' "${1}" | grep -q -E -- "^-+"; do case "${1}" in - -h|--help ) ## help + -h|--help ) ## help usage ## Exit after help informations exit 0 ;; - -d|--debug ) ## debug + -d|--debug ) ## debug DEBUG=0 ## Re-export new DEBUG value export DEBUG ;; - -q|--quiet ) ## Silent mode + -q|--quiet ) ## Silent mode ## Avoid to display any message on standard output OUTPUT_MESSAGE=1 ;; @@ -281,7 +305,11 @@ if [ ! "${NBARGS}" -eq "0" ]; then ## Only display messages SIMULATE_MODE=0 ;; - -- ) ## End of options list + -u|--urgent ) ## Urgent upgrade only + ## Check only for urgent upgrade + URGENT_ONLY_MODE=0 + ;; + -- ) ## End of options list ## End the while loop break ;;