forked from ISTI-ansible-roles/ansible-roles
Fix the function that performs the svn update so that it exits immediately if there's nothing to do.
This commit is contained in:
parent
084eaae1d2
commit
7d8faf3cfa
|
@ -15,7 +15,10 @@ LOG_FILE=${LOG_DIR}/algorithms_updater.log
|
|||
ALGORITHMS_INSTALLED_FILE=${LOG_DIR}/already_installed_algorithms.txt
|
||||
ALGORITHMS_INSTALLED_SORTED_FILE=${LOG_DIR}/already_installed_algorithms_sorted.txt
|
||||
LOCK_FILE=${LOG_DIR}/.algorithms_updater.lock
|
||||
ALGO_DIR={{ dataminer_wps_algorithms_dest }}/${INFRA_REFERENCE}
|
||||
ALGO_BASE_DIR={{ dataminer_wps_algorithms_dest }}
|
||||
ALGO_DIR=${ALGO_BASE_DIR}/${INFRA_REFERENCE}
|
||||
SVN_ALGORITHMS_URL={{ dataminer_wps_algorithms_svn }}
|
||||
SVN_UPDATE_STATUS=
|
||||
# In seconds. 60*60*6=21600s (6h)
|
||||
UPDATER_PROCESS_MAX_RUNTIME=21600
|
||||
OLDPROC=
|
||||
|
@ -24,20 +27,20 @@ RUNNING_JOB_RETVAL=
|
|||
|
||||
trap "logger 'algorithms-updater: trap intercepted, exiting.' ; cleanup 1" SIGHUP SIGINT SIGTERM
|
||||
|
||||
function cleanup() {
|
||||
cleanup() {
|
||||
rm -fr $OUT_DIR
|
||||
rm -f $LOCK_FILE
|
||||
logger 'algorithms-updater: Exiting'
|
||||
exit $1
|
||||
}
|
||||
|
||||
function create_log_dir() {
|
||||
create_log_dir() {
|
||||
if [ ! -d $LOG_DIR ] ; then
|
||||
mkdir -p $LOG_DIR
|
||||
fi
|
||||
}
|
||||
|
||||
function check_lock_file() {
|
||||
check_lock_file() {
|
||||
# Create the lock file
|
||||
if [ -f $LOCK_FILE ] ; then
|
||||
set +o pipefail
|
||||
|
@ -69,22 +72,33 @@ function check_lock_file() {
|
|||
echo "$PROCNUM" > $LOCK_FILE
|
||||
}
|
||||
|
||||
function update_svn_repo() {
|
||||
logger 'algorithms-updater: update the SVN repo'
|
||||
cd $ALGO_DIR
|
||||
# Do a svn cleanup to be on the safe side
|
||||
SVN_CLEANUP_OP=$( svn cleanup )
|
||||
svn update > $LOG_FILE 2>&1
|
||||
update_svn_repo() {
|
||||
if [ -d $ALGO_DIR ]; then
|
||||
logger 'algorithms-updater: update the SVN repo'
|
||||
cd $ALGO_DIR
|
||||
# Do a svn cleanup to be on the safe side
|
||||
set +o pipefail
|
||||
set +e
|
||||
SVN_CLEANUP_OP=$( svn cleanup )
|
||||
SVN_UPDATE_OP=$( svn update | tail -1 | grep Updated >$LOG_FILE 2>&1 )
|
||||
SVN_UPDATE_STATUS=$?
|
||||
set -o pipefail
|
||||
set -e
|
||||
else
|
||||
cd $ALGO_BASE_DIR
|
||||
logger "algorithms-updater: First subversion checkout"
|
||||
svn co $SVN_ALGORITHMS_URL >> $LOG_FILE 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
function sort_installed_algo_file() {
|
||||
sort_installed_algo_file() {
|
||||
if [ -f $ALGORITHMS_INSTALLED_FILE ] ; then
|
||||
sort -u $ALGORITHMS_INSTALLED_FILE > $ALGORITHMS_INSTALLED_SORTED_FILE
|
||||
mv $ALGORITHMS_INSTALLED_SORTED_FILE $ALGORITHMS_INSTALLED_FILE
|
||||
fi
|
||||
}
|
||||
|
||||
function algorithms_updater() {
|
||||
algorithms_updater() {
|
||||
logger 'algorithms-updater: scan the algorithms list and build the algorithms script. Reference infra is {{ dataminer_infra_reference }}'
|
||||
echo "#!/bin/bash" > $ALGORITHMS_TEMP_SCRIPT.head
|
||||
echo "cd $ADD_ALGORITHM_DIR" >> $ALGORITHMS_TEMP_SCRIPT.head
|
||||
|
@ -194,6 +208,10 @@ function algorithms_updater() {
|
|||
create_log_dir
|
||||
check_lock_file
|
||||
update_svn_repo
|
||||
if [ $SVN_UPDATE_STATUS -ne 0 ] ; then
|
||||
logger "algorithms-updater: nothing new to from SVN, exiting."
|
||||
cleanup 0
|
||||
fi
|
||||
sort_installed_algo_file
|
||||
algorithms_updater
|
||||
cleanup 0
|
||||
|
|
Loading…
Reference in New Issue