Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue 151 - Anti parameter expansion fixes #159

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
48 changes: 24 additions & 24 deletions buddypressorg.test/provision/vvv-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,47 @@
SITE_DOMAIN="buddypressorg.test"

BASE_DIR=$( dirname $( dirname $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) ) )
source $BASE_DIR/helper-functions.sh
source "${BASE_DIR}/helper-functions.sh"

wme_create_logs "$BASE_DIR/$SITE_DOMAIN/logs"
wme_create_logs "${BASE_DIR}/${SITE_DOMAIN}/logs"

if [[ `wme_provision_site "${SITE_DOMAIN}"` == 'false' ]]; then
echo "Provisioning of ${SITE_DOMAIN} skipped"
return
fi

PROVISION_DIR="$BASE_DIR/$SITE_DOMAIN/provision"
SITE_DIR="$BASE_DIR/$SITE_DOMAIN/public_html"
PROVISION_DIR="${BASE_DIR}/${SITE_DOMAIN}/provision"
SITE_DIR="${BASE_DIR}/${SITE_DOMAIN}/public_html"
SVN_PLUGINS=( buddypress bbpress )
WPCLI_PLUGINS=( akismet bbpress-no-admin debug-bar email-post-changes syntaxhighlighter )

wme_svn_git_migration $SITE_DIR
wme_svn_git_migration "${SITE_DIR}"

if [ ! -L $SITE_DIR ]; then
printf "\n#\n# Provisioning $SITE_DOMAIN\n#\n"
if [ ! -L "${SITE_DIR}" ]; then
printf "\n#\n# Provisioning ${SITE_DOMAIN}\n#\n"

if [[ ! $MIGRATED_TO_GIT ]]; then
wme_import_database "buddypressorg_dev" $PROVISION_DIR
if [[ ! "${MIGRATED_TO_GIT}" ]]; then
wme_import_database "buddypressorg_dev" "$PROVISION_DIR"
fi

wme_clone_meta_repository $BASE_DIR
wme_symlink_public_dir $BASE_DIR $SITE_DOMAIN "buddypress.org"
wme_symlink_logs_dir $BASE_DIR $SITE_DOMAIN "buddypress.org"
wme_clone_meta_repository "${BASE_DIR}"
wme_symlink_public_dir "${BASE_DIR}" "${SITE_DOMAIN}" "buddypress.org"
wme_symlink_logs_dir "${BASE_DIR}" "${SITE_DOMAIN}" "buddypress.org"

# Set up WordPress
wme_noroot wp core download --path=$SITE_DIR/wordpress
cp $PROVISION_DIR/wp-config.php $SITE_DIR
wme_noroot wp core download --path="${SITE_DIR}/wordpress"
cp "${PROVISION_DIR}/wp-config.php" "${SITE_DIR}"

# Set up plugins and themes
for i in "${SVN_PLUGINS[@]}"
do :
svn co https://plugins.svn.wordpress.org/$i/trunk $SITE_DIR/wp-content/plugins/$i
svn co "https://plugins.svn.wordpress.org/${i}/trunk" "${SITE_DIR}/wp-content/plugins/${i}"
done

wp plugin install ${WPCLI_PLUGINS[@]} --path=$SITE_DIR/wordpress --allow-root
wp plugin install ${WPCLI_PLUGINS[@]} --path="${SITE_DIR}/wordpress" --allow-root

mkdir $SITE_DIR/wp-content/mu-plugins
cp $PROVISION_DIR/sandbox-functionality.php $SITE_DIR/wp-content/mu-plugins/
mkdir "${SITE_DIR}/wp-content/mu-plugins"
cp "${PROVISION_DIR}/sandbox-functionality.php" "${SITE_DIR}/wp-content/mu-plugins/"

# Ignore external dependencies and Meta Environment tweaks
IGNORED_FILES=(
Expand All @@ -51,18 +51,18 @@ if [ ! -L $SITE_DIR ]; then
/wp-config.php
)
IGNORED_FILES=( "${IGNORED_FILES[@]}" "${SVN_PLUGINS[@]}" "${WPCLI_PLUGINS[@]}" )
wme_create_gitignore $SITE_DIR
wme_create_gitignore "${SITE_DIR}"

else
printf "\n#\n# Updating $SITE_DOMAIN\n#\n"
printf "\n#\n# Updating ${SITE_DOMAIN}\n#\n"

git -C $SITE_DIR pull origin master
wp core update --path=$SITE_DIR/wordpress --allow-root
wp plugin update ${WPCLI_PLUGINS[@]} --path=$SITE_DIR/wordpress --allow-root
git -C "${SITE_DIR}" pull origin master
wp core update --path="${SITE_DIR}/wordpress" --allow-root
wp plugin update ${WPCLI_PLUGINS[@]} --path="${SITE_DIR}/wordpress" --allow-root

for i in "${SVN_PLUGINS[@]}"
do :
svn up $SITE_DIR/wp-content/plugins/$i
svn up "${SITE_DIR}/wp-content/plugins/${i}"
done

fi
56 changes: 28 additions & 28 deletions helper-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
function wme_clone_meta_repository {
local REPOSITORY_DIR="$1/meta-repository"

if [ -d $REPOSITORY_DIR ]; then
if [ -d "${REPOSITORY_DIR}" ]; then
return 0
fi

git clone git://meta.git.wordpress.org/ $REPOSITORY_DIR
git -C $REPOSITORY_DIR config diff.noprefix true
git clone git://meta.git.wordpress.org/ "${REPOSITORY_DIR}"
git -C "${REPOSITORY_DIR}" config diff.noprefix true
}

# Symlink each site's public_html folder to the corresponding Meta repository
Expand All @@ -30,8 +30,8 @@ function wme_symlink_public_dir {
PUBLIC_DIR_PATH="$1/meta-repository/$3/public_html/"

cd "$1/$2"
ln -rs $PUBLIC_DIR_PATH public_html
mkdir -p $PUBLIC_DIR_PATH
ln -rs "${PUBLIC_DIR_PATH}" public_html
mkdir -p "${PUBLIC_DIR_PATH}"
}

# Symlink each site's log folder to the default log folder.
Expand All @@ -43,8 +43,8 @@ function wme_symlink_logs_dir {
LOGS_DIR_PATH="$1/$2/logs"

cd "$1/meta-repository/$3"
ln -rs $LOGS_DIR_PATH logs
mkdir -p $LOGS_DIR_PATH
ln -rs "${LOGS_DIR_PATH}" logs
mkdir -p "${LOGS_DIR_PATH}"
}

# Add entries to a .gitignore file
Expand All @@ -58,7 +58,7 @@ function wme_create_gitignore {

for i in "${IGNORED_FILES[@]}"
do :
echo "$i" >> $1/.gitignore
echo "$i" >> "$1/.gitignore"
done
}

Expand All @@ -68,17 +68,17 @@ function wme_create_gitignore {
#
# $1 - the absolute path to the folder where the header should be placed
function wme_pull_wporg_global_header {
curl -so $1/header.php https://wordpress.org/header.php
curl -so "$1/header.php" https://wordpress.org/header.php

sed -i "s/<\/head>/\n<?php\nif ( function_exists( 'gp_head' ) ) {\n\tgp_head();\n} else {\n\twp_head();\n}\n?>\n\n&/" $1/header.php
sed -i "s/<body id=\"wordpress-org\"/<body id=\"wordpress-org\" <?php if ( function_exists( 'body_class' ) ) { body_class(); } ?>/" $1/header.php
sed -i "s/<\/head>/\n<?php\nif ( function_exists( 'gp_head' ) ) {\n\tgp_head();\n} else {\n\twp_head();\n}\n?>\n\n&/" "$1/header.php"
sed -i "s/<body id=\"wordpress-org\"/<body id=\"wordpress-org\" <?php if ( function_exists( 'body_class' ) ) { body_class(); } ?>/" "$1/header.php"

# Replace the links to point locally
# Match: //wordpress.org -> //wordpressorg.test
sed -i -e 's/\/\/wordpress.org/\/\/wordpressorg.test/g' $1/header.php
sed -i -e 's/\/\/wordpress.org/\/\/wordpressorg.test/g' "$1/header.php"

# Match: make.wordpress.org -> make.wordpressorg.test
sed -i -e 's/make.wordpress.org/make.wordpressorg.test/g' $1/header.php
sed -i -e 's/make.wordpress.org/make.wordpressorg.test/g' "$1/header.php"
}

# Download the global WordPress.org footer into the given directory.
Expand All @@ -87,27 +87,27 @@ function wme_pull_wporg_global_header {
#
# $1 - the absolute path to the folder where the footer should be placed
function wme_pull_wporg_global_footer {
curl -so $1/footer.php https://wordpress.org/footer.php
curl -so "$1/footer.php" https://wordpress.org/footer.php

sed -i "s/<\/body>/\n<?php\nif ( function_exists( 'gp_footer' ) ) {\n\tgp_footer();\n} else {\n\twp_footer();\n}\n?>\n\n&/" $1/footer.php

# Replace the links to point locally
# Match: //wordpress.org -> //wordpressorg.test
sed -i -e 's/\/\/wordpress.org/\/\/wordpressorg.test/g' $1/footer.php
sed -i -e 's/\/\/wordpress.org/\/\/wordpressorg.test/g' "$1/footer.php"
# Match: .wordpress.org -> .wordpressorg.test
sed -i -e 's/.wordpress.org/.wordpressorg.test/g' $1/footer.php
sed -i -e 's/.wordpress.org/.wordpressorg.test/g' "$1/footer.php"
}

# Create log stubs
#
# $1 - the absolute path to the log folder
function wme_create_logs {
echo "Creating log files in ${1}"
mkdir -p $1
mkdir -p "$1"

touch $1/nginx-access.log
touch $1/nginx-error.log
touch $1/php-error.log
touch "$1/nginx-access.log"
touch "$1/nginx-error.log"
touch "$1/php-error.log"
}

# Import a MySQL database
Expand All @@ -119,7 +119,7 @@ function wme_import_database {
mysql -u root --password=root -e "CREATE DATABASE IF NOT EXISTS $1;"
mysql -u root --password=root -e "GRANT ALL PRIVILEGES ON $1.* TO wp@localhost IDENTIFIED BY 'wp';"
echo "Importing database ${2}/${1}.sql"
mysql -u root --password=root $1 < "${2}/${1}.sql"
mysql -u root --password=root "$1" < "${2}/${1}.sql"
echo "Finished database import operations for ${1}"
}

Expand All @@ -138,7 +138,7 @@ function wme_svn_git_migration {
echo "If you're working on any unfinished patches, please copy them from the backup folder."
echo -e "For help contributing with Git, see https://make.wordpress.org/meta/handbook/documentation/contributing-with-git/\n"

mv $1 "$1-old-svn-backup"
mv "$1" "$1-old-svn-backup"
MIGRATED_TO_GIT=true
}

Expand All @@ -156,7 +156,7 @@ function wme_noroot() {
function wme_provision_site {
WME_SITE_ESCAPED=`echo ${1} | sed 's/\./\\\\./g'`
WME_PROVISION_SITE=`get_config_value "provision_site.${WME_SITE_ESCAPED}" 'true'`
echo ${WME_PROVISION_SITE,,}
echo "${WME_PROVISION_SITE,,}"
}

# Loads mo/mo files from translate.wordpress.org.
Expand All @@ -165,10 +165,10 @@ function wme_provision_site {
# $2 - Slug of GlotPress project
# $3 - File path without the PO/MO extension
function wme_download_pomo {
local GPLOCALE=$1
local GPPROJECT=$2
local OUTPUT=$3
local GPLOCALE="$1"
local GPPROJECT="$2"
local OUTPUT="$3"

curl -sfg -o $OUTPUT.po "https://translate.wordpress.org/projects/$GPPROJECT/$GPLOCALE/default/export-translations?filters[status]=current&format=po" || echo "Error downloading ${GPPROJECT}-${GPLOCALE}.po"
curl -sfg -o $OUTPUT.mo "https://translate.wordpress.org/projects/$GPPROJECT/$GPLOCALE/default/export-translations?filters[status]=current&format=mo" || echo "Error downloading ${GPPROJECT}-${GPLOCALE}.mo"
curl -sfg -o "${OUTPUT}.po" "https://translate.wordpress.org/projects/${GPPROJECT}/${GPLOCALE}/default/export-translations?filters[status]=current&format=po" || echo "Error downloading ${GPPROJECT}-${GPLOCALE}.po"
curl -sfg -o "${OUTPUT}.mo" "https://translate.wordpress.org/projects/${GPPROJECT}/${GPLOCALE}/default/export-translations?filters[status]=current&format=mo" || echo "Error downloading ${GPPROJECT}-${GPLOCALE}.mo"
}
20 changes: 10 additions & 10 deletions jobs.wordpressnet.test/provision/vvv-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@
SITE_DOMAIN="jobs.wordpressnet.test"

BASE_DIR=$( dirname $( dirname $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) ) )
source $BASE_DIR/helper-functions.sh
source "${BASE_DIR}/helper-functions.sh"

wme_create_logs "$BASE_DIR/$SITE_DOMAIN/logs"
wme_create_logs "${BASE_DIR}/${SITE_DOMAIN}/logs"

if [[ `wme_provision_site "${SITE_DOMAIN}"` == 'false' ]]; then
echo "Provisioning of ${SITE_DOMAIN} skipped"
return
fi

PROVISION_DIR="$BASE_DIR/$SITE_DOMAIN/provision"
SITE_DIR="$BASE_DIR/$SITE_DOMAIN/public_html"
PROVISION_DIR="${BASE_DIR}/${SITE_DOMAIN}/provision"
SITE_DIR="${BASE_DIR}/${SITE_DOMAIN}/public_html"

wme_svn_git_migration "${SITE_DIR}"

if [ ! -L $SITE_DIR ]; then
printf "\n#\n# Provisioning $SITE_DOMAIN\n#\n"
if [ ! -L "$SITE_DIR" ]; then
printf "\n#\n# Provisioning ${SITE_DOMAIN}\n#\n"

# Don't overwrite existing databases if we're just migrating from SVN to Git
if [[ ! $MIGRATED_TO_GIT ]]; then
if [[ ! "$MIGRATED_TO_GIT" ]]; then
wme_import_database "jobs_wordpressnet_dev" "${PROVISION_DIR}"
fi

wme_clone_meta_repository $BASE_DIR
wme_clone_meta_repository "${BASE_DIR}"
wme_symlink_public_dir "${BASE_DIR}" "${SITE_DOMAIN}" "jobs.wordpress.net"
wme_symlink_logs_dir "${BASE_DIR}" "${SITE_DOMAIN}" "jobs.wordpress.net"

Expand All @@ -41,10 +41,10 @@ if [ ! -L $SITE_DIR ]; then
/wp-content/plugins/si-contact-form
/wp-config.php
)
wme_create_gitignore $SITE_DIR
wme_create_gitignore "$SITE_DIR"

else
printf "\n#\n# Updating $SITE_DOMAIN\n#\n"
printf "\n#\n# Updating ${SITE_DOMAIN}\n#\n"

git -C "${SITE_DIR}" pull origin master
wme_noroot wp core update --version=nightly --path="${SITE_DIR}/wordpress"
Expand Down
10 changes: 5 additions & 5 deletions provision/vvv-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ BASE_DIR="$( dirname $( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd

# Launch each provisioner in a subshell to avoid conflicting global variable names.
# For example, `$BASE_DIR` would be overridden by each provisioner.
( source $BASE_DIR/buddypressorg.test/provision/vvv-init.sh )
( source $BASE_DIR/jobs.wordpressnet.test/provision/vvv-init.sh )
( source $BASE_DIR/wordcamp.test/provision/vvv-init.sh )
( source $BASE_DIR/wordpressorg.test/provision/vvv-init.sh )
( source $BASE_DIR/wordpresstv.test/provision/vvv-init.sh )
( source "${BASE_DIR}/buddypressorg.test/provision/vvv-init.sh" )
( source "${BASE_DIR}/jobs.wordpressnet.test/provision/vvv-init.sh" )
( source "${BASE_DIR}/wordcamp.test/provision/vvv-init.sh" )
( source "${BASE_DIR}/wordpressorg.test/provision/vvv-init.sh" )
( source "${BASE_DIR}/wordpresstv.test/provision/vvv-init.sh" )

echo "Completed WordPress Meta Environment provisioning"
Loading