You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

deploy-directory-to-remote.sh 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 [ "${use_maintenance_mode}" = "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 [ "${use_maintenance_mode}" = "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 [ "${restart_remote_varnish}" = "yes" ]; then
  52. set -x
  53. ssh "${sudo_remote_ssh_string}" sudo service varnish restart
  54. set +x
  55. fi