#
# Copyright (c) 2001-2002 by Leni Mayo
#
#	This program is free software; you can redistribute it and/or modify
#	it under the terms of the GNU General Public License, version 2, as
#	published by the Free Software Foundation.
#
#	This program is distributed in the hope that it will be useful,
#	but WITHOUT ANY WARRANTY; without even the implied warranty of
#	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#	GNU General Public License for more details.
#
startServer() {
	# sereld -b $* -d 4 -l /tmp/sereld.log --log-truncate
	# export SEREL_DEBUG_LEVEL=3
	# export SEREL_LOG_NAME=/tmp/serelc.log
	# echo not starting server...
	sereld -b $* -d 0
	return $?
}

success() {
	echo succeeded.
	exit 0
}

failure() {
	echo -n failed
	
	if [ $# != 0 ]; then
		echo " at line number" args $*
	else
		echo .
	fi

	serelc --control stop 2>&1 > /dev/null
	exit 1
}

# testStatus directory state
# service names are the same as script names for convenience
testStatus() {
	local directory=$1
	local state=$2
	for i in $directory/*; do
		if [ ! -d $i ]; then
			local name=`basename $i`
    		local namestate=`serelc --query state $name`
			if [ "$namestate" != "$state" ]; then
				failure
			fi
		fi
	done
}
