Authored by jimi.ji

docker

#!/usr/bin/expect
set CD_PATH [lindex $argv 0]
set CONFIG_PATH [lindex $argv 1]
set GLOBAL_CONFIG_PATH [lindex $argv 2]
set timeout -1
cd $CD_PATH
spawn sh ./mvn-package.sh $CONFIG_PATH $GLOBAL_CONFIG_PATH
expect "您需要现在更新此文件吗"
send "Yes\r"
expect "请选择"
send "Quit\r"
expect "即将保存到文件"
send "Yes\r"
expect eof
#!/bin/bash
function usage(){
echo "----------------------------------"
echo "参数说明:"
echo "-g : 代码所在的组名"
echo "-b : 代码所在的分支名"
echo "-a : 代码所属系统名"
echo "-s : 部署环境名"
echo "-i : 镜像信息 "
echo ""
echo "举例:sh packageDockerImage.sh -g yoho30 -b master -a yoho-gateway -s yoho-online -w /Data/dockerPackage"
echo "----------------------------------"
}
USER=$(whoami)
if [[ "$USER" != "root" ]];then
echo "ERROR:需切换到root用户!"
exit 1
fi
if [[ $# -lt 1 ]];then
usage
exit 1
fi
while getopts "g:b:a:s:w:" arg
do
case $arg in
g)
CODE_GROUP=$OPTARG
;;
w)
WORK_SPACE=$OPTARG
;;
b)
CODE_BRANCH=$OPTARG
;;
a)
SYSTEM_NAME=$OPTARG
;;
s)
ENV_NAME=$OPTARG
;;
h)
usage
exit 1
;;
?)
echo "ERROR:未知的参数!"
exit 1
;;
esac
done
if [[ ! $CODE_GROUP || ! $CODE_BRANCH || ! $SYSTEM_NAME || ! $ENV_NAME ]];then
echo "ERROR:参数不全!"
exit 1
fi
CURRENT_PATH=$(cd `dirname $0`; pwd)
PACKAGE_PATH=$WORK_SPACE
cd $PACKAGE_PATH
#下包
git clone -b master git@git.yoho.cn:yohoops/auto_deploy_test.git
git clone -b $CODE_BRANCH git@git.yoho.cn:$CODE_GROUP/$SYSTEM_NAME.git
#打包
source /etc/profile
AUTOCONFIG_PATH=$PACKAGE_PATH/auto_deploy_test/autoconfig/$ENV_NAME
expect $CURRENT_PATH/expectPackage.exp $PACKAGE_PATH/$SYSTEM_NAME/bin $AUTOCONFIG_PATH/$SYSTEM_NAME-autoconfig.properties $AUTOCONFIG_PATH/global-autoconfig.properties
#解包
TARGET_PAHT=$PACKAGE_PATH/$SYSTEM_NAME/deploy/target
NAMESPACE=$(cat ${TARGET_PAHT}/bin/env.sh | grep SERVER_NAMESPACE= | awk -F '=' '{print $2}')
cd $TARGET_PAHT
mv *.war ${NAMESPACE}.war
echo "==============${NAMESPACE}.war"
\ No newline at end of file