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 *************************
点击查看更多内容
1人点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦