SVN Commit 根据不同学科自动发送邮件
SVN 配置:
1、编辑authz
vi /var/svn/svnrepos/conf/authz
managers = xxx
middle_chineses = xxx
high_chineses = xxx
small_maths = xxx
middle_maths = xxx
high_maths = xxx
middle_chems = xxx
high_chems = xxx
middle_englishs = xxx
high_englishs =xxx
middle_physics = xxx
high_physics = xxx
[/]
@managers = rw
* = r
[/陕西]
@managers = rw
@middle_chineses = r
@high_chineses = r
@small_maths = r
@middle_maths = r
@high_maths = r
@middle_chems = r
@high_chems = r
@middle_englishs = r
@high_englishs = r
@middle_physics = r
@high_physics = r
* =
[/陕西/语文]
@managers = rw
@middle_chineses = r
@high_chineses = r
* =
[/陕西/数学]
@managers = rw
@small_maths = r
@middle_maths = r
@high_maths = r
* =
[/陕西/化学]
@managers = rw
@middle_chems = r
@high_chems = r
* =
[/陕西/英语]
@managers = rw
@middle_englishs = r
@high_englishs = r
* =
[/陕西/物理]
@managers = rw
@middle_physics = r
@high_physics = r
* =
[/陕西/语文/初中语文]
@managers = rw
@middle_chineses = rw
* =
[/陕西/语文/高中语文]
@managers = rw
@high_chineses = rw
* =
[/陕西/数学/小学数学]
@managers = rw
@small_maths = rw
* =
[/陕西/数学/初中数学]
@managers = rw
@middle_maths = rw
* =
[/陕西/数学/高中数学]
@managers = rw
@high_maths = rw
* =
[/陕西/化学/初中化学]
@managers = rw
@middle_chems = rw
* =
[/陕西/化学/高中化学]
@managers = rw
@high_chems = rw
* =
[/陕西/英语/初中英语]
@managers = rw
@middle_englishs = rw
* =
[/陕西/英语/高中英语]
@managers = rw
@high_englishs = rw
* =
[/陕西/物理/初中物理]
@managers = rw
@middle_physics = rw
* =
[/陕西/物理/高中物理]
@managers = rw
@high_physics = rw
* =
2、编辑password
vi /var/svn/svnrepos/conf/passwd
更新自动发送邮件:
1、安装相关组建
yum install sendmail
systemctl start sendmail.service
chkconfig sendmail on
service sendmail start
2、测试邮件
echo "Hello World" | mail abc@abc.com
3、设置发件人
vi /etc/mail.rc
set from=xxx@126.com
set smtp=smtp.126.com
set smtp-auth-user=xxx@126.com smtp-auth-password=xxx
set smtp-auth=login
4、编辑SVN Commit文件
vi /var/svn/svnrepos/hooks/post-commit
#!/bin/sh
REPOS="$1"
REV="$2"
export LANG=en_US.UTF-8
# ************************* SVN info start *************************
LIMITDIFF=200
AUTHOR=`svnlook author -r $REV $REPOS`
CHANGED=`svnlook changed -r $REV $REPOS`
MESSAGE=`svnlook log -r $REV $REPOS`
DIRCHANGED=`svnlook dirs-changed -r $REV $REPOS`
DATE=$(date "+%Y-%m-%d %H:%M:%S")
LOGINFO=/var/svn/svnrepos/log/$AUTHOR-$REV.log
CHANGEDNAME=${DIRCHANGED:6:4}
SUBJECT="SVN $CHANGEDNAME更新通知 系统版本号【$REV】"
REMARKS=""
if [ -n "$MESSAGE" ]; then
REMARKS="备注:$MESSAGE"
fi
echo "SVN $CHANGEDNAME更新通知:
版本号: $REV
作者: $AUTHOR
时间: $DATE
$REMARKS
文件目录(A: 添加 U:修改 D:删除):
$CHANGED
" > $LOGINFO
# ************************* SVN info start *************************
# ************************* Send email start *************************
MANAGERS="xxx@126.com,"
MIDDLE_CHINESES="xxx@126.com"
MIDDLE_CHINESES="xxx@126.com"
SMALL_MATHS="xxx@126.com"
MIDDLE_MATHS="xxx@126.com"
HIGH_MATHS="xxx@126.com"
MIDDLE_CHEMS="xxx@126.com"
HIGH_CHEMS ="xxx@126.com"
MIDDLE_ENGLISHS="xxx@126.com"
HIGH_ENGLISHS="xxx@126.com"
MIDDLE_PHYSICS="xxx@126.com"
HIGH_PHYSICS="xxx@126.com"
CHANGEDTO=""
case $CHANGEDNAME in
"初中语文")
CHANGEDTO=$MIDDLE_ENGLISHS
;;
"高中语文")
CHANGEDTO=$HIGH_ENGLISHS
;;
"小学数学")
CHANGEDTO=$SMALL_MATHS
;;
"初中数学")
CHANGEDTO=$MIDDLE_MATHS
;;
"高中数学")
CHANGEDTO=$HIGH_MATHS
;;
"初中化学")
CHANGEDTO=$MIDDLE_CHEMS
;;
"高中化学")
CHANGEDTO=$HIGH_CHEMS
;;
"初中英语")
CHANGEDTO=$MIDDLE_ENGLISHS
;;
"高中英语")
CHANGEDTO=$HIGH_ENGLISHS
;;
"初中物理")
CHANGEDTO=$MIDDLE_PHYSICS
;;
"高中物理")
CHANGEDTO=$HIGH_PHYSICS
;;
esac
SENDTO=$MANAGERS$CHANGEDTO
mail -s "$SUBJECT" "$SENDTO" < "$LOGINFO"
# rm $LOGINFO
# ************************* Send email end *************************
打开App,阅读手记
热门评论
发布样式乱了,预览样式正常的