CentOS 5.2 SVN/Subversion Server

Here is a quick set of instructions for building a SVN server on Linux CentOS 5.2. I used it for a while unit I created one on Ubuntu 8.10

Check to see if SVN/Subversion is install on your box
which svn
If it is not installed then please install the application before continuing. Continue if already installed.
cd /etc/init.d/
/sbin/chkconfig --add svnserve
Now we want to make the configuration for the SVN Serve daemon so it starts when it is rebooted.
nano svnserve
Now that the editor is up paste the information below into the file.
#!/bin/bash
#
#   /etc/rc.d/init.d/subversion
#
# Starts the Subversion Daemon
#
# chkconfig: 2345 90 10
# description: Subversion Daemon
# processname: svnserve
# pidfile: /var/lock/subsys/svnserve

source /etc/rc.d/init.d/functions

[ -x /usr/bin/svnserve ] || exit 1

### Default variables
SYSCONFIG="/etc/sysconfig/subversion" 

### Read configuration
[ -r "$SYSCONFIG" ] && source "$SYSCONFIG" 

RETVAL=0
prog="svnserve"
arthur=" --listen-host 192.168.0.92 -r /var/repositories"
desc="Subversion Daemon"
pidfile="/var/run/$prog.pid" 

start() {
   echo -n $"Starting $desc ($prog): "
   daemon $prog -d $arthur --pid-file $pidfile
   RETVAL=$?
   if [ $RETVAL -eq 0 ]; then
     touch /var/lock/subsys/$prog
   fi
   echo
}

obtainpid() {
   pidstr=`pgrep $prog`
   pidcount=`awk -v name="$pidstr" 'BEGIN{split(name,a," "); print length(a)}'`
   if [ ! -r "$pidfile" ] && [ $pidcount -ge 2 ]; then
        pid=`awk -v name="$pidstr" 'BEGIN{split(name,a," "); print a[1]}'`
        echo $prog is already running and it was not started by the init script.
   fi
}

stop() {
   echo -n $"Shutting down $desc ($prog): "
   if [ -r "$pidfile" ]; then
        pid=`cat $pidfile`
        kill -s 3 $pid
        RETVAL=$?
   else
           RETVAL=1
   fi
   [ $RETVAL -eq 0 ] && success || failure
   echo
   if [ $RETVAL -eq 0 ]; then
     rm -f /var/lock/subsys/$prog
     rm -f $pidfile
   fi
   return $RETVAL
}

restart() {
        stop
     start
}

forcestop() {
   echo -n $"Shutting down $desc ($prog): " 

   kill -s 3 $pid
   RETVAL=$?
   [ $RETVAL -eq 0 ] && success || failure
   echo
   if [ $RETVAL -eq 0 ]; then
     rm -f /var/lock/subsys/$prog
     rm -f $pidfile
   fi

   return $RETVAL
}

status() {
   if [ -r "$pidfile" ]; then
        pid=`cat $pidfile`
   fi
   if [ $pid ]; then
           echo "$prog (pid $pid) is running..."
   else
        echo "$prog is stopped"
   fi
}                                                                           

obtainpid

case "$1" in
  start)
   start
   ;;
  stop)
   stop
   ;;
  restart)
   restart
   RETVAL=$?
   ;;
  condrestart)
   [ -e /var/lock/subsys/$prog ] && restart
   RETVAL=$?
   ;;
  status)
   status
   ;;
  forcestop)
   forcestop
   ;;
  *)
   echo $"Usage: $0 {start|stop|forcestop|restart|condrestart|status}"
   RETVAL=1
esac

exit $RETVAL
Now that the code has been copied save the file. Now we need to make it executable by the OS.
chmod +x svnserve
now you should reboot to make sure you all good and the service restarts when the system comes up also you should be able to run this from the command line to start it.
/etc/init.d/svnserve start
Alternatively you can add
/etc/init.d/svnserve sto
/etc/init.d/svnserve restart

Comments

Popular posts from this blog

Console over SSH (ONTAP)

Brocade Zone Setup

OpenSolaris ZFS Setup