Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash -e
- # Default false for flags
- db=false
- uploads=false
- plugins=false
- # Checks for flags
- while getopts dmp option
- do
- case "${option}"
- in
- d) db=true;;
- u) uploads=true;;
- p) plugins=true;;
- esac
- done
- # Sets variable for message display
- env_message=false
- # Checks if script is being run from a specific directory
- # This should be the root of your local WordPress install
- if [[ ${PWD##*/} = nano.dev ]]; then
- sftpuser=example-user
- sftppass=example-password
- server=example.sftp.wpengine.com
- if [[ $db = true ]]; then
- env_message=true
- sshpass -p $sftppass SFTP -P 2222 -r $sftpuser@$server:wp-content/mysql.sql mysql.sql
- wp db import mysql.sql
- wp search-replace 'example.com' 'example.dev'
- fi
- if [[ $uploads = true ]]; then
- env_message=true
- sshpass -p $sftppass SFTP -P 2222 -r $sftpuser@$server:wp-content/uploads wp-content/
- fi
- if [[ $plugins = true ]]; then
- env_message=true
- sshpass -p $sftppass SFTP -P 2222 -r $sftpuser@$server:wp-content/plugins wp-content/
- rm -rf wp-content/plugins/hyperdb
- rm -rf wp-content/plugins/hyperdb-1-1
- fi
- fi
- if [[ $env_message = false ]]; then
- printf "$(tput setaf 3)$(tput bold)Warning:$(tput setaf 0)$(tput sgr0) Sync failed.\n"
- else
- printf "$(tput setaf 2)$(tput bold)Success:$(tput setaf 0)$(tput sgr0) ${PWD##*/} environment synced.\n"
- fi
Add Comment
Please, Sign In to add comment