Refactor CHECK_UPGRADE

This commit is contained in:
Jeremy Gardais 2020-06-22 20:46:37 +02:00
parent de494b76c1
commit ce8cf73b0e
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 28 additions and 32 deletions

View File

@ -145,18 +145,15 @@ is_apt_upgrade_present() { # {{{
## No pending upgrade by default ## No pending upgrade by default
return_apt_upgrade_present="1" return_apt_upgrade_present="1"
## If we need to watch for upgrades ### Check if temp APT upgrade file exists
if [ "${CHECK_UPGRADE}" -eq "0" ]; then if [ -f "${APT_TMP_FILE}" ]; then
### Check if temp APT upgrade file exists return_apt_upgrade_present="0"
if [ -f "${APT_TMP_FILE}" ]; then debug_message "is_apt_upgrade_absent \
return_apt_upgrade_present="0"
debug_message "is_apt_upgrade_absent \
APT upgrade seems available for this system." APT upgrade seems available for this system."
else else
return_apt_upgrade_present="1" return_apt_upgrade_present="1"
debug_message "is_apt_upgrade_absent \ debug_message "is_apt_upgrade_absent \
NO APT upgrade available for this system." NO APT upgrade available for this system."
fi
fi fi
return "${return_apt_upgrade_present}" return "${return_apt_upgrade_present}"
@ -168,23 +165,20 @@ is_maco_upgrade_present() { # {{{
## No pending upgrades by default ## No pending upgrades by default
return_maco_upgrade_present="1" return_maco_upgrade_present="1"
## If we need to watch for upgrades ## Check if temp Maco upgrade file is present
if [ "${CHECK_UPGRADE}" -eq "0" ]; then if [ -f "${MACO_TMP_FILE}" ]; then
## Check if temp Maco upgrade file is present return_maco_upgrade_present="0"
if [ -f "${MACO_TMP_FILE}" ]; then debug_message "is_maco_upgrade_present \
return_maco_upgrade_present="0"
debug_message "is_maco_upgrade_present \
Maco upgrade seems available." Maco upgrade seems available."
## Check if temp Maco urgent upgrade file is present ## Check if temp Maco urgent upgrade file is present
elif [ -f "${MACO_TMP_URGENT_FILE}" ]; then elif [ -f "${MACO_TMP_URGENT_FILE}" ]; then
return_maco_upgrade_present="0" return_maco_upgrade_present="0"
debug_message "is_maco_upgrade_present \ debug_message "is_maco_upgrade_present \
Maco urgent upgrade seems available." Maco urgent upgrade seems available."
else else
debug_message "is_maco_upgrade_present \ debug_message "is_maco_upgrade_present \
No Maco upgrade require." No Maco upgrade require."
fi
fi fi
return "${return_maco_upgrade_present}" return "${return_maco_upgrade_present}"
@ -310,16 +304,18 @@ main() { # {{{
## Define all vars according the selected options ## Define all vars according the selected options
define_vars define_vars
## If APT package upgrade is available ## If we need to watch for upgrades
### Exit (wait for APT upgrade to be applied) if [ "${CHECK_UPGRADE}" -eq "0" ]; then
is_apt_upgrade_present \ ## If APT package upgrade is available
&& exit 0 ### Exit (wait for APT upgrade to be applied)
is_apt_upgrade_present \
## If Maco upgrade is present && exit 0
### Exit (wait for Maco upgrade to be applied)
is_maco_upgrade_present \
&& exit 0
## If Maco upgrade is present
### Exit (wait for Maco upgrade to be applied)
is_maco_upgrade_present \
&& exit 0
fi
## Simple debug message with color to valid current variables ## Simple debug message with color to valid current variables
debug_message "main Try to manage \ debug_message "main Try to manage \