| 123456789101112131415161718192021222324252627282930313233343536373839 |
- #!/bin/bash
- #set -e
- project_root_dir=$(
- cd "$(dirname "$(realpath "$0")")" || exit
- pwd
- )
- function log() {
- echo -e "${NORM_CYN}$(date '+%Y-%m-%d %H:%M:%S') ${DO_RESET}${1}${DO_RESET}"
- }
- if [ "root" = "$(whoami)" ]; then
- log "${NORM_RED}禁止使用 ${NORM_GRN}root${NORM_MGT} 用户进行发布"
- exit 18
- fi
- . "${project_root_dir}/bin/common/functions.sh"
- RELEASE_ROOT_DIR="/home/alvis/release"
- project_name=$(basename "${project_root_dir}")
- # 自定义分发所有节点的函数脚本,目前放在bin/common 目录中
- source /etc/.bash_profile
- function display() {
- du -d 0 "${RELEASE_ROOT_DIR}/${project_name}"
- re-all du -d 0 "${RELEASE_ROOT_DIR}/${project_name}"
- }
- #异常处理机制 用于切换到指定的目录,如果失败则退出脚本。
- cd "${RELEASE_ROOT_DIR}/${project_name}" || exit
- git branch
- git checkout release
- git checkout .
- git fetch --prune
- git pull
- re-all "cd ${RELEASE_ROOT_DIR}/${project_name} && git checkout . && git fetch --prune && git pull"
- rm -f dw_base.zip
- re-all "cd ${RELEASE_ROOT_DIR}/${project_name} && rm -f dw_base.zip"
- display
- chmod 775 "${RELEASE_ROOT_DIR}/${project_name}/publish.sh"
- chmod 775 -R "${RELEASE_ROOT_DIR}/${project_name}/bin"
- re-all chmod 775 -R "${RELEASE_ROOT_DIR}/${project_name}/bin"
- sync2all-hosts "${RELEASE_ROOT_DIR:?}/datasource"
- #sync2all-hosts "${RELEASE_ROOT_DIR:?}/mongo2es-customs"
- echo "发布完毕"
|