Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1416112
  • 博文数量: 264
  • 博客积分: 5810
  • 博客等级: 大校
  • 技术积分: 3528
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-13 17:15
文章分类

全部博文(264)

文章存档

2011年(264)

分类: 系统运维

2011-04-06 22:43:06

pre-commit-post钩子
  1. #/bin/bash
  2. REPOS=$1
  3. TXN=$2

  4. export HOME=/
  5. export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

  6. SVNLOOK=/usr/bin/svnlook
  7. CAT="$SVNLOOK cat -t $TXN $REPOS"
  8. $SVNLOOK changed -t "$TXN" "$REPOS" |awk '$1~/^[^D]/{print $NF}' |while read line; do
  9.         #bash syntax check
  10. # if echo $line |grep -q '\.sh$'; then
  11. # $CAT $line |bash -n 2>&2 && continue
  12. # echo "BASH SYNTAX ERROR: $line" >&2
  13. # exit 4
  14. # fi
  15.         #perl syntax check
  16.         if echo $line |grep -q '\.pl$'; then
  17.                 $CAT $line |perl -c 2>&2 && continue
  18.                 echo "PERL SYNTAX ERROR: $line" >&2
  19.                 exit 4
  20.         fi
  21.         #puppet syntax check
  22.         if echo $line |grep -q '\.pp$'; then
  23.                 $CAT "$line" |puppet --color=false --parseonly --ignoreimport >&2
  24.                 [ $? -eq 0 ] && continue
  25.                 echo "PUPPET SYNTAX ERROR: $line" >&2
  26.                 exit 4
  27.         fi
  28.         #erb syntax check
  29.         if echo $line |grep -q '\.erb$'; then
  30.                 $CAT $line |erb -x -T '-' |ruby -c 2>&2 && continue
  31.                 echo "ERB SYNTAX ERROR: $line" >&2
  32.                 exit 4
  33.         fi
  34. done
post-commit
  1. #!/bin/bash
  2. /usr/bin/svn update /etc/puppet/ --username test --password test >> /tmp/abc.out
  3. if [ $? == 0 ]
  4. then
  5.        echo "ok" >> /tmp/thisabc.out
  6.        /bin/rsync -avztpogdH --password-file=/opt/my2 /etc/puppet root@xxx.xxx.xxx.xxx::abc
  7. fi

阅读(1023) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~