Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

deploy-directory-to-remote.sh 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 ssh ${remote_ssh_string} "wp option patch update wpmm_settings general status 1 --path=${remote_wp_path}"; then
  26. echo maintenance mode activated
  27. else
  28. echo something went horribly wrong
  29. exit 1
  30. fi
  31. 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
  32. echo syncing OK
  33. else
  34. echo syncing NOK
  35. exit 1
  36. fi
  37. if ssh ${remote_ssh_string} "wp option patch update wpmm_settings general status 0 --path=${remote_wp_path}"; then
  38. echo maintenance mode deactivated
  39. else
  40. echo something went horribly wrong
  41. exit 1
  42. fi