Created
May 26, 2015 16:24
-
-
Save crossai-2033/e4134b90d081ea2e5ead to your computer and use it in GitHub Desktop.
发布脚本配置文件
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
########################################################################### | |
# 配置项 | |
# 项目名称 | |
prj_name="xxxxx" | |
# 线上集群列表 | |
a_clusters="a_1" | |
b_clusters=" | |
b_1 | |
b_2 | |
b_3 | |
" | |
c_clusters=" | |
c_1 | |
c_2 | |
c_3 | |
" | |
online_clusters="$a_clusters $b_clusters $c_clusters" | |
# 目标机器的目录 | |
online_prj_home="/home/xx/xx" | |
dst="$online_prj_home/$prj_name" | |
# SVN 地址 | |
#svn="xxx" | |
# GIT 地址 | |
git="xxx/$prj_name" | |
#使用svn或git | |
repository="git" | |
#当前版本 | |
version="1.0.0" | |
# 同步所使用的用户 | |
ssh_user="xxx"; | |
# 文件黑名单 | |
blacklist='(.*\.tmp$)|(.*\.log$)|(.*\.svn.*)' | |
########################################################################### | |
# 公共库 | |
# print colored text | |
# $1 = message | |
# $2 = color | |
# 格式化输出 | |
export black='\E[0m\c' | |
export boldblack='\E[1;0m\c' | |
export red='\E[31m\c' | |
export boldred='\E[1;31m\c' | |
export green='\E[32m\c' | |
export boldgreen='\E[1;32m\c' | |
export yellow='\E[33m\c' | |
export boldyellow='\E[1;33m\c' | |
export blue='\E[34m\c' | |
export boldblue='\E[1;34m\c' | |
export magenta='\E[35m\c' | |
export boldmagenta='\E[1;35m\c' | |
export cyan='\E[36m\c' | |
export boldcyan='\E[1;36m\c' | |
export white='\E[37m\c' | |
export boldwhite='\E[1;37m\c' | |
cecho() | |
{ | |
message=$1 | |
color=${2:-$black} | |
echo -e "$color" | |
echo -e "$message" | |
tput sgr0 # Reset to normal. | |
echo -e "$black" | |
return | |
} | |
cread() | |
{ | |
color=${4:-$black} | |
echo -e "$color" | |
read $1 "$2" $3 | |
tput sgr0 # Reset to normal. | |
echo -e "$black" | |
return | |
} | |
# 确认用户的输入 | |
deploy_confirm() | |
{ | |
while [ 1 = 1 ] | |
do | |
cread -p "$1 [y/n]: " CONTINUE $c_notify | |
if [ "y" = "$CONTINUE" ]; then | |
return 1; | |
fi | |
if [ "n" = "$CONTINUE" ]; then | |
return 0; | |
fi | |
done | |
return 0; | |
} | |
########################################################################### | |
# Start | |
export LC_ALL="zh_CN.GB2312" | |
prj_nam=`basename $dst` | |
# | |
SSH="sudo -u $ssh_user ssh -c blowfish" | |
SCP="sudo -u $ssh_user scp -c blowfish" | |
# 提示颜色 | |
c_notify=$boldcyan | |
c_error=$boldred |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment