Subversion daemon Init script

Subversion daemon Init script

Unfortunately I didn’t find a simple good daemon Init script for a debian Linux server where I want to start the subversion server svnserve automatically on start-up. So after a little bit searching on the internet and adapting the found resources (here or here), I got my Init script svnserve under /etc/init.d:

#!/bin/sh
#
# start/stop subversion daemon.
EXECUTABLE=/usr/bin/svnserve

# Test exist:ence of the executable
test -f $EXECUTABLE || exit 0

# Command line options for starting the service
OPTIONS='-d -r /var/svn'

. /lib/lsb/init-functions

case $1 in
start)
log_daemon_msg "Starting subversion daemon: $EXECUTABLE $OPTIONS"
start-stop-daemon -vo -x $EXECUTABLE -S -- $OPTIONS
log_end_msg $?
;;

stop)
log_daemon_msg "Stopping subversion daemon: $EXECUTABLE $OPTIONS"
start-stop-daemon -K -qo -x $EXECUTABLE
log_end_msg $?
;;

force-reload)
$0 restart
;;

restart)
$0 stop
$0 start
;;

*)
log_daemon_msg "Usage: /etc/init.d/svnserve {start|stop|restart}"
exit 1
;;
esac

exit 0

After you created that script (be sure that the file is executable), you have to add the script to the boot sequence:

update-rc.d svnserve defaults

If you see errors or improvements, feel free to add a comment.

One thought on “Subversion daemon Init script

  1. Thanks for the nice script Patrick. I got some LSB warning when I used it on my Debian 6 machine:
    \insserv: warning: script ‘svnserve’ missing LSB tags and overrides\

    To solve this, the script needs a LSB header. So when using this script on a Debian 6 machine, please add the following header to prevent warnings from insserve:

    #!/bin/sh
    #
    ### BEGIN INIT INFO
    # Provides: svnserve
    # Required-Start: $remote_fs $syslog
    # Required-Stop: $remote_fs $syslog
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Start and stop svnserve daemon at boot time
    # Description: Controls the main subversion server \svnserve\ with default params.
    ### END INIT INFO

    My 2 cents 🙂

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.