您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

deploy-directory-to-remote.sh 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #! /bin/sh
  2. #
  3. if [ "$#" -eq 0 ] || [ "$#" -gt 1 ]; then
  4. echo takes only one argument
  5. exit 1
  6. fi
  7. if [ ! -e "${1}" ]; then
  8. echo cannot find "${1}"
  9. exit 1
  10. fi
  11. # shellcheck source=./deployment/deployment-example.env
  12. . "${1}"
  13. if [ "${do_backup}" = "yes" ]; then
  14. if ssh ${remote_ssh_string} "mkdir --parents ${remote_deployment_directory_path}"; then
  15. echo deployment folder successfully created on remote
  16. else
  17. echo deployment folder creation on remote failed
  18. exit 1
  19. fi
  20. if ssh ${remote_ssh_string} "cp --archive --recursive ${remote_directory_path} ${remote_deployment_directory_path}/$(basename ${remote_directory_path}).backup.${now}"; then
  21. echo backup of current remote directory successfully created on remote
  22. else
  23. echo backup of current remote directory failed
  24. exit 1
  25. fi
  26. fi
  27. if [ "${remote_is_docker}" != "yes" ]; then
  28. if ssh ${remote_ssh_string} "wp option patch update wpmm_settings general status 1 --path=${remote_wp_path}"; then
  29. echo maintenance mode activated
  30. else
  31. echo something went horribly wrong
  32. exit 1
  33. fi
  34. fi
  35. # --update removed after kartolok-child shenaningans
  36. # --checksum added instead
  37. if rsync --checksum --compress --delete --delete-excluded --exclude-from="${deployment_exclude_file}" --executability --human-readable --progress --recursive "${local_directory_path}/" "${remote_ssh_string}":"${remote_directory_path}"; then
  38. echo syncing OK
  39. else
  40. echo syncing NOK
  41. exit 1
  42. fi
  43. if [ "${remote_is_docker}" != "yes" ]; then
  44. if ssh ${remote_ssh_string} "wp option patch update wpmm_settings general status 0 --path=${remote_wp_path}"; then
  45. echo maintenance mode deactivated
  46. else
  47. echo something went horribly wrong
  48. exit 1
  49. fi
  50. fi
  51. if [ "${remote_ssh_string}" = "staging" ]; then
  52. set -x
  53. ssh federal sudo service varnish restart
  54. set +x
  55. fi
  56. if [ "${remote_ssh_string}" = "prod" ]; then
  57. set -x
  58. ssh federal sudo service varnish restart
  59. set +x
  60. fi
  61. if [ "${remote_ssh_string}" = "network" ]; then
  62. set -x
  63. ssh network sudo service varnish restart
  64. set +x
  65. fi