Skip to content
This repository has been archived by the owner on May 6, 2018. It is now read-only.

Variable vcs git #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions provision/vvv-hosts

This file was deleted.

54 changes: 26 additions & 28 deletions provision/vvv-init.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
#!/usr/bin/env bash
# Provision WordPress Develop

DOMAIN=`get_primary_host "${VVV_SITE_NAME}".dev`
DB_NAME=`get_config_value 'db_name' "${VVV_SITE_NAME}"`
DB_NAME=${DB_NAME//[\\\/\.\<\>\:\"\'\|\?\!\*-]/}


# Make a database, if we don't already have one
echo -e "\nCreating database 'wordpress_develop' (if it's not already there)"
mysql -u root --password=root -e "CREATE DATABASE IF NOT EXISTS wordpress_develop"
mysql -u root --password=root -e "GRANT ALL PRIVILEGES ON wordpress_develop.* TO wp@localhost IDENTIFIED BY 'wp';"
echo -e "\nCreating database '${DB_NAME}' (if it's not already there)"
mysql -u root --password=root -e "CREATE DATABASE IF NOT EXISTS ${DB_NAME}"
mysql -u root --password=root -e "GRANT ALL PRIVILEGES ON ${DB_NAME}.* TO wp@localhost IDENTIFIED BY 'wp';"
echo -e "\n DB operations done.\n\n"

# Nginx Logs
Expand All @@ -15,55 +21,49 @@ touch ${VVV_PATH_TO_SITE}/log/build.access.log

# Checkout, install and configure WordPress trunk via develop.svn
if [[ ! -d "${VVV_PATH_TO_SITE}/public_html" ]]; then
echo "Checking out WordPress trunk. See https://develop.svn.wordpress.org/trunk"
noroot svn checkout "https://develop.svn.wordpress.org/trunk/" "/tmp/wordpress-develop"
echo "Checking out WordPress trunk from git://develop.git.wordpress.org/"
noroot git clone "git://develop.git.wordpress.org/" "/tmp/${VVV_PATH_TO_SITE}"

cd /tmp/wordpress-develop/src/
cd /tmp/${VVV_PATH_TO_SITE}/src/

echo "Installing local npm packages for src.wordpress-develop.dev, this may take several minutes."
echo "Installing local npm packages for src.${VVV_SITE_NAME}.dev, this may take several minutes."
noroot npm install

echo "Initializing grunt and creating build.wordpress-develop.dev, this may take several minutes."
echo "Initializing grunt and creating build.${VVV_SITE_NAME}.dev, this may take several minutes."
noroot grunt

echo "Moving WordPress develop to a shared directory, ${VVV_PATH_TO_SITE}/public_html"
mv /tmp/wordpress-develop ${VVV_PATH_TO_SITE}/public_html
mv /tmp/${VVV_PATH_TO_SITE} ${VVV_PATH_TO_SITE}/public_html

cd ${VVV_PATH_TO_SITE}/public_html/src/
echo "Creating wp-config.php for src.wordpress-develop.dev and build.wordpress-develop.dev."
noroot wp core config --dbname=wordpress_develop --dbuser=wp --dbpass=wp --quiet --extra-php <<PHP
echo "Creating wp-config.php for src.${VVV_SITE_NAME}.dev and build.${VVV_SITE_NAME}.dev."
noroot wp core config --dbname=${DB_NAME} --dbuser=wp --dbpass=wp --quiet --extra-php <<PHP
// Match any requests made via xip.io.
if ( isset( \$_SERVER['HTTP_HOST'] ) && preg_match('/^(src|build)(.wordpress-develop.)\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(.xip.io)\z/', \$_SERVER['HTTP_HOST'] ) ) {
if ( isset( \$_SERVER['HTTP_HOST'] ) && preg_match('/^(src|build)(.${VVV_SITE_NAME}.)\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(.xip.io)\z/', \$_SERVER['HTTP_HOST'] ) ) {
define( 'WP_HOME', 'http://' . \$_SERVER['HTTP_HOST'] );
define( 'WP_SITEURL', 'http://' . \$_SERVER['HTTP_HOST'] );
} else if ( 'build' === basename( dirname( __FILE__ ) ) ) {
// Allow (src|build).wordpress-develop.dev to share the same Database
define( 'WP_HOME', 'http://build.wordpress-develop.dev' );
define( 'WP_SITEURL', 'http://build.wordpress-develop.dev' );
// Allow (src|build).${VVV_SITE_NAME}.dev to share the same Database
define( 'WP_HOME', 'http://build.${VVV_SITE_NAME}.dev' );
define( 'WP_SITEURL', 'http://build.${VVV_SITE_NAME}.dev' );
}

define( 'WP_DEBUG', true );
PHP

echo "Installing src.wordpress-develop.dev."
noroot wp core install --url=src.wordpress-develop.dev --quiet --title="WordPress Develop" --admin_name=admin --admin_email="[email protected]" --admin_password="password"
echo "Installing src.${VVV_SITE_NAME}.dev."
noroot wp core install --url=src.${VVV_SITE_NAME}.dev --quiet --title="WordPress Develop" --admin_name=admin --admin_email="[email protected]" --admin_password="password"
cp /srv/config/wordpress-config/wp-tests-config.php ${VVV_PATH_TO_SITE}/public_html/
cd ${VVV_PATH_TO_SITE}/public_html/

else

echo "Updating WordPress develop..."
cd ${VVV_PATH_TO_SITE}/public_html/
if [[ -e .svn ]]; then
svn up
if [[ $(git rev-parse --abbrev-ref HEAD) == 'master' ]]; then
git pull --no-edit git://develop.git.wordpress.org/ master
else

if [[ $(git rev-parse --abbrev-ref HEAD) == 'master' ]]; then
git pull --no-edit git://develop.git.wordpress.org/ master
else
echo "Skip auto git pull on develop.git.wordpress.org since not on master branch"
fi

echo "Skip auto git pull on develop.git.wordpress.org since not on master branch"
fi

echo "Updating npm packages..."
Expand All @@ -75,5 +75,3 @@ if [[ ! -d "${VVV_PATH_TO_SITE}/public_html/build" ]]; then
cd ${VVV_PATH_TO_SITE}/public_html/
grunt
fi

ln -sf ${VVV_PATH_TO_SITE}/bin/develop_git /home/vagrant/bin/develop_git
18 changes: 11 additions & 7 deletions provision/vvv-nginx.conf
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
################################################################
# WordPress develop src nginx configuration
#
# http://src.wordpress-develop.dev - this server configuration is
# http://src.{vvv_site_name}.dev - this server configuration is
# setup to listen on port 80 for any requests coming in to
# src.wordpress-develop.dev and use the {vvv_path_to_site}/public_html/src
# src.{vvv_path_to_site}.dev and use the {vvv_path_to_site}/public_html/src
# directory to serve them.
server {
listen 80;
listen 443 ssl;
server_name src.wordpress-develop.dev *.src.wordpress-develop.dev ~^src\.wordpress-develop\.\d+\.\d+\.\d+\.\d+\.xip\.io$;
server_name src.{vvv_site_name}.dev
*.src.{vvv_site_name}.dev
~^src\.{vvv_site_name}\.\d+\.\d+\.\d+\.\d+\.xip\.io$;
root {vvv_path_to_site}/public_html/src;

error_log {vvv_path_to_site}/log/src.error.log;
Expand All @@ -22,19 +24,21 @@ server {
################################################################
# WordPress develop build nginx configuration
#
# http://build.wordpress-develop.dev - this server configuration is
# http://build.{vvv_site_name}.dev - this server configuration is
# setup to listen on port 80 for any requests coming in to
# build.wordpress-develop.dev and use the {vvv_path_to_site}/public_html/build
# build.{vvv_site_name}.dev and use the {vvv_path_to_site}/public_html/build
# directory to serve them.
server {
listen 80;
listen 443 ssl;
server_name build.wordpress-develop.dev *.build.wordpress-develop.dev ~^build\.wordpress-develop\.\d+\.\d+\.\d+\.\d+\.xip\.io$;
server_name build.{vvv_site_name}.dev
*.build.{vvv_site_name}.dev
~^build\.{vvv_site_name}\.\d+\.\d+\.\d+\.\d+\.xip\.io$;
root {vvv_path_to_site}/public_html/build;

error_log {vvv_path_to_site}/log/build.error.log;
access_log {vvv_path_to_site}/log/build.access.log;

set $upstream {upstream};

include /etc/nginx/nginx-wp-common.conf;
Expand Down