Skip to content

Instantly share code, notes, and snippets.

@fl3a
Created July 11, 2012 09:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fl3a/3089178 to your computer and use it in GitHub Desktop.
Save fl3a/3089178 to your computer and use it in GitHub Desktop.
Drupal-Distro-Build-Script

Drupal-Distro-Build-Script

About

Testing the functionality of Drupal installation profiles is cumbesome...

This script helps you to perform the following (repeating) steps of rolling out an installation profile, before you are able to test it's functionality.

It performs the following steps in case of Feature Server (fserver) 6.x installation profile:

  1. Drush make
  • Drush make on distro.make from Git-Repository
  • Download of the Drupal Core
  • Clone of the Git repository for the installation profile
  • Recursive search of further Drush-Makefiles, download Drupal-Modules and themes, specified within found Makefile drupal-org.make
  1. Symlinks from Build to DocumentRoot
  2. Drop tables within target database
  3. Installation of the specified Installationprofile via site-install

@see example.build.conf.sh for build options..

@see also my blogpost Drupal-Distro-Build-Skript (in german).

Requirements

Examples

  1. Simple call with output

     drupal_distro_build.sh fserver6_build.conf.sh
    
  2. Call with sending the output of the build process via mail, subject is the name of the build

     drupal_distro_build.sh fserver6_build.conf.sh |  mail -s `head -n 1`  mail@example.com
    
  3. Call with generating a logfile, name of the log is Build + Suffix .log

     drupal_distro_build.sh fserver6_build.conf.sh | tee `head -n 1 `.log
    
#!/bin/bash
# Treat unset variables as an error
set -o nounset
# Source configuration
source $1 || exit 126
echo -e "${BUILD}"
##
# Needed executables & drush commands
#
DRUSH=$(which drush) &> /dev/null \
|| { echo 'Missing drush. Aborting...' >&2; exit 127; }
# Specific path to drush version for drush site-install
set +o nounset
[ -z "$DRUSH_SITE_INSTALL_DRUSH" ] && DRUSH_SITE_INSTALL_DRUSH=${DRUSH}
set -o nounset
which git &> /dev/null \
|| { echo 'Missing git. Aborting...'>&2; exit 127; }
drush help make &> /dev/null \
|| { echo "Could not probe 'drush make'. Aborting...">&2; exit 127; }
${DRUSH_SITE_INSTALL_DRUSH} help site-install &> /dev/null \
|| { echo "Could not probe 'drush site-install'. Aborting...">&2; exit 127; }
##
# run drush make
#
cd ${WEB_DIR}
echo -e "# Running drush make, create new build ${BUILD} with ${BUILD_MAKEFILE}...\n"
${DRUSH} make ${MAKE_OPTIONS} ${BUILD_MAKEFILE} ${BUILD} 2>&1 \
&& echo -e "\n# Creating build ${BUILD} was successful\n" \
|| { echo -e "\nFAILED!\n"; exit 1; }
##
# link new build to docroot
#
if [ -L ${DOC_ROOT} ] ; then
echo -ne "# Symlink ${BUILD} already exists, unlink ${BUILD}... "
unlink ${DOC_ROOT} 2>&1 \
&& echo -e "done\n" \
|| { echo -e "FAILED!\n"; exit 2; }
fi
echo -ne "# Symlink ${BUILD} to ${WEB_DIR}/${DOC_ROOT}... "
ln -s ${BUILD} ${DOC_ROOT} 2>&1 \
&& echo -e "done\n" \
|| { echo -e "FAILED!\n"; exit 3; }
##
# run drush site-install (and drop existing tables)
#
echo -e "# Running drush site-install...\n"
${DRUSH_SITE_INSTALL_DRUSH} site-install ${BUILD_PROFILE} ${SI_OPTIONS} -y -r ${WEB_DIR}/${DOC_ROOT} \
--db-url=${DB_DRIVER}://${DB_USER}:${DB_PASS}@${DB_HOST}/${DB} \
--account-name=${DRUPAL_UID1} \
--account-pass=${DRUPAL_UID1_PASS} \
--account-mail=${DRUPAL_UID1_MAIL} \
--site-mail=${DRUPAL_SITE_MAIL} \
--site-name=${DRUPAL_SITE_NAME} 2>&1 \
&& echo -e "\n# Site installation was successful." \
|| { echo -e "\n# FAILED!"; exit 4; }
exit 0
# @file example build configuration
#
# Webserver specific
#
# Path of the directory
# where to build should take place
#WEB_DIR='/var/www/fserver6_builds'
# Name of DocumentRoot within $WEB_DIR
# where the webserver should point to
#DOC_ROOT='fserver6_build'
#
# Buid process specific
#
# Path to makefile
#BUILD_MAKEFILE='https://raw.github.com/fl3a/fserver_profile/master/drupal-org.make'
# Machine name of the profile that should be installed
#BUILD_PROFILE='fserver_profile'
# Date prefix for build
#BUILD_DATE=$(date +%Y%m%d%H%M%S)
# Name pattern for the build
#BUILD=${DOC_ROOT}-${BUILD_DATE}
#
# Options for drush site-install
# @see drush help site-install
#
# Specific path to drush version for drush site-install command
#DRUSH_SITE_INSTALL_DRUSH='/usr/local/share/drush-4.6/drush'
# --account-name Option
#DRUPAL_UID1='Hochwohlgeboren'
# --ACCOUNT-PASS OPTION
#DRUPAL_UID1_PASS='FbVZQkU5OAYmg'
# --account-mail
#DRUPAL_UID1_MAIL='mail@example.com'
# --site-name Option
#DRUPAL_SITE_NAME=${BUILD}
# --site-mail Option
#DRUPAL_SITE_MAIL='mail@example.com'
#DRUPAL_SITE_MAIL=${DRUPAL_UID1_MAIL}
#
# Database specific settings to build db_url
# ${DB_DRIVER}://${DB_USER}:${DB_PASS}@${DB_HOST}/${DB}
#
#DB_DRIVER="mysqli"
#DB_USER="fserver6_build"
#DB_PASS="FbVZQkU5OAYmg"
#DB_HOST="localhost"
#DB="fserver6_build"
#
# Additional drush make options
# @see drush help make
#
#MAKE_OPTIONS='--nocolor --md5=print --no-patch-txt'
#
# Additional drush site-install (si) options
# @see drush help site-install
#
#SI_OPTIONS='--nocolor'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment