Friday, May 22, 2009

How to stop and restart subversion using a simple script

1. create the svn restart script:
sudo nano /etc/init.d/restartsvn

sudo cat /etc/init.d/restartsvn
#!/bin/bash
echo This is a startup script to stop and restart subversion - Alan

echo Now stopping previous svn instance...
sudo kill -9 `ps aux | grep -i svn | grep -i listen-host | grep -v grep | awk '{print $2}'`

echo Sleeping 3 seconds...
#sleep 3 seconds
sleep 3

echo Now starting svn for you: /usr/bin/svnserve -d --listen-host 10.0.0.10 -r /srv/svn
/usr/bin/svnserve -d --listen-host 10.0.0.10 -r /srv/svn

echo The process id of the new svn instance is:
echo `ps aux | grep -i svn | grep -i listen-host | grep -v grep | awk '{print $2}'`
echo Done


2. make the script executable
sudo chmod u+x /etc/init.d/restartsvn

3. execute the script
sudo /etc/init.d/restartsvn

No comments:

Post a Comment