publish.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/bash
  2. #set -e
  3. project_root_dir=$(
  4. cd "$(dirname "$(realpath "$0")")" || exit
  5. pwd
  6. )
  7. function log() {
  8. echo -e "${NORM_CYN}$(date '+%Y-%m-%d %H:%M:%S') ${DO_RESET}${1}${DO_RESET}"
  9. }
  10. if [ "root" = "$(whoami)" ]; then
  11. log "${NORM_RED}禁止使用 ${NORM_GRN}root${NORM_MGT} 用户进行发布"
  12. exit 18
  13. fi
  14. . "${project_root_dir}/bin/common/functions.sh"
  15. RELEASE_ROOT_DIR="/home/alvis/release"
  16. project_name=$(basename "${project_root_dir}")
  17. # 自定义分发所有节点的函数脚本,目前放在bin/common 目录中
  18. source /etc/.bash_profile
  19. function display() {
  20. du -d 0 "${RELEASE_ROOT_DIR}/${project_name}"
  21. re-all du -d 0 "${RELEASE_ROOT_DIR}/${project_name}"
  22. }
  23. #异常处理机制 用于切换到指定的目录,如果失败则退出脚本。
  24. cd "${RELEASE_ROOT_DIR}/${project_name}" || exit
  25. git branch
  26. git checkout release
  27. git checkout .
  28. git fetch --prune
  29. git pull
  30. re-all "cd ${RELEASE_ROOT_DIR}/${project_name} && git checkout . && git fetch --prune && git pull"
  31. rm -f dw_base.zip
  32. re-all "cd ${RELEASE_ROOT_DIR}/${project_name} && rm -f dw_base.zip"
  33. display
  34. chmod 775 "${RELEASE_ROOT_DIR}/${project_name}/publish.sh"
  35. chmod 775 -R "${RELEASE_ROOT_DIR}/${project_name}/bin"
  36. re-all chmod 775 -R "${RELEASE_ROOT_DIR}/${project_name}/bin"
  37. sync2all-hosts "${RELEASE_ROOT_DIR:?}/datasource"
  38. #sync2all-hosts "${RELEASE_ROOT_DIR:?}/mongo2es-customs"
  39. echo "发布完毕"