Add possibility to check for urgent upgrade only

This commit is contained in:
Jeremy Gardais 2020-11-30 15:48:25 +01:00
parent 2036f081fe
commit ab742e8295
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 41 additions and 13 deletions

View File

@ -26,6 +26,9 @@ export OUTPUT_MESSAGE
# If modifications should be applied # If modifications should be applied
[ -z "${SIMULATE_MODE}" ] && SIMULATE_MODE=1 [ -z "${SIMULATE_MODE}" ] && SIMULATE_MODE=1
# If only urgent upgrade should be checked
[ -z "${URGENT_ONLY_MODE}" ] && URGENT_ONLY_MODE=1
## Colors ## Colors
readonly PURPLE='\033[1;35m' readonly PURPLE='\033[1;35m'
readonly RED='\033[0;31m' readonly RED='\033[0;31m'
@ -42,7 +45,7 @@ readonly MACO_TMP_URGENT_FILE="/tmp/.maco.urgent.upgrade"
usage() { # {{{ usage() { # {{{
cat <<- EOF 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 Compare current version of Maco script with the latest and
the urgent versions then try to prepare the host by: the urgent versions then try to prepare the host by:
@ -52,6 +55,9 @@ EXAMPLES:
- Verify Maco's upgrade and prepare the current host - Verify Maco's upgrade and prepare the current host
${PROGNAME} ${PROGNAME}
- Verify only urgent upgrade for Maco and prepare the current host
${PROGNAME} --urgent
OPTIONS: OPTIONS:
-d,--debug -d,--debug
Enable debug messages. Enable debug messages.
@ -59,11 +65,14 @@ OPTIONS:
-h,--help -h,--help
Print this help message. Print this help message.
-q,--quiet
Disable messages on standard output (except for error).
-s,--simulate -s,--simulate
Only display messages and don't manage temp files. Only display messages and don't manage temp files.
-q,--quiet -u,--urgent
Disable messages on standard output (except for error). Check only for urgent upgrade.
EOF EOF
@ -242,13 +251,28 @@ main() { # {{{
is_maco_uptodate \ is_maco_uptodate \
&& exit 0 && exit 0
is_maco_upgrade_require \ ## If URGENT_ONLY_MODE is set
&& prepare_host_for_upgrade \ if [ "${URGENT_ONLY_MODE}" -eq "0" ]; then
&& exit 0 ### Check only for urgent upgrade {{{
is_maco_urgent_upgrade_require \
&& prepare_host_for_upgrade \
&& exit 0
### }}}
is_maco_urgent_upgrade_require \ else
&& prepare_host_for_upgrade \ ### Check for latest upgrade {{{
&& exit 0 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 while printf -- '%s' "${1}" | grep -q -E -- "^-+"; do
case "${1}" in case "${1}" in
-h|--help ) ## help -h|--help ) ## help
usage usage
## Exit after help informations ## Exit after help informations
exit 0 exit 0
;; ;;
-d|--debug ) ## debug -d|--debug ) ## debug
DEBUG=0 DEBUG=0
## Re-export new DEBUG value ## Re-export new DEBUG value
export DEBUG export DEBUG
;; ;;
-q|--quiet ) ## Silent mode -q|--quiet ) ## Silent mode
## Avoid to display any message on standard output ## Avoid to display any message on standard output
OUTPUT_MESSAGE=1 OUTPUT_MESSAGE=1
;; ;;
@ -281,7 +305,11 @@ if [ ! "${NBARGS}" -eq "0" ]; then
## Only display messages ## Only display messages
SIMULATE_MODE=0 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 ## End the while loop
break break
;; ;;