Last active
March 27, 2018 03:39
-
-
Save davemac/7d3ef368070c1b49fe21bc1efb2a2533 to your computer and use it in GitHub Desktop.
bash script for first deployment of WordPress site to staging server, excludes dev tools and build files
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
# for initial site deployment to staging server, excludes dev tools and build files | |
# uses current directory as theme path and ssh alias | |
# 3 user inputs: dbname, dbuser, dbpass | |
firstdeploy() { | |
current=${PWD##*/} | |
cd ~/Sites/$current || return | |
echo "Database name:" | |
read dbname | |
echo "Database user:" | |
read dbuser | |
echo "Database password:" | |
read dbpass | |
# rsync the local database to staging site | |
wp db export $current.sql | |
rsync $current.sql $current-s:~/ | |
wp @stage core download --path=www --skip-content | |
wp @stage config create --dbname="$dbname" --dbuser="$dbuser" --dbpass="$dbpass" --skip-check --extra-php <<PHP | |
define( 'WP_DEBUG', false ); | |
define('SAVEQUERIES', false); | |
define( 'DISALLOW_FILE_EDIT', true ); | |
define( 'WP_POST_REVISIONS', 5 ); | |
define( 'JETPACK_STAGING_MODE', true); | |
PHP | |
wp @stage db import $current.sql | |
wp @stage search-replace "$current.localhost" "$current.dmctest.com.au" --all-tables | |
rsync --exclude-from "rsync-exclude.txt" wp-content $current-s:~/www | |
# remove plugins that aren't needed | |
wp @stage plugin deactivate debug-bar query-monitor acf-theme-code-pro wordpress-seo | |
wp @stage plugin delete debug-bar query-monitor acf-theme-code-pro wordpress-seo | |
# Discourage search engines from indexing this site | |
wp @stage option update blog_public 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment