#!/sbin/sh

##  Copy/Rename this script to /opt/csw/lib/svc/method/svnserve
##  Please change $REPOS to the location of your SVN Repo

. /lib/svc/share/smf_include.sh

SVNSERVE=/opt/csw/bin/svnserve
REPOS="/export/tonic_repo/"

[ ! -d ${REPOS} ] && exit $SMF_EXIT_ERR_CONFIG

case "$1" in
'start')
	${SVNSERVE} -d -r ${REPOS}
        exit 0
        ;;
'stop')
	kill `pgrep svnserve`
        exit 0
	;;	
'refresh')
	## There is no restart for svnserve, so we simply 
	##  kill it and restart.  The only reason to do this
	##  is to change startup options on svnserve.	
	##  We sleep for 5 secs because more than likely 
	##  SMF will restart it before we do.
	kill `pgrep svnserve`
	sleep 5 
	pgrep svnserve || ${SVNSERVE} -d -r ${REPOS}
        exit 0
	;;	
	
*)
        echo "Usage: $0 { start | stop | refresh }"
        exit 1
        ;;
esac
