Created
April 1, 2019 10:01
-
-
Save prosenjit-manna/436ae7a1b57eea5d984f973ccfad7f7a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## These variable should be set in Bitbucket repository | |
## If you want to try in local system without bitbucket pipeline | |
## You can do so with update variable value | |
## One thing is required collect Aws ssh key for ssh connect | |
## Create a ssh key in Aws server and add public key in your bitbucket account | |
## Otherwise this code will not work | |
# export WP_PROD_ROOT_PATH="/var/www/html/pipelines/wp-testing";\ | |
# export DB_NAME_PROD="wppipelineprod";\ | |
# export DB_USER="root";\ | |
# export DB_PASS="123456";\ | |
# export WP_PROD_ROOT_URL="http://domain/wp-prod";\ | |
# export AWSDOMAINANDUSER="ec2-user@awsdomain";\ | |
# export GITURL="[email protected]:username/wp-pipeline.git";\ | |
# export LOCALURL="http://localhost/wp-pipeline";\ | |
## End Bitbucket variable | |
ssh $AWSDOMAINANDUSER ' | |
export WP_PROD_ROOT_PATH="'$WP_PROD_ROOT_PATH'";\ | |
export DB_NAME_PROD="'$DB_NAME_PROD'";\ | |
export DB_USER="'$DB_USER'";\ | |
export DB_PASS="'$DB_PASS'";\ | |
export WP_PROD_ROOT_URL="'$WP_PROD_ROOT_URL'";\ | |
export GITURL="'$GITURL'";\ | |
export LOCALURL="'$LOCALURL'";\ | |
if [ wp core version --path=$WP_PROD_ROOT_PATH ] | |
then | |
echo "already Setup" | |
else | |
echo "Setup starting" ;\ | |
eval `ssh-agent -s` | |
ssh-add ~/.ssh/id_rsa | |
git clone $GITURL $WP_PROD_ROOT_PATH --progress ; \ | |
wp core download --path=$WP_PROD_ROOT_PATH; \ | |
wp core config --dbname=$DB_NAME_PROD --dbuser=$DB_USER --dbpass=$DB_PASS --dbhost=localhost --path=$WP_PROD_ROOT_PATH; \ | |
wp db create --path=$WP_PROD_ROOT_PATH; \ | |
wp db import $WP_PROD_ROOT_PATH/db/db.txt --path=$WP_PROD_ROOT_PATH; \ | |
fi | |
wp search-replace $LOCALURL $WP_PROD_ROOT_URL --path=$WP_PROD_ROOT_PATH; \ | |
'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment