SVN服務啟動指令碼
阿新 • • 發佈:2020-09-11
#!/bin/bash # # author:liusha # description: SVN Server start|stop|restart|status. USER=root HOME=/home/svn SERVER_NAME="SVN Server" pid=0 #獲取程序號 getPid() { pid=`ps -ef |grep svnserve |grep -v "grep" |awk '{print $2}'` } #啟動服務 start() { getPid if [ ! -n "$pid" ]; then SVN_CMD="svnserve -d -r $HOME" echo "$SERVER_NAME Start-----------------" su $USER -c "$SVN_CMD" echo "$SERVER_NAME Finish----------------" else echo "$SERVER_NAME is runing PID: $pid" fi } #停止服務 stop() { getPid if [ ! -n "$pid" ]; then echo "$SERVER_NAME not runing" else echo "$SERVER_NAME stop..." kill -9 $pid fi } #重啟服務 restart() { stop sleep 1s start } #服務狀態 status() { getPid if [ ! -n "$pid" ]; then echo "$SERVER_NAME not runing" else echo "$SERVER_NAME is runing PID: $pid" fi } case $1 instart) start ;; stop) stop ;; restart) restart ;; status) status ;; *) echo "$0: Usage: $0 {start|stop|restart|status}" exit 1 ;; esac