12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #!/bin/bash -c
- app_names=("zookeeper" "kibana" "elasticsearch")
- envs=("qa" "pro")
- #当前目录
- DEPLOY_HOME=$(
- cd $(dirname $0)
- pwd
- )
- echo "----------------------------------"
- echo "选择要部署的应用:"
- echo "(0) zookeeper"
- echo "(1) kibana"
- echo "(2) elasticsearch"
- echo "----------------------------------"
- while [ 1 ]; do
- read input1
- if ! [[ $input1 =~ ^[0-9](,[0-9])*$ ]]; then
- echo "请输入[0-2]之间的数字:"
- continue
- fi
- if [ $input1 -ge 0 -a $input1 -le 2 ]; then
- currApp=${app_names[$input1]}
- break
- else
- echo "请输入[0-2]之间的数字:"
- fi
- done
- echo "----------------------------------"
- echo "运行环境:"
- echo "(0) qa"
- echo "(1) pro"
- echo "----------------------------------"
- while [ 1 ]; do
- read input1
- if ! [[ $input1 =~ ^[0-9](,[0-9])*$ ]]; then
- echo "请输入[0-1]之间的数字:"
- continue
- fi
- if [ $input1 != 1 -o $input1 -lt 0 -o $input1 -gt 2 ]; then
- ENV=${envs[$input1]}
- break
- else
- echo "请输入[0-1]之间的数字:"
- fi
- done
- echo "----------------------------------"
- echo "最终要部署的应用${currApp}"
- echo "环境${ENV}"
- echo "----------------------------------"
- cd $DEPLOY_HOME || exit
- rm -rf .tmp && mkdir .tmp && cd .tmp || exit
- git config --global user.email "yangxg_yang@easou.cn"
- git config --global user.name "${USER}"
- git config --global credential.helper store
- git clone http://yangxg:yangtxy1256@gogs.ieasou.cn/yangxg/${currApp}.git ${currApp} && cd ${currApp} || exit
- cp -f ../../deploy-tmp-${currApp}.yaml deploy-tmp.yaml
- cp -f ../../drone.${currApp}.yml .drone.yml
- cp -f ../../Dockerfile-${currApp} Dockerfile
- git add deploy-tmp.yaml
- git add .drone.yml
- git add Dockerfile
- echo "git commit"
- git commit --allow-empty -m "deploy $ENV/${currApp}:1.0"
- echo "git push"
- git push origin master
- cd $DEPLOY_HOME || exit
- rm -rf .tmp
|