Linux下SVN(Subversion)自動啟動指令碼

來源:互聯網
上載者:User

標籤:

 

給大家分享下三種自動指令碼,由易到難!

本人使用的方法二,其它方法沒有實驗 指令碼一:下面的shell指令碼啟動,是根據多項目使用的svnserve
-d --listen-port 3690 -r /svnroot/rekfan.com/svnserve -d --listen-port 3691 -r /svnroot/rekfan.cn/svn預設啟動連接埠是3690,這裡有兩個svn庫,所以當出現這樣的情況時,上面的服務指令碼只會啟動一個svn庫.所以就需要使用shell指令碼來實現啟動兩個svn庫.vi /root/svn.shsvn.sh指令碼內容:#!/bin/bashsvnserve -d --listen-port 3690 -r /svnroot/rekfan.com/svnserve -d --listen-port 3691 -r /svnroot/rekfan.cn/然後添加可執行許可權chmod 700 /root/svn.sh或chmod ug+x /root/svn.sh添加到自動運行vi /etc/rc.local在最後添加一行內容/root/svn.sh然後重啟伺服器,使用ps aux|grep svn來查看svn是否啟動指令碼二:svn服務自啟動指令碼把指令碼放在/etc/init.d/下vi /etc/rc.d/init.d/svnsvn指令碼內容:#!/bin/bash# chkconfig: - 85 15# description: svn serverSVN_HOME=/svnroot/rekfan.comif [ ! -f "/usr/bin/svnserve" ]thenecho "svnserver startup: cannot start"exitficase "$1" instart)echo "Starting svnserve…"/usr/bin/svnserve -d --listen-port 3690 -r $SVN_HOMEecho "Finished!";;stop)echo "Stoping svnserve…"killall svnserveecho "Finished!";;restart)$0 stop$0 start;;*)echo "Usage: svn { start | stop | restart } "exit 1esac這裡請注意,不要刪除# chkconfig: - 85 15和# description: svn server,不然無法使用chkconfig加入服務,會提示service svn does not support chkconfig.然後執行chmod 755 /etc/init.d/svn
加入系統自動啟動:

在init.d目錄建立一個指令檔svnd.sh 
# cd /etc/init.d
# vim svnd.sh
輸入svnd.sh內容如下(/kaifa/svn 為svn倉庫目錄):

#!/bin/bash
#svnserve startup
/etc/init.d/svn restart

儲存退出。
更新,修改許可權:

chmod 755 svnd.sh
update-rc.d svnd.sh defaults


也可以使用下面的方法加上預設自動啟動:chkconfig
--add svnchkconfig svn on最後查看下chkconfig --list|grep svn指令碼三:#! /bin/sh -e### BEGIN INIT INFO# Provides: svnserve# Required-Start: $local_fs $syslog $remote_fs# Required-Stop: $local_fs $syslog $remote_fs# Default-Start: 2 3 4 5# Default-Stop: 0 1 6# Short-Description: Start/Stop svnserve### END INIT INFOPATH=/sbin:/usr/sbin:/bin:/usr/binDESC="svnserve"NAME=svnservePIDFILE=/var/run/$NAME.pidDAEMON=/usr/bin/$NAME#why add --pid-file parameter here? svnserve writes correct PID into PIDFILE.#start-stop-daemon writes the PID before the process running. It may cause the PID nubmer dismatch.#So, Please DO NOT rely on the --make-pidfile optionDAEMON_ARGS="-d -r /opt/svnproject --pid-file=$PIDFILE"SCRIPTNAME=/etc/init.d/$NAME[ -x "$DAEMON" ] || exit 0[ -r /etc/default/$NAME ] && . /etc/default/$NAME. /lib/lsb/init-functionsdo_start(){start-stop-daemon --start --quiet --exec $DAEMON --test > /dev/null /|| return 1start-stop-daemon --start --quiet --background --exec $DAEMON -- /$DAEMON_ARGS /|| return 2}#For those prcesses with chilren processes. Please stop with --exec, plus command name.#--pid-file can only kill parent process. All the children processes will be transferred to 1.do_stop(){start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --exec "$DAEMON"RETVAL="$?"[ "$RETVAL" = 2 ] && return 2start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec "$DAEMON"[ "$?" = 2 ] && return 2rm -f $PIDFILEreturn "$RETVAL"}case "$1" instart)log_daemon_msg "Starting $DESC" "$NAME"if [ -s $PIDFILE ] && kill -0 $(cat $PIDFILE) >/dev/null 2>&1; thenlog_daemon_msg "apparently already running"log_end_msg 0exit 0fido_startcase "$?" in0|1) log_end_msg 0 ;;2) log_end_msg 1 ;;esac;;stop)log_daemon_msg "Stopping $DESC" "$NAME"do_stopcase "$?" in0|1) log_end_msg 0 ;;2) log_end_msg 1 ;;esac;;restart|force-reload)log_daemon_msg "Restarting $DESC" "$NAME"do_stopcase "$?" in0|1)do_startcase "$?" in0) log_end_msg 0 ;;1) log_end_msg 1 ;; # Old process is still running*) log_end_msg 1 ;; # Failed to startesac;;*)# Failed to stoplog_end_msg 1;;esac;;*)echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2exit 3;;esacexit 0

Linux下SVN(Subversion)自動啟動指令碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.