#
# run-functions  This file contains functions common to the qmail run scripts
#

exec 2>&1

PATH="/sbin:/usr/sbin:/bin:/usr/bin:$PATH"

# Read the contents of a control file, substituting the given default
# string if the file is empty.
readdefault() {
	var=$1; shift
	file=$1; shift
	if [ -s /var/qmail/control/$file ]; then
		export $var="`cat /var/qmail/control/$file`"
	else
		export $var="$*"
	fi
}

# Read the contents of a file relative to /var/qmail if found otherwise
# absolute file path is assumed, substituting the given default string
# if the file is empty.
readfiledefault() {
	var=$1; shift
	file=$1; shift
	if [ -s /var/qmail/$file ]; then
		export $var="`cat /var/qmail/$file`"
	elif [ -s $file ]; then
		export $var="`cat $file`"
	else
		export $var="$*"
	fi
}
