Guest User

Untitled

a guest
Nov 6th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. #!/bin/bash -e
  2.  
  3. # Default false for flags
  4. db=false
  5. uploads=false
  6. plugins=false
  7.  
  8. # Checks for flags
  9. while getopts dmp option
  10. do
  11. case "${option}"
  12. in
  13. d) db=true;;
  14. u) uploads=true;;
  15. p) plugins=true;;
  16. esac
  17. done
  18.  
  19. # Sets variable for message display
  20. env_message=false
  21.  
  22. # Checks if script is being run from a specific directory
  23. # This should be the root of your local WordPress install
  24. if [[ ${PWD##*/} = nano.dev ]]; then
  25.  
  26. sftpuser=example-user
  27. sftppass=example-password
  28. server=example.sftp.wpengine.com
  29.  
  30. if [[ $db = true ]]; then
  31. env_message=true
  32. sshpass -p $sftppass SFTP -P 2222 -r $sftpuser@$server:wp-content/mysql.sql mysql.sql
  33. wp db import mysql.sql
  34. wp search-replace 'example.com' 'example.dev'
  35. fi
  36.  
  37. if [[ $uploads = true ]]; then
  38. env_message=true
  39. sshpass -p $sftppass SFTP -P 2222 -r $sftpuser@$server:wp-content/uploads wp-content/
  40. fi
  41.  
  42. if [[ $plugins = true ]]; then
  43. env_message=true
  44. sshpass -p $sftppass SFTP -P 2222 -r $sftpuser@$server:wp-content/plugins wp-content/
  45. rm -rf wp-content/plugins/hyperdb
  46. rm -rf wp-content/plugins/hyperdb-1-1
  47. fi
  48.  
  49. fi
  50.  
  51. if [[ $env_message = false ]]; then
  52. printf "$(tput setaf 3)$(tput bold)Warning:$(tput setaf 0)$(tput sgr0) Sync failed.\n"
  53. else
  54. printf "$(tput setaf 2)$(tput bold)Success:$(tput setaf 0)$(tput sgr0) ${PWD##*/} environment synced.\n"
  55. fi
Add Comment
Please, Sign In to add comment