publish.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. source /etc/.bash_profile
  16. . "${project_root_dir}/conf/env.sh"
  17. project_name=$(basename "${project_root_dir}")
  18. function display() {
  19. du -d 0 "${RELEASE_ROOT_DIR}/${project_name}"
  20. re-all du -d 0 "${RELEASE_ROOT_DIR}/${project_name}"
  21. }
  22. #异常处理机制 用于切换到指定的目录,如果失败则退出脚本。
  23. cd "${RELEASE_ROOT_DIR}/${project_name}" || exit
  24. git branch
  25. git checkout release
  26. git checkout .
  27. git fetch --prune
  28. git pull
  29. re-all "cd ${RELEASE_ROOT_DIR}/${project_name} && git checkout . && git fetch --prune && git pull"
  30. rm -f dw_base.zip
  31. re-all "cd ${RELEASE_ROOT_DIR}/${project_name} && rm -f dw_base.zip"
  32. display
  33. chmod 775 "${RELEASE_ROOT_DIR}/${project_name}/publish.sh"
  34. chmod 775 -R "${RELEASE_ROOT_DIR}/${project_name}/bin"
  35. re-all chmod 775 -R "${RELEASE_ROOT_DIR}/${project_name}/bin"
  36. sync2all-hosts "${RELEASE_ROOT_DIR:?}/datasource"
  37. #sync2all-hosts "${RELEASE_ROOT_DIR:?}/mongo2es-customs"
  38. echo "发布完毕"