Add web_mode to get maco's version with curl
This commit is contained in:
parent
f6cd6ee79b
commit
5f8ffa900f
|
@ -5,8 +5,8 @@
|
|||
# 1. Disable SGE queue
|
||||
# 2. Create a temp file (${MACO_LOCAL_DIR}/.maco.upgrade or ${MACO_LOCAL_DIR}/.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)
|
||||
# This script can be call by a cronjob (eg. weekly or daily with --fail option).
|
||||
# Another script should try to apply upgrades also with cron (eg. hourly).
|
||||
|
||||
# Vars {{{
|
||||
readonly PROGNAME=$(basename "${0}")
|
||||
|
@ -45,7 +45,7 @@ readonly MACO_TMP_URGENT_FILE="${MACO_LOCAL_DIR}/.maco.urgent.upgrade"
|
|||
usage() { # {{{
|
||||
|
||||
cat <<- EOF
|
||||
usage: $PROGNAME [-d|-h|-q|-s|-u]
|
||||
usage: $PROGNAME [-d|-h|-q|-s|-u|-w]
|
||||
|
||||
Compare current version of Maco script with the latest and
|
||||
the urgent versions then try to prepare the host by:
|
||||
|
@ -58,6 +58,9 @@ EXAMPLES:
|
|||
- Verify only urgent upgrade for Maco and prepare the current host
|
||||
${PROGNAME} --urgent
|
||||
|
||||
- Get Maco's new versions from a webserver instead of the filesystem
|
||||
${PROGNAME} --web
|
||||
|
||||
OPTIONS :
|
||||
-d,--debug
|
||||
Enable debug messages.
|
||||
|
@ -76,6 +79,9 @@ OPTIONS :
|
|||
|
||||
-u,--urgent
|
||||
Check only for urgent upgrade.
|
||||
|
||||
-w,--web
|
||||
Get Maco's versions from a webserver.
|
||||
EOF
|
||||
|
||||
|
||||
|
@ -316,8 +322,21 @@ 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 }' )
|
||||
## If WEB_MODE wasn't defined (argument, environment variable,…) {{{
|
||||
if [ -z "${WEB_MODE}" ]; then
|
||||
### Get Maco's versions from filesystem
|
||||
debug_message "define_vars − \
|
||||
Get Maco's versions from filesystem."
|
||||
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 }' )
|
||||
else
|
||||
### Get Maco's versions from webserver
|
||||
debug_message "define_vars − \
|
||||
Get Maco's versions from webserver."
|
||||
readonly LATEST_MACO_VERSION=$(curl --silent --insecure https://store.ipr.univ-rennes1.fr/InstallProgs/ipr/maco/maco-version.txt | awk -v FS=. '{ print $1 "-" $2 "-" $3 "T" $4 ":" $5 ":" $6 }')
|
||||
readonly URGENT_MACO_VERSION=$(curl --silent --insecure https://store.ipr.univ-rennes1.fr/InstallProgs/ipr/maco/urgent-maco-version.txt | awk -v FS=. '{ print $1 "-" $2 "-" $3 "T" $4 ":" $5 ":" $6 }')
|
||||
fi
|
||||
## }}}
|
||||
## Convert version to timestamp
|
||||
readonly CURRENT_TIMESTAMP=$(date -d "${CURRENT_MACO_VERSION}" "+%s")
|
||||
readonly LATEST_TIMESTAMP=$(date -d "${LATEST_MACO_VERSION}" "+%s")
|
||||
|
@ -363,7 +382,6 @@ main() { # {{{
|
|||
&& prepare_host_for_upgrade \
|
||||
&& exit 0
|
||||
### }}}
|
||||
|
||||
fi
|
||||
|
||||
}
|
||||
|
@ -404,6 +422,10 @@ if [ ! "${NBARGS}" -eq "0" ]; then
|
|||
## Check only for urgent upgrade
|
||||
URGENT_ONLY_MODE=0
|
||||
;;
|
||||
-w|--web ) ## Web mode
|
||||
## Get versions from webserver
|
||||
WEB_MODE=0
|
||||
;;
|
||||
-- ) ## End of options list
|
||||
## End the while loop
|
||||
break
|
||||
|
|
Loading…
Reference in New Issue