#!/bin/sh
export LANG=en_US.UTF-8
#仓库
REPOS="$1"
#提交版本
REV="$2"
SVN_LOOK_PATH=/usr/bin/svnlook
SVN_PATH=/usr/bin/svn
#svn用户
SVN_USER=svnUser
#svn用户密码
SVN_PASS=svnPass
#更新的目录
CHANGEDDIRS=$($SVN_LOOK_PATH dirs-changed $REPOS)
#提交作者
AUTHOR=$($SVN_LOOK_PATH author -r $REV "$REPOS")
#提交的备注
MESSAGE=$($SVN_LOOK_PATH log -r $REV "$REPOS")
TIME=$(date "+%Y-%m-%d %H:%M:%S")
S_TIME=$(date +%s)
#日志文件
SVN_LOG_FILE=/var/log/svn/svn_log.log
#目标路径
TARGET_PATH=/data/game1
exec 1>>"$SVN_LOG_FILE"
exec 2>&1
#需要更新的路径
SVN_UP_PATH_ARRAY=(
trunk/json
trunk/server
trunk/client
)
function myecho() {
echo "$TIME" "$*"
}
is_need_update() {
for var in ${SVN_UP_PATH_ARRAY[@]};
do
if [ $flag = false ]
then
if [[ $1 == $var* ]]
then
flag=true
fi
fi
done
}
for dir in $CHANGEDDIRS
do
flag=false
is_need_update $dir
if [ $flag = true ]
then
$SVN_PATH update $TARGET_PATH/$dir --username $SVN_USER --password $SVN_PASS --no-auth-cache
fi
done
E_TIME=$(date +%s)
COST_TIME=`expr $E_TIME - $S_TIME`
myecho
myecho "**************************************************************"
myecho "提交版本:$REV 作者:$AUTHOR"
myecho "提交备注:$MESSAGE"
myecho "耗时:$COST_TIME"
myecho "修改目录:$(echo $CHANGEDDIRS | tr '\n' ' | ')"