#!/bin/sh #SVN路径 svn_path_1="http://192.168.1.201:8080/svn/" #SVN用户名/密码 svn_user="svncheck" svn_passwd="svncheck" #工作目录 cur_path="/root/shell/svn" #临时目录 tmp_path_1="$cur_path/tmp/test" #配置文件备份目录 bak_path="$cur_path/bakdir" #上次取下的版本 rev_file="$cur_path/rev_file" #svn记录 svn_log="$cur_path/svn.log" #SVN备注记录 svn_msg_log="$cur_path/svn_msg.log" #获取上次版本号 #test -f "$rev_file" && latest_rev=`cat $rev_file` || latest_rev=1 latest_rev=1 #echo $latest_rev #开始执行时间 echo `date +%F......%T` >>$svn_log #取SVN上最新版本号 head_rev=`svn info --username=$svn_user --password=$svn_passwd --no-auth-cache --non-interactive --xml $svn_path_1 | grep "revision" | head -1 |cut -d '"' -f2` #if [ "$head_rev" -gt "$latest_rev" ];then svn export --force --username=$svn_user --password=$svn_passwd --no-auth-cache --non-interactive $svn_path_1 $tmp_path_1 >>$svn_log # svn export --force --username=$svn_user --password=$svn_passwd --no-auth-cache --non-interactive $svn_path_2 $tmp_path_2 >>$svn_log if [ "$?" == 0 ];then echo "$head_rev" > $rev_file fi #最终不变的配置文件 # rm -fr $tmp_path_1/static/domain.inc #更改权限 chmod -R 777 $tmp_path_1/protected/runtime #发布到本机最终目录 #if [ `ls -al $tmp_path_1|wc -l` != 3 ];then cp -pfr $tmp_path_1/* /var/www/WWW_ROOT_DEV/ # cp -pfr $tmp_path_1/* /var/www/WWW_ROOT_DER # cp -pfr $tmp_path_1/* /var/www/WWW_ROOT_DEW/ #发布到192.168.1.252 # scp -rp $tmp_path_1/* 192.168.1.252:/var/www/WWW_ROOT_DEX # fi #发布到本机最终目录 # if [ `ls -al $tmp_path_2|wc -l` != 3 ];then # cp -pfr $tmp_path_2/* /var/comm_der/ # cp -pfr $tmp_path_2/* /var/comm_dev/ # cp -pfr $tmp_path_2/* /var/comm_dew/ #发布到192.168.1.252 # scp -rp $tmp_path_2/* 192.168.1.252:/var/comm_dex # fi #清空临时目录 rm -fr $tmp_path_1/* #执行其它的脚本 # /var/www/scheme/go #提示消息 echo "已取出最新版本$head_rev发布完成!" #else # echo "SVN上没有最新版本!无需发布" #fi