#!/bin/bash
#
# svnd		Script to control subversion daemon (svnserve).
#
# Author:       Samo Pogacnik <samo.pogacnik@s5.net>
#
# chkconfig: - 90 10
# description:  Starts, stops and restarts subversion daemon. 

# Source function library.
. /etc/init.d/functions

prog="svnserve"

# Check that networking is up.
[ -f /usr/bin/svnserve ] || exit 0

RETVAL=0

# The location of the virtual root for repositories.
SVNROOT=/home/svnr

start() {
        echo -n $"Starting subversion daemon ($prog): "
        daemon $prog -d -r $SVNROOT
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/svnd
        return $RETVAL
}

stop() {
        echo -n $"Stopping subversion daemon ($prog): "
        killproc $prog
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/svnd
        return $RETVAL
}
# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
	if [ -e /var/lock/subsys/svnd ]; then
		echo $"Subversion daemon is enabled."
	else
		echo $"Subversion daemon is disabled."
	fi
	;;
  restart|reload)
	stop
	start
	;;
  *)
	# do not advertise unreasonable commands that there is no reason
	# to use with this device
	echo $"Usage: $0 {start|stop|status|restart}"
	exit 1
esac

exit 0

