我用 LinuxLinuxLinux学习之路

SVN篇:Shell脚本实现SVN启动,停止,重启

2019-08-02  本文已影响3人  walker86

话不多说,直接粘贴上以下脚本:

#!/bin/bash

case "$1" in

start)

        /usr/local/subversion/bin/svnserve -d -r /data/svn/repos/

        svnport=`netstat -natp | grep svnserve | awk -F: '{print $4}' | awk 'NR==1'`

        if [ $svnport -eq 3690 ]

        then

                echo "SVN Server Already Runnning. Port:3690"

        else

                echo "SVN Server Does Not Start"

        fi

reload)

        svnport=`netstat -natp | grep svnserve | awk -F: '{print $4}' | awk 'NR==1'`

        if [ $svnport -eq 3690 ]

        then

                killall svnserve 

               /usr/local/subversion/bin/svnserve -d -r /data/svn/repos/

                echo "Reload OK"

        else

                echo "SVN Server Is Not Running"

        fi

stop)

        killall svnserve

        echo "SVN Server Has Been Stopped"

status)

        svnport=`netstat -natp | grep svnserve | awk -F: '{print $4}' | awk 'NR==1'`

        pid=`ps aux | grep svnserve | grep -v "grep" | awk '{print $2}'`

        if [ $svnport -eq 3690 ]

        then

                echo "SVN Server (pid:$pid) 正在运行..."

        else

                echo "SVN Server 停止运行..."

        fi

*)

        echo "$0: Usage: $0 {start|status|stop|reload}"

        exit 1

esac

上一篇 下一篇

猜你喜欢

热点阅读