From ee91922764a2889b4748a8e336a0993641ed31af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Wed, 17 Jun 2020 16:01:25 +0200 Subject: [PATCH] Manage a temp file if upgrade is required --- cluster/maco.check.update.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cluster/maco.check.update.sh b/cluster/maco.check.update.sh index e4a9c0d..19a6ac7 100755 --- a/cluster/maco.check.update.sh +++ b/cluster/maco.check.update.sh @@ -3,6 +3,7 @@ # This script will check if Maco require an upgrade and # will prepare the host in order to apply upgrade : # 1. Disable SGE queue +# 2. Create a temp file (/tmp/.maco.upgrade or /tmp/.maco.urgent.upgrade) # This script can be call by a cronjob (eg. weekly) # Another script should try to apply upgrades also with cron (eg. hourly) @@ -34,6 +35,8 @@ readonly COLOR_DEBUG="${PURPLE}" ## Maco readonly MACO_LOCAL_DIR="/opt/maco" readonly MACO_INSTALL_DIR="/mnt/store.ipr/InstallProgs/ipr/maco" +readonly MACO_TMP_FILE="/tmp/.maco.upgrade" +readonly MACO_TMP_URGENT_FILE="/tmp/.maco.urgent.upgrade" # }}} usage() { # {{{ @@ -108,10 +111,15 @@ 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 + touch "${MACO_TMP_URGENT_FILE}" && echo "Urgent Maco upgrade is available (from version ${CURRENT_MACO_VERSION} to ${URGENT_MACO_VERSION})." >> "${MACO_TMP_URGENT_FILE}" 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" + ## Ensure urgent temp file is not present + rm -f -- "${MACO_TMP_URGENT_FILE}" fi return "${return_urgent_upgrade}" @@ -127,10 +135,15 @@ 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 + touch "${MACO_TMP_FILE}" && echo "Latest Maco upgrade is available (from version ${CURRENT_MACO_VERSION} to ${LATEST_MACO_VERSION})." >> "${MACO_TMP_FILE}" else debug_message "is_maco_upgrade_require − \ Local Maco (${CURRENT_MACO_VERSION}) seems up to date (latest: ${LATEST_MACO_VERSION})." return_upgrade="1" + ## Ensure temp file is not present + rm -f -- "${MACO_TMP_FILE}" fi return "${return_upgrade}" @@ -146,6 +159,8 @@ 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" + ## Ensure to remove temp files + rm -f -- "${MACO_TMP_FILE}" "${MACO_TMP_URGENT_FILE}" else debug_message "is_maco_uptodate − \ Local Maco version (${CURRENT_MACO_VERSION}) is different from latest version (${LATEST_MACO_VERSION})."