Sunday, September 20, 2009

Creating a startup script for svnserve on Ubuntu - init.d/skeleton

I am finally moving from my Suse Sles server and switched to Ubuntu (8.1.10 - 64 bits). As on my desktop I put webmin to manage the server processes. Simple and easy.

Installing svnserve (subversion) is easy thanks to synaptic - the package manager. The only missing piece is the startup script.

I first though porting the Suse script to Ubuntu. Not that simple.

I found the following link explaining how to proceed chttp://benrobb.com/2007/01/15/howto-start-subversion-at-boot-on-ubuntu/

Basiscally the start is creating a one line script and putting the correct link to rcX.d directories (sudo update-rc.d svnserve defaults).

One user 'Sean O' helped a bit further. Thanks to him I know about the skeleton script in init.d.

This is the starting point for building a correct script. I modified shortly the script by adapting properly the variables such as :

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
USERNAME=svn

I added the USERNAME variable. It is referenced in the script like this

start-stop-daemon --start --quiet --chuid $USERNAME --make-pidfile --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS

This will now start the process under the svn account instead of root. The key is the command start-stop-daemon. Anyway I need a good book of practicall syadmin for Ubuntu...

No comments: