Don't manage files with SIMULATE_MODE enabled
This commit is contained in:
parent
1c6a8fcbc6
commit
b7a369ae90
|
@ -42,7 +42,7 @@ readonly MACO_TMP_URGENT_FILE="/tmp/.maco.urgent.upgrade"
|
|||
usage() { # {{{
|
||||
|
||||
cat <<- EOF
|
||||
usage: $PROGNAME [-h,--help|-d,--debug|-s,--simulate]
|
||||
usage: $PROGNAME [-d|-h|-s]
|
||||
|
||||
Compare current version of Maco script with the latest and
|
||||
the urgent versions then try to prepare the host by:
|
||||
|
@ -51,8 +51,19 @@ Compare current version of Maco script with the latest and
|
|||
EXAMPLES:
|
||||
- Verify Maco's upgrade and prepare the current host
|
||||
${PROGNAME}
|
||||
|
||||
OPTIONS :
|
||||
-d,--debug
|
||||
Enable debug messages.
|
||||
|
||||
-h,--help
|
||||
Print this help message.
|
||||
|
||||
-s,--simulate
|
||||
Only display messages and don't manage temp files.
|
||||
EOF
|
||||
|
||||
|
||||
}
|
||||
# }}}
|
||||
debug_message() { # {{{
|
||||
|
@ -111,16 +122,24 @@ is_maco_urgent_upgrade_require() { # {{{
|
|||
Urgent Maco upgrade is available (from version ${CURRENT_MACO_VERSION} to ${URGENT_MACO_VERSION})."
|
||||
message "Urgent Maco upgrade is available (from version ${CURRENT_MACO_VERSION} to ${URGENT_MACO_VERSION})."
|
||||
return_urgent_upgrade="0"
|
||||
## Also create an urgent temp file that can be monitored
|
||||
## touch and append to keep existing content
|
||||
|
||||
## If SIMULATE_MODE is not enable
|
||||
if [ ! "${SIMULATE_MODE}" -eq 0 ]; then
|
||||
### Also create an urgent temp file that can be monitored
|
||||
### touch and append to keep existing content
|
||||
touch "${MACO_TMP_URGENT_FILE}" && echo "Urgent Maco upgrade is available (from version ${CURRENT_MACO_VERSION} to ${URGENT_MACO_VERSION})." >> "${MACO_TMP_URGENT_FILE}"
|
||||
fi
|
||||
|
||||
else
|
||||
debug_message "is_maco_urgent_upgrade_require − \
|
||||
Local Maco (${CURRENT_MACO_VERSION}) is newer than urgent upgrade (${URGENT_MACO_VERSION})."
|
||||
return_urgent_upgrade="1"
|
||||
## If SIMULATE_MODE is not enable
|
||||
if [ ! "${SIMULATE_MODE}" -eq 0 ]; then
|
||||
## Ensure urgent temp file is not present
|
||||
rm -f -- "${MACO_TMP_URGENT_FILE}"
|
||||
fi
|
||||
fi
|
||||
|
||||
return "${return_urgent_upgrade}"
|
||||
|
||||
|
@ -135,16 +154,24 @@ is_maco_upgrade_require() { # {{{
|
|||
Latest Maco upgrade is available (from version ${CURRENT_MACO_VERSION} to ${LATEST_MACO_VERSION})."
|
||||
message "Latest Maco upgrade is available (from version ${CURRENT_MACO_VERSION} to ${LATEST_MACO_VERSION})."
|
||||
return_upgrade="0"
|
||||
## Also create a temp file that can be monitored
|
||||
## touch and append to keep existing content
|
||||
|
||||
## If SIMULATE_MODE is not enable
|
||||
if [ ! "${SIMULATE_MODE}" -eq 0 ]; then
|
||||
### Also create a temp file that can be monitored
|
||||
### touch and append to keep existing content
|
||||
touch "${MACO_TMP_FILE}" && echo "Latest Maco upgrade is available (from version ${CURRENT_MACO_VERSION} to ${LATEST_MACO_VERSION})." >> "${MACO_TMP_FILE}"
|
||||
fi
|
||||
|
||||
else
|
||||
debug_message "is_maco_upgrade_require − \
|
||||
Local Maco (${CURRENT_MACO_VERSION}) seems up to date (latest: ${LATEST_MACO_VERSION})."
|
||||
return_upgrade="1"
|
||||
## If SIMULATE_MODE is not enable
|
||||
if [ ! "${SIMULATE_MODE}" -eq 0 ]; then
|
||||
## Ensure temp file is not present
|
||||
rm -f -- "${MACO_TMP_FILE}"
|
||||
fi
|
||||
fi
|
||||
|
||||
return "${return_upgrade}"
|
||||
|
||||
|
@ -159,8 +186,11 @@ is_maco_uptodate() { # {{{
|
|||
Local Maco (${CURRENT_MACO_VERSION}) is up to date (latest: ${LATEST_MACO_VERSION})."
|
||||
message "Local Maco (${CURRENT_MACO_VERSION}) is up to date (latest: ${LATEST_MACO_VERSION})."
|
||||
return_uptodate="0"
|
||||
## If SIMULATE_MODE is not enable
|
||||
if [ ! "${SIMULATE_MODE}" -eq 0 ]; then
|
||||
## Ensure to remove temp files
|
||||
rm -f -- "${MACO_TMP_FILE}" "${MACO_TMP_URGENT_FILE}"
|
||||
fi
|
||||
else
|
||||
debug_message "is_maco_uptodate − \
|
||||
Local Maco version (${CURRENT_MACO_VERSION}) is different from latest version (${LATEST_MACO_VERSION})."
|
||||
|
@ -175,6 +205,7 @@ prepare_host_for_upgrade() { # {{{
|
|||
|
||||
sge_disable_host_queue_script="${PROGDIR}/sge.disable.host.queue.sh"
|
||||
|
||||
## If SIMULATE_MODE is enable
|
||||
if [ "${SIMULATE_MODE}" -eq 0 ]; then
|
||||
return 0
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue