Newer
Older
# Create a development environment for a given "name" on devwww/devdb
# Include common dev script.
. dev/common.sh
Neil Drumm
committed
# Usage: write_template "template" "path/to/destination"
function write_template {
sed -e "s/DB_NAME/${db_name}/g;s/NAME/${name}/g;s/SITE/${site}/g;s/DB_PASS/${db_pass}/g" "dev/${1}" > "${2}"
}
# Fail early if comment is omitted.
[ -z "${COMMENT-}" ] && echo "Comment is required." && exit 1
# Handle drupal.org vs. sub-domains properly
if [ ${site} == "drupal" ]; then
fqdn="drupal.org"
snapshot="drupal_database_snapshot.reduce-current.sql.bz2"
elif [ ${site} == "drupal_7" ]; then
fqdn="drupal.org"
snapshot="drupal_7_database_snapshot.reduce-current.sql.bz2"
# Strip any _ and following characters from ${site}, and add .drupal.org.
# Such as 'qa_7' -> 'qa.drupal.org'
fqdn="$(echo "${site}" | sed -e 's/_.*//').drupal.org"
# If ${site} has an underscore, use the following characters. Such as
# 'qa_7' -> 'qa.drupal.org-7'
repository="${fqdn}$(echo ${site} | sed -ne 's/.*_/-/p')"
snapshot="${site}_database_snapshot.dev-current.sql.bz2"
# DrupalCon São Paulo 2012 and later have a common BZR repository.
if [ "${site}" == "saopaulo2012" -o "${site}" == "sydney2013" -o "${site}" == "portland2013" -o "${site}" == "europe2014" -o "${site}" == "northamerica2014" ]; then
repository="drupalcon-7"
fi
if [ "${site}" == "association" -o "${site}" == "api" ]; then
[ -e "${web_path}" ] && echo "Project webroot already exists!" && exit 1
mkdir -p "${web_path}/htdocs"
chown -R bender:developers "${web_path}"
echo "${COMMENT}" > "${web_path}/comment"
write_template "vhost.conf.template" "${vhost_path}"
mysql -e "CREATE DATABASE ${db_name};"
mysql -e "GRANT ALL ON ${db_name}.* TO '${db_name}'@'devwww.drupal.org' IDENTIFIED BY '${db_pass}';"
# Checkout webroot
echo "Populating development environment with bzr checkout"
bzr checkout bzr+ssh://bender-deploy@util.drupal.org/${repository} "${web_path}/htdocs"
write_template "settings.local.php.template" "${web_path}/htdocs/sites/default/settings.local.php"
# Strongarm the permissions
echo "Forcing proper permissions on ${web_path}"
find "${web_path}" -type d -exec chmod g+rwx {} +
find "${web_path}" -type f -exec chmod g+rw {} +
chgrp -R developers "${web_path}"
rsync -v --copy-links --password-file ~/util.rsync.pass "rsync://devmysql@util.drupal.org/mysql-dev/${snapshot}" "${WORKSPACE}"
# InnoDB handles the url alias table much faster.
echo "ALTER TABLE url_alias ENGINE InnoDB;" | ${drush} sql-cli
# Disable modules that don't work well in development (yet)
Neil Drumm
committed
${drush} pm-disable paranoia
${drush} pm-disable civicrm
Neil Drumm
committed
ln -s /media/${fqdn} "${web_path}/htdocs/$(${drush} status | sed -ne 's/^ *File directory path *: *\([^ ]*\).*$/\1/p')"
Neil Drumm
committed
${drush} vdel preprocess_css
${drush} vdel preprocess_js
Neil Drumm
committed
${drush} pm-enable views_ui
${drush} pm-enable imagecache_ui
Neil Drumm
committed
${drush} updatedb
# Enable UC test gateway
${drush} en test_gateway
${drush} vset uc_payment_credit_gateway test_gateway
Neil Drumm
committed
${drush} vdel bakery_slaves
${drush} vset bakery_domain ".redesign.devdrupal.org"
if [ "${site}" == "drupal" ]; then
# Drupal.org sites are masters
Neil Drumm
committed
${drush} vset bakery_master "http://${name}-${site}.redesign.devdrupal.org/"
Neil Drumm
committed
${drush} vset bakery_key "$(pwgen -s 32 1)"
if [ "${bakery_master-}" ]; then
Neil Drumm
committed
${drush} vset bakery_master "http://${bakery_master}-drupal.redesign.devdrupal.org/"
drush_master="drush -r /var/www/dev/${bakery_master}-drupal.redesign.devdrupal.org/htdocs -l ${bakery_master}-drupal.redesign.devdrupal.org -y"
Neil Drumm
committed
${drush} vset bakery_key $(${drush_master} vget bakery_key | sed -ne 's/^.*"\(.*\)"/\1/p')
${drush_master} bakery-add-slave "http://${name}-${site}.redesign.devdrupal.org/"
Neil Drumm
committed
${drush} pm-disable bakery
Angie Byron
committed
# Set up test user
Angie Byron
committed
# Prime any big caches
Neil Drumm
committed
wget -O /dev/null http://${name}-${site}.redesign.devdrupal.org --user=drupal --password=drupal