#!/bin/sh
exec 2>&1

# Note that `notracker1` and 'notracker2' are just examples. Change
# them to the installed tracker name(s). See roundup-server(1) for
# more info

if [ -f /etc/default/roundup ]; then
	. /etc/default/roundup
fi

# Take these values from /etc/default/roundup:
# PORT, USER, TRACKERS, but override them all in case of having a CONFFILE
#
# TRACKERS must be set to a list of trackers in one string. Example:
# TRACKERS=${TRACKERS:=notracker1=/var/lib/roundup/notracker1 notracker2=/var/lib/roundup/notracker2}
# 
# If you can, use the server config file instead (except for the USER variable)

CONFFILE=/etc/roundup/roundup-server.ini

OPTS="-D"

if [ X${PORT} != X ]; then
	OPTS="${OPTS} -p ${PORT}"
fi

if [ -f ${CONFFILE} ]; then
	OPTS="${OPTS} -C ${CONFFILE}"
fi

if [ X${USER} != X ]; then
	chown -R ${USER} /var/lib/roundup/trackers
	chown -R ${USER} /var/run/roundup
	chown -R ${USER} /var/log/roundup
	UOPT="chpst -u ${USER}"
fi

echo "starting roundup server"

exec $UOPT roundup-server ${OPTS} ${TRACKERS}

