diff --git a/cluster/maco.check.update.sh b/cluster/maco.check.update.sh index 7eb79ea..dd8ee1c 100755 --- a/cluster/maco.check.update.sh +++ b/cluster/maco.check.update.sh @@ -66,6 +66,33 @@ message() { # {{{ return 0 +} +# }}} +is_var_empty() { # {{{ + + ## Return False by default + return_var_empty="1" + ## Total number of variables to test + local_total_var="${#}" + + loop_count_var_empty="0" + + ## While it remains a variable to test + while [ "${local_total_var}" -gt "${loop_count_var_empty}" ]; do + debug_message "is_var_empty − \ +Test var: ${1}." + ### Test if this is empty and set return value to True + [ -z "${1}" ] && return_var_empty="0" + + ### Increase the number of tested variables + loop_count_var_empty=$((loop_count_var_empty+1)) + + ### Shift to the next variable + shift + done + + return "${return_var_empty}" + } # }}} is_maco_urgent_upgrade_require() { # {{{ @@ -140,17 +167,19 @@ Disable SGE queue." main() { # {{{ ## Get all Maco's versions (date) - readonly CURRENT_MACO_VERSION=$(< "${MACO_LOCAL_DIR}/maco-version.txt" awk -v FS=. '{ print $1 "-" $2 "-" $3 "T" $4 ":" $5 ":" $6 }' \ - || exit 1) - readonly LATEST_MACO_VERSION=$(< "${MACO_INSTALL_DIR}/maco-version.txt" awk -v FS=. '{ print $1 "-" $2 "-" $3 "T" $4 ":" $5 ":" $6 }' \ - || exit 2) - readonly URGENT_MACO_VERSION=$(< "${MACO_INSTALL_DIR}/urgent-maco-version.txt" awk -v FS=. '{ print $1 "-" $2 "-" $3 "T" $4 ":" $5 ":" $6 }' \ - || exit 3) + readonly CURRENT_MACO_VERSION=$(< "${MACO_LOCAL_DIR}/maco-version.txt" awk -v FS=. '{ print $1 "-" $2 "-" $3 "T" $4 ":" $5 ":" $6 }' ) + readonly LATEST_MACO_VERSION=$(< "${MACO_INSTALL_DIR}/maco-version.txt" awk -v FS=. '{ print $1 "-" $2 "-" $3 "T" $4 ":" $5 ":" $6 }' ) + readonly URGENT_MACO_VERSION=$(< "${MACO_INSTALL_DIR}/urgent-maco-version.txt" awk -v FS=. '{ print $1 "-" $2 "-" $3 "T" $4 ":" $5 ":" $6 }' ) ## Convert version to timestamp readonly CURRENT_TIMESTAMP=$(date -d "${CURRENT_MACO_VERSION}" "+%s") readonly LATEST_TIMESTAMP=$(date -d "${LATEST_MACO_VERSION}" "+%s") readonly URGENT_TIMESTAMP=$(date -d "${URGENT_MACO_VERSION}" "+%s") + ## If a variable is empty + ## Exit with error code + is_var_empty "${CURRENT_MACO_VERSION}" "${LATEST_MACO_VERSION}" "${URGENT_MACO_VERSION}" "${CURRENT_TIMESTAMP}" "${LATEST_TIMESTAMP}" "${URGENT_TIMESTAMP}" \ + && exit 1 + is_maco_uptodate \ && exit 0