#!@l_prefix@/lib/openpkg/bash @l_prefix@/etc/rc
##
##  rc.cvs -- Run-Commands for CVS pserver Daemon
##

%config
    cvs_pserverd_enable="no"
    cvs_pserverd_gflags=""
    cvs_pserverd_lflags=""
    cvs_pserverd_listen="127.0.0.1:2401"

%common
    cvs_pserverd_pidfile="@l_prefix@/var/cvs/pserverd.pid"

%start -p 200 -u root
    if opServiceEnabled cvs_pserverd; then
        rm -f $cvs_pserverd_pidfile >/dev/null 2>&1 || true
        @l_prefix@/bin/cvs -f $cvs_pserverd_gflags \
            pserverd -d -p $cvs_pserverd_pidfile \
                     -l $cvs_pserverd_listen $cvs_pserverd_lflags
    fi

%stop -p 200 -u root
    if opServiceEnabled cvs_pserverd; then
        if [ -f $cvs_pserverd_pidfile ]; then
            kill -TERM `cat $cvs_pserverd_pidfile` >/dev/null 2>&1 || true
            sleep 2
            kill -KILL `cat $cvs_pserverd_pidfile` >/dev/null 2>&1 || true
            rm -f $cvs_pserverd_pidfile >/dev/null 2>&1 || true
        fi
    fi

