Home > General > Subversion (SVN) Server Startup Script

Subversion (SVN) Server Startup Script

February 12th, 2008 Leave a comment Go to comments

To be able to start and stop my subversion server nicely I created the following script to startup and shutdown under debian.

#! /bin/sh
# /etc/init.d/svnserve: start and stop svnserve
 
# Exit immediately if a command exits with a nonzero exit status.
set -e
 
# svnserve exists and is executable
test -x /usr/bin/svnserve || exit 0
 
# Directory Where the Repository is located, created with svnadmin create
REPOS_DIR="/opt/svn"
 
# The pid-file
PIDFILE="/var/run/svnserve.pid"
 
case "$1" in
  start)
        echo -n "Starting Subversion (SVN) Server"
        start-stop-daemon --start --quiet \
                --exec /usr/bin/svnserve -- -dr $REPOS_DIR
        # Also tried the following line but it didn't work ok
        #       --make-pidfile --pidfile $PIDFILE
        PID=`pidof svnserve` || true
        echo $PID > $PIDFILE
        echo "."
        ;;
  stop)
        echo -n "Stopping Subversion (SVN) Server"
        start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
        if [ -f $PIDFILE ]
        then
                rm $PIDFILE
        fi
        echo "."
        ;;
 
  *)
        echo "Usage: /etc/init.d/svnserve {start|stop}"
        exit 1
esac
 
exit 0

Place the script in /etc/init.d/svnserve and run the following command:

update-rc.d svnserve defaults
  1. June 6th, 2010 at 22:28 | #1

    Thanks! This script was very helpful!

    I am running Subversion 1.5.4, as installed from the Ubuntu 9.04 Jaunty repositories and –pid-file is now a valid argument for svnserve.

    I changed the start block as such:

    start)
    echo -n “Starting Subversion (SVN) Server”
    start-stop-daemon –start –quiet \
    –exec /usr/bin/svnserve — -dr $REPOS_DIR \
    –pid-file=$PIDFILE
    #PID=`pidof svnserve` || true
    #echo $PID > $PIDFILE
    echo “.”
    ;;

    I also added the LSB init lines so that the update-rc.d wouldn’t have warnings. I basically used the apache file as a template.

    ### BEGIN INIT INFO
    # Provides: svnserve
    # Required-Start: $local_fs $remote_fs $network $syslog
    # Required-Stop: $local_fs $remote_fs $network $syslog
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Start svnserve daemon at boot time
    # Description: Enable svnserve by daemon.
    ### END INIT INFO

  2. December 4th, 2012 at 11:12 | #2

    Danke, genau das Skript, was ich suche.

  1. No trackbacks yet.

Time limit is exhausted. Please reload CAPTCHA.