diff --git a/openbis_all/source/bash/check-and-exit-if-new-sprint-server b/openbis_all/source/bash/check-and-exit-if-new-sprint-server new file mode 100755 index 0000000000000000000000000000000000000000..6b9debc5846f43829f7ab46e33a4d02921184068 --- /dev/null +++ b/openbis_all/source/bash/check-and-exit-if-new-sprint-server @@ -0,0 +1,37 @@ +#! /bin/bash +# +# This script checks whether openBIS AS server is a sprint server installed in the current week +# or not. If yes exit (with exit code 0) is executed. +# +# usage: check-and-exit-if-new-sprint-server.sh <servers> +# +# where +# <servers> is the path to the directory containing the server folders 'openBIS-server' +# and 'datastore_server', +# +if [ $# -ne 1 ]; then + echo "Usage: check-and-exit-if-new-sprint-server.sh <servers>" + exit 1 +fi + +SERVERS="$1" +LOG_FILE=$SERVERS/openBIS-server/jetty/logs/jetty.out + +CURRENT_VERSION=UNKNOWN +if [ -f $LOG_FILE ]; then + CURRENT_VERSION=`awk '/STATUS.CISDContextLoaderListener - Version/ {print $1" "$2" "$8" "$9}' $LOG_FILE | tail -1` + echo "Current openBIS Application Server: $CURRENT_VERSION" + if [ "SNAPSHOT" != "`echo $CURRENT_VERSION|awk '{print $3}'`" ]; then + TIME_STAMP="`echo $CURRENT_VERSION|awk '{print $1, $2}'`" + WEEK=`date --date="$TIME_STAMP" "+%W"` + if [ $? -ne 0 ]; then + # Mac OSX has a different flavor of date command + WEEK=`date -j -f "%Y-%m-%d %H:%M:%S" "$TIME_STAMP" "+%W"` + fi + CURRENT_WEEK=`date "+%W"` + if [ "$WEEK" = "$CURRENT_WEEK" ]; then + echo "Sprint server not replaced until next week." + exit + fi + fi +fi diff --git a/openbis_all/source/bash/nightly-upgrade-generic-openbis.sh b/openbis_all/source/bash/nightly-upgrade-generic-openbis.sh index d83c8ae17c8cc83bcefa26b808d79e79509d50b0..cf9b87a7d23f590990dd5b07b9b907c3658d9350 100644 --- a/openbis_all/source/bash/nightly-upgrade-generic-openbis.sh +++ b/openbis_all/source/bash/nightly-upgrade-generic-openbis.sh @@ -10,35 +10,15 @@ # Crontab entry: #Â 30 3 * * * [ -f $HOME/.profile ] && . $HOME/.profile && [ -f $HOME/.bash_profile ] && . $HOME/.bash_profile && nightly-upgrade-generic-openbis.sh &>> openbis-cronjob.txt #Â +# Dependencies: +# - check-and-exit-if-new-sprint-server.sh BIN_DIR=`dirname "$0"` SERVERS=sprint echo ":::::::::::::::::::: Nightly Upgrade Generic openBIS Servers [`date`] :::::::::::::::::::::" -################################################## -# -# Check whether upgrade should be done or not -# -LOG_FILE=$SERVERS/openBIS-server/jetty/logs/openbis_log.txt -CURRENT_VERSION=UNKNOWN -if [ -f $LOG_FILE ]; then - CURRENT_VERSION=`awk '/OPERATION.CISDContextLoaderListener - Version/ {print $1" "$2" "$8" "$9}' $LOG_FILE | tail -1` - echo "Current openBIS Application Server: $CURRENT_VERSION" - if [ "SNAPSHOT" != "`echo $CURRENT_VERSION|awk '{print $3}'`" ]; then - TIME_STAMP="`echo $CURRENT_VERSION|awk '{print $1, $2}'`" - WEEK=`date --date="$TIME_STAMP" "+%W"` - if [ $? -ne 0 ]; then - # Mac OSX has a different flavor of date command - WEEK=`date -j -f "%Y-%m-%d %H:%M:%S" "$TIME_STAMP" "+%W"` - fi - CURRENT_WEEK=`date "+%W"` - if [ "$WEEK" = "$CURRENT_WEEK" ]; then - echo "Sprint server not replaced until next week." - exit - fi - fi -fi +"$BIN_DIR/check-and-exit-if-new-sprint-server.sh" "$SERVERS" ################################################## #