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
[ -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
### }}}
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
}
# }}}
@ -281,6 +305,10 @@ if [ ! "${NBARGS}" -eq "0" ]; then
## Only display messages
SIMULATE_MODE=0
;;
-u|--urgent ) ## Urgent upgrade only
## Check only for urgent upgrade
URGENT_ONLY_MODE=0
;;
-- ) ## End of options list
## End the while loop
break