BenRobb

  • Home
  • About Me
  • Contact

Howto: Start Subversion at Boot on Ubuntu

January 15, 2007 by Ben

I don’t know if I’ve extolled the virtues of Ubuntu on this blog yet, but they are many. They are, however, not the topic of this post. Every once in a while, I like to try different operating systems on my server, and at the moment, I’m just coming back to an Ubuntu server after a brief fling with Windows Server 2003.

On the list of things to do after install was to get Ubuntu to start the svnserve daemon at boot. I’ve taken the time to look this up enough times that I figured I’d just add it here. This procedure holds for anything you’d like to do at boot, I’m simply running my svn daemon.

Step 1 – Create your script.
Simply create a new file (I called mine svnserve) and type the command you’d like to run

cd /etc/init.d/ # (thanks Alfonso)
sudo touch svnserve
sudo vi svnserve
svnserve -d -r /usr/local/svn/repository_name

Step 2 – Save the script in the /etc/init.d/ folder

Step 3 – Make the script executable
sudo chmod +x svnserve

Step 4 – Add the script to the boot sequence
sudo update-rc.d svnserve defaults

That’s it. When you’re done you should see some output similar to

Adding system startup for /etc/init.d/svnserve ...
/etc/rc0.d/K20svnserve -> ../init.d/svnserve
/etc/rc1.d/K20svnserve -> ../init.d/svnserve
/etc/rc6.d/K20svnserve -> ../init.d/svnserve
/etc/rc2.d/S20svnserve -> ../init.d/svnserve
/etc/rc3.d/S20svnserve -> ../init.d/svnserve
/etc/rc4.d/S20svnserve -> ../init.d/svnserve
/etc/rc5.d/S20svnserve -> ../init.d/svnserve

Filed Under: Old Stuff Tagged With: featured

  • mik

    thanks!
    just what I needed!

  • Alfonso Reyes

    Excellent tip!
    If I may suggest to add a line before “sudo touch svnserve”, that says:

    cd /etc/init.d

    Otherwise, “update-rc.d” will not add “svnserve”.

    Thanks.

  • Miles Thompson

    Just what was needed to finish off the installation of subversion. Thanks.

  • James Haigh

    Thanks for this, just what I was looking for. Works on Debian Sarge too.

  • Ola

    Great, thanks!

    A contribution, my srartscript:
    #!/bin/sh
    #
    # start/stop subversion daemon.

    test -f /usr/bin/svnserve || exit 0

    OPTIONS=”-d -r /svnroot”

    case “$1” in
    start)
    echo -n “Starting subversion daemon:”
    echo -n ” svnserve”
    start-stop-daemon –start –quiet –oknodo –user svnowner –exec /usr/bin/svnserve — $OPTIONS
    echo “.”

    ;;
    stop)
    echo -n “Stopping subversion daemon:”
    echo -n ” svnserve”
    start-stop-daemon –stop –quiet –oknodo –exec /usr/bin/svnserve
    echo “.”
    ;;
    reload)
    ;;
    force-reload)
    $0 restart
    ;;
    restart)
    $0 stop
    $0 start
    ;;
    *)
    echo “Usage: /etc/init.d/subversion {start|stop|reload|restart}”
    exit 1
    ;;
    esac

    exit 0

  • Michael Heusi

    Thank you. With this, even a beginner like me can install subversion.

  • jkm

    Thanks for your advanced script, Ola. I’ve only one suggestion:

    For changing to user svnowner before starting svnserve you should use –chuid instead of –user. –user only limits killall when stopping to processes running with this uid.

  • Colin

    At the risk of sounding repetitious – THANKS.
    The Subversion book assumes that we all know how to initiate a daemon at startup. It seems like I’m not the only one that doesn’t.
    Ola’s script looks interesting as well, I’ll try that as well soon.

  • Piero

    Thanks a lot, but please next time you should use “normal” charachters (if possible), so that the code could be easily copied and pasted ^_^

  • phoenix

    Thanks for the helpful hint :)

  • Chris

    Thanks for the great guide.

    I’m kind of new to linux, but I didn’t want to run the server as root so I added “sudo -u ” to step 1 line 4 which then became:
    sudo -u svnserve -d -r /usr/local/svn/repository_name
    I also changed owner both user and group to the file svnserve.
    sudo chown : svnserve

    What do you think of my suggestions?

  • Brad

    I wonder if this is handled the same (or close) in SUSE?

  • Infrarotkabine

    Thanks for sharing this guide :-)

  • Sean O

    The following init script is the head of an example built from the skeleton init script in Ubuntu (/etc/init.d/skeleton) and works for me in Hardy Heron (server edition) just fine. Please note that my repositories are located at “/home/svn,” you may need to modify this.

    #! /bin/sh
    ### BEGIN INIT INFO
    # Provides: svnserve
    # Required-Start: $local_fs $remote_fs
    # Required-Stop: $local_fs $remote_fs
    # Default-Start: 2 3 4 5
    # Default-Stop: S 0 1 6
    # Short-Description: SVN initscript
    # Description: This file starts the SVN server (svnserve) at boot and should be
    # placed in /etc/init.d.
    ### END INIT INFO

    # Author: Sean O’Brien

    # Do NOT “set -e”

    # PATH should only include /usr/* if it runs after the mountnfs.sh script
    PATH=/usr/sbin:/usr/bin:/sbin:/bin
    DESC=”Description of the service”
    NAME=svnserve
    DAEMON=/usr/bin/$NAME
    DAEMON_ARGS=”-d -r /home/svn”
    PIDFILE=/var/run/$NAME.pid
    SCRIPTNAME=/etc/init.d/$NAME

  • Scott

    Just so everyone knows… the characters in the above script that need to be changed are the long dashes to double hypens, and the quotes to simple quotes (not smart quotes). Also note that you can test your script from the command line and make sure all three cases (start, stop, restart, etc) work without rebooting each time.

    This script and howto really helps. Thanks to everyone who has posted to this topic!!

  • Ravi

    That was a very crisp to the point solution I was looking for … Thanks a Lot

  • Keith Lynch

    Found the following worked best on Ubuntu

    #!/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/svnrepos’

    case $1 in
    start)
    echo -n “Starting subversion daemon: $EXECUTABLE $OPTIONS\n”
    start-stop-daemon -vo -x $EXECUTABLE -S — $OPTIONS
    echo -n “.”
    ;;

    stop)
    echo -n “Stopping subversion daemon: $EXECUTABLE $OPTIONS\n”
    start-stop-daemon -K -qo -x $EXECUTABLE
    echo -n “.”
    ;;

    force-reload)
    $0 restart
    ;;

    restart)
    $0 stop
    $0 start
    ;;

    *)
    echo ‘Usage: /etc/init.d/subversion {start|stop|restart}’
    exit 1
    ;;
    esac

    exit 0

  • Dinesh Dharme

    Thanks, it was really helpful. There were other scripts but they were little complex

  • Flashmob

    Thanks! I will recommend this to all my friends.

  • Jack

    Thanks! You rock.

  • barleone

    Thanks for this simple yet powerfull solution!
    I’ve got it working on Ubuntu 10.04 Lucid Lynx.

    QUESTION: The other scripts also look interesting. But how to make these working? Where to put them?

  • Pingback: Subversion daemon Init script | assumption of advancement()

  • Antonio

    T H A N K S !

  • Jakobsen out of Denmark

    T H A N K S
    did the job that I have moved in front of me for now 3 month in 5 min. remote from home.
    Tested and now on air.

    / Jørgen

  • techgane

    Thanks for sharing a nice article

    how to install svn on ubuntu

  • rahul

    thanks……………………..

  • Ben

    Thank you for providing this solution. I implemented it and was satisfied, until I realized that I couldn’t stop, restart, or reload the svnserve service, which I’m able to do with a proper “service”.

    Then I found http://odyniec.net/articles/ubuntu-subversion-server/ in which the author provides an init script that “works out-of-the-box” and takes this approach one step further, yielding a proper service that can be controlled with standard service commands. Here’s his script:

    http://odyniec.net/articles/ubuntu-subversion-server/svnserve

    This is working very well for me. Thanks again for pointing me in the right direction with this post.

Tags

2 cents Analytics apple best of Blogging conspiracy dev elections email spam excel featured games google hillary homes howto huck ilife install javascript Life mac Marketing mccain me microsoft mitt obama omniture plaxo politics programming ps3 riaa robisons science seth godin sitecatalyst social media stem cells summit sync top 10 upgrades wordpress
Since I don't run ads on my site, please consider letting the miner run while you read.
Loading...

Copyright © 2018 · Enterprise Pro Theme on Genesis Framework · WordPress · Log in