Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

deploy-directory-to-remote.sh 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 ssh ${remote_ssh_string} "mkdir --parents ${remote_deployment_directory_path}"; then
  14. echo deployment folder successfully created on remote
  15. else
  16. echo deployment folder creation on remote failed
  17. exit 1
  18. fi
  19. if ssh ${remote_ssh_string} "cp --archive --recursive ${remote_directory_path} ${remote_deployment_directory_path}/$(basename ${remote_directory_path}).backup.${now}"; then
  20. echo backup of current remote directory successfully created on remote
  21. else
  22. echo backup of current remote directory failed
  23. exit 1
  24. fi
  25. if [ "${remote_is_docker}" != "yes" ]; then
  26. if ssh ${remote_ssh_string} "wp option patch update wpmm_settings general status 1 --path=${remote_wp_path}"; then
  27. echo maintenance mode activated
  28. else
  29. echo something went horribly wrong
  30. exit 1
  31. fi
  32. fi
  33. if rsync --archive --compress --delete --delete-excluded --exclude-from="${deployment_exclude_file}" --human-readable --progress "${local_directory_path}/" "${remote_ssh_string}":"${remote_directory_path}"; then
  34. echo syncing OK
  35. else
  36. echo syncing NOK
  37. exit 1
  38. fi
  39. if [ "${remote_is_docker}" != "yes" ]; then
  40. if ssh ${remote_ssh_string} "wp option patch update wpmm_settings general status 0 --path=${remote_wp_path}"; then
  41. echo maintenance mode deactivated
  42. else
  43. echo something went horribly wrong
  44. exit 1
  45. fi
  46. fi