#!@l_prefix@/lib/openpkg/bash @l_prefix@/etc/rc
##
##  rc.perforce -- Run-Commands for P4 Daemon
##

%config
    perforce_enable="yes"
    perforce_port="localhost:1666"
    perforce_rootdir="@l_prefix@/var/perforce/p4d.depot"
    perforce_journal="@l_prefix@/var/perforce/p4d.journal"
    perforce_logfile="@l_prefix@/var/perforce/p4d.log"

%start -p 100 -u root
    if opServiceEnabled perforce; then
        cmd="@l_prefix@/sbin/p4d" 
        cmd="$cmd -q -d -z"
        cmd="$cmd -p ${perforce_port}"
        cmd="$cmd -r ${perforce_rootdir}"
        cmd="$cmd -J ${perforce_journal}"
        cmd="$cmd -L ${perforce_logfile}"
        umask 077
        su @l_rusr@ -c "nohup $cmd </dev/null >/dev/null 2>&1 &"
    fi

%stop -p 200 -u root
    if opServiceEnabled perforce; then
        cmd="@l_prefix@/bin/p4"
        cmd="$cmd -p ${perforce_port}"
        cmd="$cmd admin stop"
        umask 077
        su @l_rusr@ -c "$cmd"
    fi

