svn shell脚本
该脚本用于服务器启动时启动svn
#chkconfig: 345 60 60
#!/bin/bash
SVN_HOME=/web/software/svn/bin
SVNNAME=Subversion
start()
{
/bin/su - svn -c "$SVN_HOME/svnserve -d -r /web/repo"
echo $"Starting $SVNNAME:[OK] "
}
stop()
{
#/usr/bin/pgrep svnserve | /usr/bin/xargs /bin/kill -9
/bin/ps aux| /bin/awk '/svnserve/ && !/awk/{print $2}'| /usr/bin/xargs /bin/kill -9 1>/dev/null 2>/dev/null
result=$?
if [ $result -eq 0 ];
then
echo "Stopping $SVNNAME:[OK] "
else
echo $"Stopping $SVNNAME:[Failure] "
echo -n $"$SVNNAME is Running"
echo
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 3
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0
说明
/bin/su - svn -c "$SVN_HOME/svnserve -d -r /web/repo" 以svn 用户启动后台监控svn目录
/bin/ps aux| /bin/awk '/svnserve/ && !/awk/{print $2}'| /usr/bin/xargs /bin/kill -9 1>/dev/null 2>/dev/null 检测当前是否存在svn的pid 如果存在的话则调用kill方法关闭svn