Chinaunix首页 | 论坛 | 博客

OPS

  • 博客访问: 485234
  • 博文数量: 117
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1210
  • 用 户 组: 普通用户
  • 注册时间: 2015-05-05 14:50
个人简介

hellow 运维

文章分类

全部博文(117)

文章存档

2019年(1)

2018年(1)

2017年(45)

2016年(38)

2015年(32)

我的朋友

分类: 系统运维

2016-04-13 11:05:31





#!/bin/bash
#function master() {
#git hooks is post-commit
REPOS="$1"
REV="$2"
#文件日志存放位置
log="/var/log/svn.log"
#项目update位置
DIR=/data/backup/svnrepos
#备份文件目录{上一量级代码}
backDIR="/data/backup/test"
#正式服务提供服务位置{新代码}
webDIR="/data/backup/src"
zwebDIR="/data/mydate"
#环境字符
export LC_ALL=en_US.UTF-8
export LANG=zh_CN.UTF-8
CURDATE=`date +%Y-%m-%d`
echo "code deployed by at $CURDATE,$REPOS,$REV" >> $log
#代码更新存放目录
svn update  /data/backup/svnrepos/  --username hanye --password hanye131
#匹配文件是否更新完成,是,执行文件的备份,和上次代码文件的备份,和代码的回滚的匹配
if [  $? -eq 0 ]; then
  echo -e "\033[33;31m svn update success\033[0m" >> $log
  cd /data/backup/svnrepos/

   config1=`cat confile  | sed -n '1p'`
   config2=`cat confile  | sed -n '2p'`
   if [ "$config1" == "master" ]; then
       if [ "$config2" == "online" ]; then
           cp $webDIR/* $backDIR/ -fr
           cp /data/backup/svnrepos/*  $webDIR/ -fr
           ansible 192.168.0.171 -m synchronize -a "src=$webDIR/ dest=$zwebDIR"
       elif [ "$config2" == "local" ];then
           echo "two line is local" >> $log
       fi
   elif [ "$config1" == "rollback" ]; then
     cp $backDIR/* $webDIR/ -fr
    ansible 192.168.0.171 -m synchronize -a "src=$backDIR/ dest=$zwebDIR"
  fi
else
   echo -e "\033[33;33m svn update not  success\033[0m"  >> $log
fi

# master 2>&1 | tee $log
#if [ "`cat $log  | grep -E 'error|failed|warning'|grep -v error.jsp|grep -v error.html|grep -v error.htm`" == "" ];then
 # echo "\033[33;31m Congratuations,push success!\033[0m"
#else
#   cat  $log | grep -E 'error|failed|warning'|grep -v error.jsp|grep -v error.html|grep -v error.htm
#   echo "\033[31;33m Push failed,please check the error message carefully!\033[0m"
#fi

阅读(1801) | 评论(0) | 转发(0) |
0

上一篇:tomcat 详细日志

下一篇:linux监控 netdata

给主人留下些什么吧!~~