Install subversion on centos cpanel vps with autostart script on reboot

I learned this stuff by searching and want to add a quick reference here for others. To install subverion on CentOS, just do:

# yum install subversion

Make sure if "perl-URI" is installed or not. If its not there you can install it using

# yum install perl-URI

Now you may stuck here, because yum may not install perl-URI, why? If you have cpanel, probably you have added perl* to /etc/yum.conf exclude list. Just remove it and install perl-URI, then revert it. The next thing was to create a repository.

# cd /home/username # mkdir repos # svnadmin create /home/username/repos/myProject1

I always create a symlink to make things easier:

# ln -s /home/username/repos /svn

Now to start subversion as daemon do:

# svnserve -d -r /svn

Ok, we need to setup subversion autostart at reboot. I just found a script sometime somewhere on internet and I do not really remember who was the author, but thanks to the guy, I edited the script to suit my needs. Below is the working result, I tested and installed it on CentOS x86_64

#   /etc/rc.d/init.d/subversion
# Starts the Subversion Daemon
# chkconfig: 345 90 10
# description: Subversion Daemon
# processname: svnserve
source /etc/rc.d/init.d/functions
[ -x /usr/bin/svnserve ] || exit 1
# To pass additional options (for instace, -r root of directory to server) to
# the svnserve binary at startup, set OPTIONS here.
OPTIONS="-r /svn"
desc="Subversion Daemon"
start() {
        echo -n $"Starting $desc ($prog): "
   daemon $prog -d $OPTIONS
   [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
stop() {
   echo -n $"Shutting down $desc ($prog): "
   killproc $prog
   [ $RETVAL -eq 0 ] && success || failure
   [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
   return $RETVAL
case "$1" in
        [ -e /var/lock/subsys/$prog ] && restart
   echo $"Usage: $0 {start|stop|restart|condrestart}"
exit $RETVAL

Save this script on /etc/init.d/subversion and make it chmod 0750 Execute /etc/init.d/subversion and make sure it does not have any error. To make it autostart at reboot time, we should use chkconfig facility on RedHat/CentOS.

# chkconfig --level 345 subversion on

To get more info on chkconfig see man chkconfig and man runlevel, and Now start/restart svn server and check it works.

# /etc/init.d/subversion restart

Yes, it was so easy, no? ;)