#!/bin/bash

# $Debian$

#
# Execute pserver
#

# Set some resource limits

unset HOME
if [ -f /etc/cvs-pserver.conf ]; then
	. /etc/cvs-pserver.conf
elif [ -f /etc/cvs.conf ]; then
	. /etc/cvs.conf
else
	CVS_PSERV_REPOS=""
fi

ulimit -m ${CVS_PSERV_LIMIT_MEM:-131072}
ulimit -d ${CVS_PSERV_LIMIT_DATA:-131072}
ulimit -c ${CVS_PSERV_LIMIT_CORE:-0}
ulimit -t ${CVS_PSERV_LIMIT_CPU:-3600} 

allow_root_opts=""
OLDIFS="$IFS"
IFS=':'
for i in $CVS_PSERV_REPOS; do
	IFS="$OLDIFS"
	allow_root_opts="$allow_root_opts --allow-root=$i"
done

cvs_tmp_dir=""
[ "$CVS_TMP_DIR" != "" ] && cvs_tmp_dir="-T $CVS_TMP_DIR"

external_password_file=""
[ "$CVS_EXT_PASSWD_FILE" != "" ] && \
    external_password_file="--password-file $CVS_EXT_PASSWD_FILE"

exec /usr/bin/cvs -b /usr/bin ${cvs_tmp_dir} ${allow_root_opts} \
    ${external_password_file} pserver

# End of file.
