File tine20-asyncrunner.sh of Package tine20

#!/bin/sh
#
# Run async scripts
#
# (c) Johannes Weberhofer, Weberhofer GmbH 2012
#
# This script is licensed under the AGPL
#

TINE20SOURCE='/usr/share/tine20'
INSTALLATIONS='/etc/tine20-installations'
MAININST='/var/lib/tine20'

function doAsyncEvents() {
	WEBROOT="$1"
	if [ -d "$WEBROOT" ] ; then
	        # update installation
	        if [ -x "/usr/bin/php" ] ; then
	                PHP="/usr/bin/php"
	        else
	                if [ -x "/usr/bin/php5" ] ; then
	                        PHP="/usr/bin/php5"
	                fi
	        fi
	        if [ -x "$PHP" ] ; then
	                pushd "$WEBROOT" > /dev/null
	                # run only when config.inc.php exists and 
	                # run only, when 'ENTER DATABASE HOSTNAME' is no longer present
	                if [ -e config.inc.php ] ; then
	                        grep -q 'ENTER DATABASE HOSTNAME' config.inc.php
	                        if [ "$?" -ne 0 ] ; then
					if [ ! -d "../log" ] ; then
						mkdir "../log"
					fi
	                                "$PHP" -d ".:$WEBROOT:$TINE20SOURCE:$PHP/PEAR" \
						tine20.php --method Tinebase.triggerAsyncEvents \
						>> ../log/cron.log
	                        fi
	                fi
	                popd > /dev/null
	        fi
	else
	        echo "Invilid tine20 location: $WEBROOT" 1>&2
	fi
}

doAsyncEvents "$MAININST/webroot"
if [ -e "$INSTALLATIONS" ] ; then
        while read INST ; do
                if [ "$INST" != "$MAININST" ] ; then
                        doAsyncEvents "$INST"
                fi
        done < "$INSTALLATIONS"
fi
openSUSE Build Service is sponsored by