#!/bin/bash


###----------------------------------------###
###
###  Octopus Aegir Installer
###
###  Copyright (C) 2010-2014 Omega8.cc
###  noc@omega8.cc www.omega8.cc
###
###  This program is free software. You can
###  redistribute it and/or modify it under
###  the terms of the GNU GPL as published by
###  the Free Software Foundation, version 2
###  or later.
###
###  This program is distributed in the hope
###  that it will be useful, but WITHOUT ANY
###  WARRANTY; without even the implied
###  warranty of MERCHANTABILITY or FITNESS
###  FOR A PARTICULAR PURPOSE. See the GNU GPL
###  for more details.
###
###  You should have received a copy of the
###  GNU GPL along with this program.
###  If not, see http://www.gnu.org/licenses/
###
###  Code: https://code.aegir.cc/aegir
###
###----------------------------------------###


###----------------------------------------###
### DON'T EDIT ANYTHING BELOW THIS LINE    ###
###----------------------------------------###

_INSTALLER_VERSION=EDIT_INSTALLER_VERSION


###---### Distro config.
#
_AGOV=EDIT_AGOV
_CIVICRM_M6=EDIT_CIVICRM_M6
_CIVICRM_M7=EDIT_CIVICRM_M7
_COD=EDIT_COD
_COMMERCE1=EDIT_COMMERCE1
_COMMERCE2=EDIT_COMMERCE2
_COMMONS2=EDIT_COMMONS2
_COMMONS3=EDIT_COMMONS3
_DRUPAL_EDGE_8=EDIT_DRUPAL_EDGE_8
_DRUPAL7=EDIT_DRUPAL7
_DRUPAL7D="EDIT_DRUPAL7-dev"
_DRUPAL7P="EDIT_DRUPAL7-prod"
_DRUPAL7S="EDIT_DRUPAL7-stage"
_DRUPAL8=EDIT_DRUPAL8
_ERPAL=EDIT_ERPAL
_GUARDR=EDIT_GUARDR
_MANAGINGNEWS=EDIT_MANAGINGNEWS
_NODESTREAM7=EDIT_NODESTREAM7
_OPEN_DEALS=EDIT_OPEN_DEALS
_OPENACADEMY=EDIT_OPENACADEMY
_OPENATRIUM6=EDIT_OPENATRIUM6
_OPENATRIUM7=EDIT_OPENATRIUM7
_OPENBLOG=EDIT_OPENBLOG
_OPENCHURCH=EDIT_OPENCHURCH
_OPENDEALS=EDIT_OPENDEALS
_OPENOUTREACH=EDIT_OPENOUTREACH
_OPENPUBLISH=EDIT_OPENPUBLISH
_OPENSCHOLAR=EDIT_OPENSCHOLAR
_PANOPOLY=EDIT_PANOPOLY
_PROSEPOINT=EDIT_PROSEPOINT
_RECRUITER=EDIT_RECRUITER
_RESTAURANT=EDIT_RESTAURANT
_SMALLCORE6=EDIT_SMALLCORE6
_SMALLCORE7=EDIT_SMALLCORE7
_SMALLCORE8=EDIT_SMALLCORE8
_SPARK=EDIT_SPARK
_TOTEM=EDIT_TOTEM
_UBERCART6=EDIT_UBERCART6
_UBERCART7=EDIT_UBERCART7


###---### Main config.
#
_AEGIR_VERSION=EDIT_AEGIR_VERSION
_ALL_DISTRO=EDIT_ALL_DISTRO
_ALLOW_UNSUPPORTED=EDIT_ALLOW_UNSUPPORTED
_AUTOPILOT=EDIT_AUTOPILOT
_BOA_REPO_GIT_URL=EDIT_BOA_REPO_GIT_URL
_BOA_REPO_NAME=EDIT_BOA_REPO_NAME
_CLIENT_CORES=EDIT_CLIENT_CORES
_CLIENT_OPTION=EDIT_CLIENT_OPTION
_DEBUG_MODE=EDIT_DEBUG_MODE
_DISTRO=EDIT_DISTRO
_DOMAIN=EDIT_DOMAIN
_DRUSH_VERSION=EDIT_DRUSH_VERSION
_HM_DISTRO=EDIT_HM_DISTRO
_HM_ONLY=EDIT_HM_ONLY
_HOT_SAUCE=EDIT_HOT_SAUCE
_LAST_ALL=EDIT_LAST_ALL
_LAST_HMR=EDIT_LAST_HMR
_LASTNUM=EDIT_LASTNUM
_NOW=EDIT_NOW
_O_CONTRIB_UP=EDIT_O_CONTRIB_UP
_PHP_CLI_VERSION=EDIT_PHP_CLI_VERSION
_PHP_FPM_VERSION=EDIT_PHP_FPM_VERSION
_PLATFORMS_LIST="EDIT_PLATFORMS_LIST"
_PURGE_FOR_SEVEN=EDIT_PURGE_FOR_SEVEN
_PURGE_MODE=EDIT_PURGE_MODE
_SPINNER=EDIT_SPINNER
_SRCDIR=/opt/tmp/files
_STATUS=INIT
_T_BUILD=EDIT_T_BUILD
_THIS_DB_HOST=EDIT_THIS_DB_HOST
_TODAY=`date +%y%m%d`
_USE_CURRENT=EDIT_USE_CURRENT
_USE_STOCK=EDIT_USE_STOCK
_WEBG=EDIT_WEBG
#
_USER=EDIT_USER
_ROOT="/data/disk/$_USER"
_HOSTMASTER_ROOT="$_ROOT/aegir/distro/$_HM_DISTRO"
_PREV_HOSTMASTER_ROOT="$_ROOT/aegir/distro/$_LAST_HMR"
_LOG=/var/backups/octopus-$_USER-$_NOW.log
#
if [ "$_PHP_CLI_VERSION" = "5.5" ] && [ -x "/opt/php55/bin/php" ] ; then
  _L_PHP_CLI=/opt/php55/bin
elif [ "$_PHP_CLI_VERSION" = "5.4" ] && [ -x "/opt/php54/bin/php" ] ; then
  _L_PHP_CLI=/opt/php54/bin
elif [ "$_PHP_CLI_VERSION" = "5.3" ] && [ -x "/opt/php53/bin/php" ] ; then
  _L_PHP_CLI=/opt/php53/bin
elif [ "$_PHP_CLI_VERSION" = "5.2" ] && [ -x "/opt/php52/bin/php" ] ; then
  _L_PHP_CLI=/opt/php52/bin
fi
_DRUSHCMD="$_L_PHP_CLI/php $_ROOT/tools/drush/drush.php"
#
if [ "$_PHP_FPM_VERSION" != "5.2" ] && [ "$_PHP_CLI_VERSION" != "5.2" ] ; then
  _D_8_ALLOW=YES
else
  _D_8_ALLOW=NO
fi
#
SHELL=/bin/bash
PATH=$_L_PHP_CLI:/usr/local/bin:/usr/local/sbin:/opt/local/bin:/usr/bin:/usr/sbin:/bin:/sbin


###---### Functions.
#
# Noticeable messages.
msg () {
  echo "Octopus [`date`] ==> $*"
}
#
# Simple prompt.
prompt_yes_no () {
if [ "$_AUTOPILOT" = "YES" ]; then
  return 0
else
  while true ; do
    printf "$* [Y/n] "
    read answer
    if [ -z "$answer" ] ; then
      return 0
    fi
    case $answer in
      [Yy]|[Yy][Ee][Ss])
        return 0
        ;;
      [Nn]|[Nn][Oo])
        return 1
        ;;
      *)
        echo "Please answer yes or no"
        ;;
    esac
 done
fi
}
#
# Small spinner.
mrun () {
  CMD="$1"
  touch busy
  if [ "$_SPINNER" = "YES" ] ; then
    bash $_SRCDIR/spinner busy &
  fi
  if $CMD >> $_LOG; then
    rm busy
    sleep 1
    return 0
  fi
}
#
# Extract archive.
extract_archive () {
  if [ ! -z $1 ] ; then
    case $1 in
      *.tar.bz2)   tar xjf $1    ;;
      *.tar.gz)    tar xzf $1    ;;
      *.bz2)       bunzip2 $1    ;;
      *.rar)       unrar x $1    ;;
      *.gz)        gunzip -q $1  ;;
      *.tar)       tar xf $1     ;;
      *.tbz2)      tar xjf $1    ;;
      *.tgz)       tar xzf $1    ;;
      *.zip)       unzip -qq $1  ;;
      *.Z)         uncompress $1 ;;
      *.7z)        7z x $1       ;;
      *)           echo "'$1' cannot be extracted via >extract<" ;;
    esac
    rm -f $1
  fi
}
#
# Download and extract from dev/contrib mirror.
get_dev_contrib () {
  if [ ! -z $1 ] ; then
    curl -L --max-redirs 10 -k -s -O --retry 10 --retry-delay 15 -A iCab "http://files.aegir.cc/dev/contrib/$1"
    extract_archive "$1"
  fi
}
#
# Download and extract from distro.
get_distro_ext () {
  if [ ! -z $1 ] ; then
    curl -L --max-redirs 10 -k -s -O --retry 10 --retry-delay 15 -A iCab "http://files.aegir.cc/distro/$1"
    extract_archive "$1"
  fi
}
#
# Create standard directories.
fix_dirs_files () {
  rm -f ./*.txt
  rm -f ./modules/*.txt
  rm -f ./themes/*.txt
  rm -f -r ./modules/cookie_cache_bypass
  mkdir -p ./sites/default/files
  mkdir -p ./cache/{normal,perm}
  chmod -R 777 ./cache
  if [ -e "./sites/default/default.settings.php" ] ; then
    cp -af ./sites/default/default.settings.php ./sites/default/settings.php
  fi
  chmod a+rw ./sites/default/settings.php
  chmod a+rwx ./sites/default/files
  mkdir -p ./profiles
  mkdir -p ./sites/all/{modules,libraries,themes}
  rm -f ./core/modules/*.txt
  rm -f ./core/themes/*.txt
  rm -f ./modules/*.txt
  rm -f ./themes/*.txt
  rm -f ./sites/all/*.txt
  echo empty > ./profiles/EMPTY.txt
  echo empty > ./sites/all/EMPTY.txt
  echo empty > ./sites/all/modules/EMPTY.txt
  echo empty > ./sites/all/libraries/EMPTY.txt
  echo empty > ./sites/all/themes/EMPTY.txt
  chmod 0755 ./profiles &> /dev/null
  chmod 0751 ./sites
  chmod 0751 ./sites/all
  chmod 02775 ./sites/all/{modules,libraries,themes}
  cp -af /opt/tmp/$_BOA_REPO_NAME/aegir/conf/get.htaccess.txt ./.htaccess
  cp -af /opt/tmp/$_BOA_REPO_NAME/aegir/conf/crossdomain.xml ./
}
#
# Create D6 symlinks.
create_d6_symlinks () {
  if [ ! -L "includes" ] ; then
    ln -sf $_D6_CORE_DIR/.htaccess .htaccess
    ln -sf $_D6_CORE_DIR/boost_stats.php boost_stats.php
    ln -sf $_D6_CORE_DIR/cron.php cron.php
    ln -sf $_D6_CORE_DIR/crossdomain.xml crossdomain.xml
    ln -sf $_D6_CORE_DIR/includes includes
    ln -sf $_D6_CORE_DIR/index.php index.php
    ln -sf $_D6_CORE_DIR/install.php install.php
    ln -sf $_D6_CORE_DIR/js.php js.php
    ln -sf $_D6_CORE_DIR/misc misc
    ln -sf $_D6_CORE_DIR/modules modules
    ln -sf $_D6_CORE_DIR/themes themes
    ln -sf $_D6_CORE_DIR/update.php update.php
    ln -sf $_D6_CORE_DIR/xmlrpc.php xmlrpc.php
    cp -af $_D6_CORE_DIR/sites ./
  fi
  if [ ! -L "$_OCTO_PLPATH/profiles" ] && [ -d "$_SHRD_PLPATH/profiles" ] ; then
    rm -f -r $_OCTO_PLPATH/profiles
    ln -s $_SHRD_PLPATH/profiles $_OCTO_PLPATH/profiles
  fi
}
#
# Create D7 symlinks.
create_d7_symlinks () {
  if [ ! -L "web.config" ] ; then
    ln -sf $_D7_CORE_DIR/.htaccess .htaccess
    ln -sf $_D7_CORE_DIR/authorize.php authorize.php
    ln -sf $_D7_CORE_DIR/cron.php cron.php
    ln -sf $_D7_CORE_DIR/crossdomain.xml crossdomain.xml
    ln -sf $_D7_CORE_DIR/includes includes
    ln -sf $_D7_CORE_DIR/index.php index.php
    ln -sf $_D7_CORE_DIR/install.php install.php
    ln -sf $_D7_CORE_DIR/js.php js.php
    ln -sf $_D7_CORE_DIR/misc misc
    ln -sf $_D7_CORE_DIR/modules modules
    ln -sf $_D7_CORE_DIR/themes themes
    ln -sf $_D7_CORE_DIR/update.php update.php
    ln -sf $_D7_CORE_DIR/web.config web.config
    ln -sf $_D7_CORE_DIR/xmlrpc.php xmlrpc.php
    cp -af $_D7_CORE_DIR/sites ./
  fi
  if [ ! -L "$_OCTO_PLPATH/profiles" ] && [ -d "$_SHRD_PLPATH/profiles" ] ; then
    rm -f -r $_OCTO_PLPATH/profiles
    ln -s $_SHRD_PLPATH/profiles $_OCTO_PLPATH/profiles
  fi
}
#
# Create D8 symlinks.
create_d8_symlinks () {
  if [ ! -L "core" ] ; then
    ln -sf $_D8_CORE_DIR/.htaccess .htaccess
    ln -sf $_D8_CORE_DIR/core core
    ln -sf $_D8_CORE_DIR/crossdomain.xml crossdomain.xml
    ln -sf $_D8_CORE_DIR/index.php index.php
    ln -sf $_D8_CORE_DIR/web.config web.config
    cp -af $_D8_CORE_DIR/sites ./
  fi
  if [ ! -L "$_OCTO_PLPATH/profiles" ] && [ -d "$_SHRD_PLPATH/profiles" ] ; then
    rm -f -r $_OCTO_PLPATH/profiles
    ln -s $_SHRD_PLPATH/profiles $_OCTO_PLPATH/profiles
  fi
}
#
# Rename D7 profiles.
rename_drupal7_profiles () {
  for Files in `find ./profiles -type f`
  do
    sed -i "s/name = Minimal/name = Vanilla Minimal/g"   $Files &> /dev/null
    sed -i "s/name = Standard/name = Vanilla Standard/g" $Files &> /dev/null
    sed -i "s/name = Testing/name = Vanilla Testing/g"   $Files &> /dev/null
    sed -i "s/hidden = TRUE//g"                          $Files &> /dev/null
  done
}
#
# Rename D8 profiles.
rename_drupal8_profiles () {
  for Files in `find ./core/profiles -type f`
  do
    sed -i "s/name = Minimal/name = Vanilla Minimal/g"   $Files &> /dev/null
    sed -i "s/name = Standard/name = Vanilla Standard/g" $Files &> /dev/null
    sed -i "s/name = Testing/name = Vanilla Testing/g"   $Files &> /dev/null
  done
}
#
# Prepare D6 core.
prepare_drupal6_core () {
  if [ ! -e "$_D6_CORE_DIR" ] ; then
    rm -f -r $_D6_CORE_DIR
    cd /data/all/000/core
    curl -L --max-redirs 10 -k -s -A iCab "http://files.aegir.cc/core/pressflow-$_SMALLCORE6.tar.gz" | tar -xzf -
    cd $_D6_CORE_DIR/
    fix_dirs_files
    patch -p0 < /opt/tmp/$_BOA_REPO_NAME/aegir/patches/taxonomy-6.26.patch &> /dev/null
    rm -f $_D6_CORE_DIR/modules/taxonomy/taxonomy.module.orig
    rm -f modules/o_contrib
    ln -s $_CORE/o_contrib modules/o_contrib
    ln -s $_CORE/o_contrib/js/js.php js.php
    cp -af $_CORE/o_contrib/image/image.imagemagick.inc includes/
    cp -af $_CORE/o_contrib/boost/stats/boost_stats.php ./ &> /dev/null
    rm -f -r $_D6_CORE_DIR/scripts
    rm -f -r $_D6_CORE_DIR/themes/{bluemarine,chameleon,pushbutton,README.txt}
    cd $_D6_CORE_DIR/themes
    get_dev_contrib "rubik-6.x-3.0-beta5.tar.gz"
    get_dev_contrib "tao-6.x-3.3.tar.gz"
    rm -f $_D6_CORE_DIR/sites/all/*.txt
    cd $_CORE
  fi
}
#
# Prepare D7 core.
prepare_drupal7_core () {
  if [ ! -e "$_D7_CORE_DIR" ] ; then
    rm -f -r $_D7_CORE_DIR
    cd /data/all/000/core
    curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "http://files.aegir.cc/core/drupal-$_SMALLCORE7.tar.gz" | tar -xzf -
    cd $_D7_CORE_DIR/
    fix_dirs_files
    rename_drupal7_profiles
    patch -p0 < /opt/tmp/$_BOA_REPO_NAME/aegir/patches/taxonomy-7.12.patch &> /dev/null
    rm -f $_D7_CORE_DIR/modules/taxonomy/taxonomy.module.orig
    rm -f modules/o_contrib_seven
    ln -s $_CORE/o_contrib_seven modules/o_contrib_seven
    ln -s $_CORE/o_contrib_seven/js/js.php js.php
    rm -f -r $_D7_CORE_DIR/scripts
    cd $_D7_CORE_DIR/themes
    get_dev_contrib "rubik-7.x-4.1.tar.gz"
    get_dev_contrib "tao-7.x-3.1.tar.gz"
    cd $_CORE
  fi
}
#
# Prepare D8 core.
prepare_drupal8_core () {
  if [ ! -e "$_D8_CORE_DIR" ] ; then
    rm -f -r $_D8_CORE_DIR
    cd /data/all/000/core
    curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "http://files.aegir.cc/core/drupal-$_SMALLCORE8.tar.gz" | tar -xzf -
    cd $_D8_CORE_DIR/
    fix_dirs_files
    rename_drupal8_profiles
    rm -f modules/o_contrib_eight
    ln -s $_CORE/o_contrib_eight modules/o_contrib_eight
    cd $_CORE
  fi
}
#
# Remove D6 core from distro directory.
nocore_d6_dist_clean () {
  rm -f $_SHRD_PLPATH/.gitignore
  rm -f $_SHRD_PLPATH/.htaccess
  rm -f $_SHRD_PLPATH/*.php
  rm -f $_SHRD_PLPATH/*.txt
  rm -f $_SHRD_PLPATH/*.xml
  rm -f -r $_SHRD_PLPATH/cache
  rm -f -r $_SHRD_PLPATH/includes
  rm -f -r $_SHRD_PLPATH/misc
  rm -f -r $_SHRD_PLPATH/modules
  rm -f -r $_SHRD_PLPATH/sites
  rm -f -r $_SHRD_PLPATH/scripts
  rm -f -r $_SHRD_PLPATH/themes
  if [ ! -d "$_SHRD_PLPATH/profiles" ] && [ -d "$_D6_CORE_DIR/profiles" ] ; then
    rm -f -r $_SHRD_PLPATH/profiles
    cp -af $_D6_CORE_DIR/profiles $_SHRD_PLPATH/
  fi
  sed -i "s/'dblog'/'robotstxt', 'path_alias_cache'/g" $_SHRD_PRPATH/$_REAL_PRNAME.profile &> /dev/null
}
#
# Remove D7 core from distro directory.
nocore_d7_dist_clean () {
  rm -f $_SHRD_PLPATH/.gitignore
  rm -f $_SHRD_PLPATH/.htaccess
  rm -f $_SHRD_PLPATH/*.php
  rm -f $_SHRD_PLPATH/*.txt
  rm -f $_SHRD_PLPATH/*.xml
  rm -f $_SHRD_PLPATH/web.config
  rm -f -r $_SHRD_PLPATH/cache
  rm -f -r $_SHRD_PLPATH/includes
  rm -f -r $_SHRD_PLPATH/misc
  rm -f -r $_SHRD_PLPATH/modules
  rm -f -r $_SHRD_PLPATH/sites
  rm -f -r $_SHRD_PLPATH/scripts
  rm -f -r $_SHRD_PLPATH/themes
  _REVISIONS="10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26"
  for i in $_REVISIONS; do
    if [ -d "$_CORE/drupal-7.$i" ] && [ ! -e "$_SHRD_PLPATH" ] ; then
      mv $_CORE/drupal-7.$i $_SHRD_PLPATH
    fi
  done
  if [ ! -d "$_SHRD_PLPATH/profiles" ] && [ -d "$_D7_CORE_DIR/profiles" ] ; then
    rm -f -r $_SHRD_PLPATH/profiles
    cp -af $_D7_CORE_DIR/profiles $_SHRD_PLPATH/
  fi
}
#
# Remove D8 core from distro directory.
nocore_d8_dist_clean () {
  rm -f $_SHRD_PLPATH/.gitignore
  rm -f $_SHRD_PLPATH/.htaccess
  rm -f $_SHRD_PLPATH/*.php
  rm -f $_SHRD_PLPATH/*.txt
  rm -f $_SHRD_PLPATH/*.xml
  rm -f $_SHRD_PLPATH/web.config
  rm -f -r $_SHRD_PLPATH/cache
  rm -f -r $_SHRD_PLPATH/core
  rm -f -r $_SHRD_PLPATH/includes
  rm -f -r $_SHRD_PLPATH/misc
  rm -f -r $_SHRD_PLPATH/modules
  rm -f -r $_SHRD_PLPATH/scripts
  rm -f -r $_SHRD_PLPATH/sites
  rm -f -r $_SHRD_PLPATH/themes
  if [ ! -d "$_SHRD_PLPATH/profiles" ] && [ -d "$_D8_CORE_DIR/profiles" ] ; then
    rm -f -r $_SHRD_PLPATH/profiles
    cp -af $_D8_CORE_DIR/profiles $_SHRD_PLPATH/
  fi
}
#
# Enable D6 admin.
enable_drupal6_admin () {
  sed -i "s/'path_alias_cache'/'path_alias_cache', 'admin'/g" $_SHRD_PRPATH/$_REAL_PRNAME.profile &> /dev/null
}
#
# Remove default core seven profiles.
remove_default_core_seven_profiles () {
  rm -f -r $_SHRD_PLPATH/profiles/minimal
  rm -f -r $_SHRD_PLPATH/profiles/standard
  rm -f -r $_SHRD_PLPATH/profiles/testing
}
#
# Init this distro root.
init_this_distro_root () {
  mkdir -p $_OCTO_PLPATH
  cd $_OCTO_PLPATH
  if [[ "$_SHRD_PLNAME" =~ "-$_SMALLCORE6" ]] ; then
    create_d6_symlinks
  elif [[ "$_SHRD_PLNAME" =~ "-$_SMALLCORE7" ]] ; then
    create_d7_symlinks
  else
    create_d8_symlinks
  fi
}
#
# Upgrade contrib less.
upgrade_contrib_less () {
  rm -f -r {context,ctools,entity,entityreference,mimemail,og}
  get_dev_contrib "context-7.x-3.2.tar.gz"
  get_dev_contrib "ctools-7.x-1.4.tar.gz"
  get_dev_contrib "entity-7.x-1.5.tar.gz"
  get_dev_contrib "entityreference-7.x-1.1.tar.gz"
  get_dev_contrib "mimemail-7.x-1.0-beta3.tar.gz"
  get_dev_contrib "og-7.x-2.7.tar.gz"
  if [ -e "views" ] ; then
    cd views
    # https://drupal.org/node/1766338#comment-6445882
    patch -p1 < /opt/tmp/$_BOA_REPO_NAME/aegir/patches/views-revert-broken-filter-or-groups-1766338-7.patch &> /dev/null
    # https://drupal.org/node/2037469
    patch -p1 < /opt/tmp/$_BOA_REPO_NAME/aegir/patches/views-exposed-sorts-2037469-1.patch &> /dev/null
    cd ../
  fi
  if [ -e "apps" ] ; then
    cd apps
    patch -p1 < /opt/tmp/$_BOA_REPO_NAME/aegir/patches/apps_msg.patch &> /dev/null
    cd ../
  fi
  cd $_CORE
}
#
# Create D7 basic platform.
create_drupal7_basic () {
  if [ ! -d "$_SHRD_PLPATH" ] ; then
    mkdir -p $_SHRD_PLPATH
    if [ ! -e "$_D7_CORE_DIR" ] ; then
      prepare_drupal7_core
    fi
    nocore_d7_dist_clean
  fi
  init_this_distro_root
}


###---### Checking status.
#
if [ -e "$_ROOT/log/setupmail.txt" ] ; then
  _STATUS=UPGRADE
  cd $_ROOT
fi


###---### User check.
#
msg "$_STATUS C: Aegir automated install script part C"
if [ `whoami` = "root" ] ; then
  msg "$_STATUS C: FATAL ERROR: This script should be ran as a non-root user"
  msg "$_STATUS C: FATAL ERROR: Aborting AegirSetupC installer NOW!"
  touch /opt/tmp/status-AegirSetupC-FAIL
  exit 1
fi


###---### Hot Sauce check.
#
if [ "$_HOT_SAUCE" = "NO" ] ; then
  _CORE="/data/all/$_LAST_ALL"
  _THIS_CORE="$_LAST_ALL"
  if [ "$_USE_CURRENT" = "YES" ] && [ -e "/data/all/000/core-v-$_SMALLCORE6.txt" ] && [ -e "/data/all/000/core-v-$_SMALLCORE7.txt" ] ; then
    msg "$_STATUS C: Shared platforms code v.$_LAST_ALL (latest available) will be used for this install"
  elif [ "$_USE_CURRENT" = "NO" ] || [ ! -e "/data/all/000/core-v-$_SMALLCORE6.txt" ] || [ ! -e "/data/all/000/core-v-$_SMALLCORE7.txt" ] ; then
    _CORE="/data/all/$_ALL_DISTRO"
    _THIS_CORE="$_ALL_DISTRO"
    msg "$_STATUS C: Shared platforms code v.$_ALL_DISTRO (hot new) will be created"
  else
    msg "$_STATUS C: Shared platforms code v.$_LAST_ALL (latest available) will be used for this install"
  fi
else
  _CORE="/data/all/$_ALL_DISTRO"
  _THIS_CORE="$_ALL_DISTRO"
  msg "$_STATUS C: Shared platforms code v.$_ALL_DISTRO (hot new) will be created"
fi
_D6_CORE_DIR="/data/all/000/core/pressflow-$_SMALLCORE6"
_D7_CORE_DIR="/data/all/000/core/drupal-$_SMALLCORE7"
_D8_CORE_DIR="/data/all/000/core/drupal-$_SMALLCORE8"


###---### Distributions full names.
#
_F_ACQUIA="Acquia $_SMALLCORE6 P.$_THIS_CORE"
_F_AGOV="aGov 1.0-rc8 $_SMALLCORE7 P.$_THIS_CORE"
_F_CIVICRM_M6="CiviCRM $_CIVICRM_M6 $_SMALLCORE6 P.$_THIS_CORE"
_F_CIVICRM_M7="CiviCRM $_CIVICRM_M7 $_SMALLCORE7 P.$_THIS_CORE"
_F_COD="Conference 1.0-a5 $_SMALLCORE7 P.$_THIS_CORE"
_F_COMMERCE1="Commerce 1.25 $_SMALLCORE7 P.$_THIS_CORE"
_F_COMMERCE2="Commerce 2.15 $_SMALLCORE7 P.$_THIS_CORE"
_F_COMMONS2="Commons 2.17 $_SMALLCORE6 P.$_THIS_CORE"
_F_COMMONS3="Commons 3.13 $_SMALLCORE7 P.$_THIS_CORE"
_F_DRUPAL_EDGE_8="Drupal $_DRUPAL_EDGE_8"
_F_DRUPAL6="Drupal $_SMALLCORE6 P.$_THIS_CORE"
_F_DRUPAL7="Drupal $_SMALLCORE7 P.$_THIS_CORE"
_F_DRUPAL8="Drupal $_SMALLCORE8 P.$_THIS_CORE"
_F_ERPAL="ERPAL 2.0-b2 $_SMALLCORE7 P.$_THIS_CORE"
_F_FSERVER="Feature Server 1.2 $_SMALLCORE6 P.$_THIS_CORE"
_F_GUARDR="Guardr 1.4 $_SMALLCORE7 P.$_THIS_CORE"
_F_MANAGINGNEWS="MNews $_MANAGINGNEWS $_SMALLCORE6 P.$_THIS_CORE"
_F_NODESTREAM7="NodeStream 2.0-rc5 $_SMALLCORE7 P.$_THIS_CORE"
_F_OPENACADEMY="Open Academy 1.0 $_SMALLCORE7 P.$_THIS_CORE"
_F_OPENATRIUM6="Open Atrium 1.7.2 $_SMALLCORE6 P.$_THIS_CORE"
_F_OPENATRIUM7="Open Atrium 2.19 $_SMALLCORE7 P.$_THIS_CORE"
_F_OPENBLOG="OpenBlog 1.0-a3 $_SMALLCORE7 P.$_THIS_CORE"
_F_OPENCHURCH="OpenChurch 1.12 $_SMALLCORE7 P.$_THIS_CORE"
_F_OPENDEALS="Open Deals $_OPEN_DEALS $_SMALLCORE7 P.$_THIS_CORE"
_F_OPENOUTREACH="Open Outreach 1.7 $_SMALLCORE7 P.$_THIS_CORE"
_F_OPENPUBLISH="OpenPublish 3.0-b7 $_SMALLCORE7 P.$_THIS_CORE"
_F_OPENSCHOLAR="OpenScholar 3.12.1 $_SMALLCORE7 P.$_THIS_CORE"
_F_PANOPOLY="Panopoly 1.6 $_SMALLCORE7 P.$_THIS_CORE"
_F_PROSEPOINT="Prosepoint $_PROSEPOINT $_SMALLCORE6 P.$_THIS_CORE"
_F_RECRUITER="Recruiter 1.2 $_SMALLCORE7 P.$_THIS_CORE"
_F_RESTAURANT="Restaurant 1.0-a5 $_SMALLCORE7 P.$_THIS_CORE"
_F_SPARK="Spark 1.0-b1 $_SMALLCORE7 P.$_THIS_CORE"
_F_TOTEM="Totem 1.1.2 $_SMALLCORE7 P.$_THIS_CORE"
_F_UBER_CART_TESTING="Ubercart $_UBERCART7 [ud2] $_SMALLCORE7 P.$_THIS_CORE"
_F_UBERCART6="Ubercart $_UBERCART6 $_SMALLCORE6 P.$_THIS_CORE"
_F_UBERCART7="Ubercart $_UBERCART7 [aq3] $_SMALLCORE7 P.$_THIS_CORE"
#
_F_DRUPAL6_D="Drupal $_SMALLCORE6 D.$_THIS_CORE"
_F_DRUPAL6_S="Drupal $_SMALLCORE6 S.$_THIS_CORE"
_F_DRUPAL6_P="Drupal $_SMALLCORE6 P.$_THIS_CORE"
_F_DRUPAL7_D="Drupal $_SMALLCORE7 D.$_THIS_CORE"
_F_DRUPAL7_S="Drupal $_SMALLCORE7 S.$_THIS_CORE"
_F_DRUPAL7_P="Drupal $_SMALLCORE7 P.$_THIS_CORE"


###---### Create directories.
#
mkdir -p $_ROOT/distro/$_THIS_CORE
chmod 0711 $_ROOT/distro &> /dev/null
chmod 0711 $_ROOT/distro/$_THIS_CORE &> /dev/null


###---###
_ALLOW_ALL=YES
_ALLOW_CIVICRM=YES
if [ "$_CLIENT_CORES" -lt "1" ] ; then
  _ALLOW_ALL=NO
  _ALLOW_CIVICRM=NO
  _D_8_ALLOW=NO
fi
if [[ "$_VM_TEST" =~ beng ]] ; then
  _VMFAMILY="VS"
else
  _VMFAMILY="XEN"
fi
if [[ "$_DOMAIN" =~ ".host8." ]] || [ "$_VMFAMILY" = "VS" ] ; then
  if [[ "$_DOMAIN" =~ ".o8.io" ]] ; then
    _D_8_ALLOW=YES
  else
    _D_8_ALLOW=NO
  fi
fi


###---### Prepare D6 and D7 shared core
#
prepare_drupal6_core
prepare_drupal7_core


acquia_install () {
###---### Acquia
#
_REAL_PRNAME="acquia"
_SHRD_PLNAME="$_REAL_PRNAME-$_SMALLCORE6"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ AQ6 ]] ; then
if [ ! -d "$_OCTO_PLPATH/modules/path_alias_cache" ] ; then
echo " "
if prompt_yes_no "$_F_ACQUIA - http://bit.ly/acquiadrupal" ; then
true
msg "DISTRO: $_F_ACQUIA installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D6_CORE_DIR" ] ; then
      prepare_drupal6_core
    fi
    cd $_CORE
    get_distro_ext "vanilla-$_SHRD_PLNAME.tar.gz"
    nocore_d6_dist_clean
    rm -f -r $_SHRD_PLPATH/profiles/default
  else
    cd $_CORE
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_ACQUIA installation completed"
else
  msg "DISTRO: $_F_ACQUIA installation skipped"
fi
fi
fi
}


agov_install () {
###---### aGov
#
_REAL_PRNAME="agov"
_SHRD_PLNAME="$_REAL_PRNAME-$_AGOV-$_SMALLCORE7"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_ALLOW_ALL" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ AGV ]] ; then
if [ ! -d "$_OCTO_PLPATH" ] ; then
echo " "
if prompt_yes_no "$_F_AGOV - https://drupal.org/project/agov" ; then
true
msg "DISTRO: $_F_AGOV installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  cd $_CORE
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D7_CORE_DIR" ] ; then
      prepare_drupal7_core
    fi
    curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "http://ftp.drupal.org/files/projects/$_REAL_PRNAME-$_AGOV-core.tar.gz" | tar -xzf -
    if [ -d "$_CORE/$_REAL_PRNAME-$_AGOV" ] ; then
      mv $_REAL_PRNAME-$_AGOV $_SHRD_PLNAME
    fi
    nocore_d7_dist_clean
    remove_default_core_seven_profiles
    rm -f -r $_SHRD_PRPATH/modules/contrib/entitycache
    if [ $_AGOV = "7.x-1.0-rc8" ] ; then
      cd $_SHRD_PRPATH/modules/contrib
      rm -f -r {password_policy,views}
      get_dev_contrib "password_policy-7.x-1.6.tar.gz"
      get_dev_contrib "views-7.x-3.8.tar.gz"
      cd $_SHRD_PRPATH/modules/contrib/views
      # https://drupal.org/node/1766338#comment-6445882
      patch -p1 < /opt/tmp/$_BOA_REPO_NAME/aegir/patches/views-revert-broken-filter-or-groups-1766338-7.patch &> /dev/null
      # https://drupal.org/node/2037469
      patch -p1 < /opt/tmp/$_BOA_REPO_NAME/aegir/patches/views-exposed-sorts-2037469-1.patch &> /dev/null
      # upgrade_contrib_less
    fi
  else
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_AGOV installation completed"
else
  msg "DISTRO: $_F_AGOV installation skipped"
fi
fi
fi
fi
}


civicrm_m6_install () {
###---### CiviCRM Modern D6
#
_REAL_PRNAME="default"
_SHRD_PLNAME="civicrm-$_CIVICRM_M6-$_SMALLCORE6"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_ALLOW_CIVICRM" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ CM6 ]] ; then
if [ ! -d "$_OCTO_PLPATH/modules/path_alias_cache" ] ; then
echo " "
if prompt_yes_no "$_F_CIVICRM_M6 - http://civicrm.org" ; then
true
msg "DISTRO: $_F_CIVICRM_M6 installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D6_CORE_DIR" ] ; then
      prepare_drupal6_core
    fi
    cd $_CORE
    cp -af /opt/tmp/$_BOA_REPO_NAME/aegir/makefiles/civicrm-4.1-d6.make ./
    $_DRUSHCMD make civicrm-4.1-d6.make $_SHRD_PLNAME &> /dev/null
    rm -f civicrm-4.1-d6.make
    _CIVI_ENGAGE="$_SHRD_PLPATH/sites/all/modules/civicrm/drupal/modules/civicrm_engage"
    cp -af /opt/tmp/$_BOA_REPO_NAME/aegir/patches/civicrm_engage.install $_CIVI_ENGAGE/civicrm_engage.install &> /dev/null
    if [ ! -d "$_SHRD_PLPATH/sites/all/modules/civicrm/l10n" ] && [ -d "$_SHRD_PLPATH/sites/all/modules/civicrm/civicrm_l10n/l10n" ] ; then
      mv $_SHRD_PLPATH/sites/all/modules/civicrm/civicrm_l10n/l10n $_SHRD_PLPATH/sites/all/modules/civicrm/ &> /dev/null
    fi
    mkdir -p $_SHRD_PRPATH/modules
    mv $_SHRD_PLPATH/sites/all/modules/civicrm $_SHRD_PRPATH/modules/ &> /dev/null
    nocore_d6_dist_clean
    else
    cd $_CORE
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_CIVICRM_M6 installation completed"
else
  msg "DISTRO: $_F_CIVICRM_M6 installation skipped"
fi
fi
fi
fi
}


civicrm_m7_install () {
###---### CiviCRM Modern D7
#
_REAL_PRNAME="standard"
_SHRD_PLNAME="civicrm-$_CIVICRM_M7-$_SMALLCORE7"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_ALLOW_CIVICRM" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ CM7 ]] ; then
if [ ! -d "$_OCTO_PLPATH" ] ; then
echo " "
if prompt_yes_no "$_F_CIVICRM_M7 - http://civicrm.org" ; then
true
msg "DISTRO: $_F_CIVICRM_M7 installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  cd $_CORE
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D7_CORE_DIR" ] ; then
      prepare_drupal7_core
    fi
    cp -af /opt/tmp/$_BOA_REPO_NAME/aegir/makefiles/civicrm-4.3-d7.make ./
    $_DRUSHCMD make civicrm-4.3-d7.make $_SHRD_PLNAME &> /dev/null
    rm -f civicrm-4.3-d7.make
    if [ ! -d "$_SHRD_PLPATH/sites/all/modules/civicrm/l10n" ] && [ -d "$_SHRD_PLPATH/sites/all/modules/civicrm/civicrml10n/l10n" ] ; then
      mv $_SHRD_PLPATH/sites/all/modules/civicrm/civicrml10n/l10n $_SHRD_PLPATH/sites/all/modules/civicrm/ &> /dev/null
    fi
    mkdir -p $_SHRD_PRPATH/modules
    mv $_SHRD_PLPATH/sites/all/modules/civicrm $_SHRD_PRPATH/modules/ &> /dev/null
    rm -f -r $_SHRD_PLPATH/profiles/testing
    rm -f -r $_SHRD_PLPATH/profiles/minimal
    nocore_d7_dist_clean
  else
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_CIVICRM_M7 installation completed"
else
  msg "DISTRO: $_F_CIVICRM_M7 installation skipped"
fi
fi
fi
fi
}


cod_install () {
###---### Conference Organizing Distribution
#
_REAL_PRNAME="cod"
_SHRD_PLNAME="$_REAL_PRNAME-$_COD-$_SMALLCORE7"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_ALLOW_ALL" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ COD ]] ; then
if [ ! -d "$_OCTO_PLPATH" ] ; then
echo " "
if prompt_yes_no "$_F_COD - https://drupal.org/project/cod" ; then
true
msg "DISTRO: $_F_COD installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  cd $_CORE
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D7_CORE_DIR" ] ; then
      prepare_drupal7_core
    fi
    curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "http://ftp.drupal.org/files/projects/$_REAL_PRNAME-$_COD-core.tar.gz" | tar -xzf -
    if [ -d "$_CORE/$_REAL_PRNAME-$_COD" ] ; then
      mv $_REAL_PRNAME-$_COD $_SHRD_PLNAME
    fi
    nocore_d7_dist_clean
    remove_default_core_seven_profiles
    sed -i "s/Conference Organizing Distribution (COD)/Conference/g" $_SHRD_PRPATH/$_REAL_PRNAME.profile &> /dev/null
    if [ $_COD = "7.x-1.0-alpha3" ] ; then
      cd $_SHRD_PRPATH/modules/contrib
      upgrade_contrib_less
    fi
  else
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_COD installation completed"
else
  msg "DISTRO: $_F_COD installation skipped"
fi
fi
fi
fi
}


commerce_7_1_install () {
###---### Commerce 7.x-1.x
#
_REAL_PRNAME="commerce_kickstart"
_SHRD_PLNAME="commerce-$_COMMERCE1-$_SMALLCORE7"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_ALLOW_ALL" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ DCE ]] ; then
if [ ! -d "$_OCTO_PLPATH" ] ; then
echo " "
if prompt_yes_no "$_F_COMMERCE1 - http://drupalcommerce.org" ; then
true
msg "DISTRO: $_F_COMMERCE1 installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  cd $_CORE
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D7_CORE_DIR" ] ; then
      prepare_drupal7_core
    fi
    curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "http://ftp.drupal.org/files/projects/$_REAL_PRNAME-$_COMMERCE1-core.tar.gz" | tar -xzf -
    if [ -d "$_CORE/commerce-$_COMMERCE1" ] ; then
      mv commerce-$_COMMERCE1 $_SHRD_PLNAME
    elif [ -d "$_CORE/$_REAL_PRNAME-$_COMMERCE1" ] ; then
      mv $_REAL_PRNAME-$_COMMERCE1 $_SHRD_PLNAME
    fi
    nocore_d7_dist_clean
    remove_default_core_seven_profiles
    cd $_SHRD_PRPATH
    patch -p1 < /opt/tmp/$_BOA_REPO_NAME/aegir/patches/$_REAL_PRNAME.patch &> /dev/null
    if [ $_COMMERCE1 = "7.x-1.21" ] ; then
      cd $_SHRD_PRPATH/modules
      rm -f -r {rules}
      get_dev_contrib "rules-7.x-2.7.tar.gz"
      upgrade_contrib_less
    fi
  else
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_COMMERCE1 installation completed"
else
  msg "DISTRO: $_F_COMMERCE1 installation skipped"
fi
fi
fi
fi
}


commerce_7_2_install () {
###---### Commerce 7.x-2.x
#
_REAL_PRNAME="commerce_kickstart"
_SHRD_PLNAME="commerce-$_COMMERCE2-$_SMALLCORE7"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_ALLOW_ALL" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ CME ]] ; then
if [ ! -d "$_OCTO_PLPATH" ] ; then
echo " "
if prompt_yes_no "$_F_COMMERCE2 - http://drupalcommerce.org" ; then
true
msg "DISTRO: $_F_COMMERCE2 installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  cd $_CORE
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D7_CORE_DIR" ] ; then
      prepare_drupal7_core
    fi
    curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "http://ftp.drupal.org/files/projects/$_REAL_PRNAME-$_COMMERCE2-core.tar.gz" | tar -xzf -
    if [ -d "$_CORE/commerce-$_COMMERCE2" ] ; then
      mv commerce-$_COMMERCE2 $_SHRD_PLNAME
    elif [ -d "$_CORE/$_REAL_PRNAME-$_COMMERCE2" ] ; then
      mv $_REAL_PRNAME-$_COMMERCE2 $_SHRD_PLNAME
    fi
    nocore_d7_dist_clean
    remove_default_core_seven_profiles
    cd $_SHRD_PRPATH
    patch -p1 < /opt/tmp/$_BOA_REPO_NAME/aegir/patches/$_REAL_PRNAME.patch &> /dev/null
    if [ $_COMMERCE2 = "7.x-2.10" ] ; then
      cd $_SHRD_PRPATH/modules/contrib
      rm -f -r {message_notify}
      get_dev_contrib "message_notify-7.x-2.5.tar.gz"
      upgrade_contrib_less
    fi
  else
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_COMMERCE2 installation completed"
else
  msg "DISTRO: $_F_COMMERCE2 installation skipped"
fi
fi
fi
fi
}


commons_6_install () {
###---### Commons 6.x
#
_REAL_PRNAME="drupal_commons"
_SHRD_PLNAME="commons-$_COMMONS2-$_SMALLCORE6"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_ALLOW_ALL" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ DCS ]] ; then
if [ ! -d "$_OCTO_PLPATH/modules/path_alias_cache" ] ; then
echo " "
if prompt_yes_no "$_F_COMMONS2 - http://acquia.com/drupalcommons" ; then
true
msg "DISTRO: $_F_COMMONS2 installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D6_CORE_DIR" ] ; then
      prepare_drupal6_core
    fi
    cd $_CORE
    get_distro_ext "commons-$_COMMONS2.tar.gz"
    if [ -d "$_CORE/acquia_commons" ] ; then
      mv $_CORE/acquia_commons $_SHRD_PLPATH
    elif [ -d "$_CORE/commons-$_COMMONS2" ] ; then
      mv $_CORE/commons-$_COMMONS2 $_SHRD_PLPATH
    else
      mv $_CORE/commons $_SHRD_PLPATH
    fi
    if [ $_COMMONS2 = "6.x-2.13" ] ; then
      cd $_SHRD_PRPATH/modules/contrib/og
      patch -p1 < /opt/tmp/$_BOA_REPO_NAME/aegir/patches/og_update_6205_commons_fix.patch &> /dev/null
    fi
    rm -f -r $_SHRD_PLPATH/profiles/default
    nocore_d6_dist_clean
    sed -i "s/'Commons'/'Commons 2'/g" $_SHRD_PRPATH/$_REAL_PRNAME.profile &> /dev/null
    if [ $_COMMONS2 = "6.x-2.13" ] ; then
      cd $_SHRD_PRPATH/modules/contrib
      rm -f -r {context,flag,password_policy}
      get_dev_contrib "context-6.x-3.3.tar.gz"
      get_dev_contrib "flag-6.x-2.1.tar.gz"
      get_dev_contrib "password_policy-6.x-1.6.tar.gz"
    fi
  else
    cd $_CORE
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
if [ ! -L "$_OCTO_PLPATH/sites/all/libraries/getid3" ] ; then
  mkdir -p $_OCTO_PLPATH/sites/all/libraries
  ln -sf $_SHRD_PRPATH/libraries/getid3 $_OCTO_PLPATH/sites/all/libraries/getid3
fi
msg "DISTRO: $_F_COMMONS2 installation completed"
else
  msg "DISTRO: $_F_COMMONS2 installation skipped"
fi
fi
fi
fi
}


commons_7_install () {
###---### Commons 7.x
#
_REAL_PRNAME="commons"
_SHRD_PLNAME="commons-$_COMMONS3-$_SMALLCORE7"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_ALLOW_ALL" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ CS7 ]] ; then
if [ ! -d "$_OCTO_PLPATH" ] ; then
echo " "
if prompt_yes_no "$_F_COMMONS3 - http://acquia.com/drupalcommons" ; then
true
msg "DISTRO: $_F_COMMONS3 installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  cd $_CORE
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D7_CORE_DIR" ] ; then
      prepare_drupal7_core
    fi
    curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "http://ftp.drupal.org/files/projects/$_REAL_PRNAME-$_COMMONS3-core.tar.gz" | tar -xzf -
    if [ -d "$_CORE/$_REAL_PRNAME-$_COMMONS3" ] ; then
      mv $_REAL_PRNAME-$_COMMONS3 $_SHRD_PLNAME
    fi
    nocore_d7_dist_clean
    remove_default_core_seven_profiles
    cd $_SHRD_PRPATH
    sed -i "s/name = Commons/name = Commons 3/g" $_SHRD_PRPATH/$_REAL_PRNAME.info &> /dev/null
    rm -f -r $_SHRD_PRPATH/modules/contrib/entitycache
    rm -f -r $_SHRD_PRPATH/modules/contrib/registry_rebuild
    if [ $_COMMONS3 = "7.x-3.4" ] ; then
      cd $_SHRD_PRPATH/modules/contrib
      upgrade_contrib_less
    fi
  else
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_COMMONS3 installation completed"
else
  msg "DISTRO: $_F_COMMONS3 installation skipped"
fi
fi
fi
fi
}


drupal6_install () {
###---### Drupal 6 Pressflow
#
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ D6D ]] || [[ $_PLATFORMS_LIST =~ D6S ]] || [[ $_PLATFORMS_LIST =~ D6P ]] ; then
if [ ! -d "$_ROOT/distro/$_THIS_CORE/pressflow-$_SMALLCORE6-prod/modules/path_alias_cache" ] ; then
echo " "
if prompt_yes_no "$_F_DRUPAL6 - http://pressflow.org" ; then
true

###---### Drupal 6 Pressflow Development
#
_REAL_PRNAME="default"
_SHRD_PLNAME="pressflow-$_SMALLCORE6-dev"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ D6D ]] ; then
msg "DISTRO: $_F_DRUPAL6_D installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  if [ ! -e "$_D6_CORE_DIR" ] ; then
    prepare_drupal6_core
  fi
  cd $_CORE
  mkdir -p $_SHRD_PLPATH
  nocore_d6_dist_clean
  enable_drupal6_admin
fi
init_this_distro_root
msg "DISTRO: $_F_DRUPAL6_D installation completed"
echo " "
fi

###---### Drupal 6 Pressflow Staging
#
_REAL_PRNAME="default"
_SHRD_PLNAME="pressflow-$_SMALLCORE6-stage"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ D6S ]] ; then
msg "DISTRO: $_F_DRUPAL6_S installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  if [ ! -e "$_D6_CORE_DIR" ] ; then
    prepare_drupal6_core
  fi
  cd $_CORE
  mkdir -p $_SHRD_PLPATH
  nocore_d6_dist_clean
  enable_drupal6_admin
fi
init_this_distro_root
msg "DISTRO: $_F_DRUPAL6_S installation completed"
echo " "
fi

###---### Drupal 6 Pressflow Production
#
_REAL_PRNAME="default"
_SHRD_PLNAME="pressflow-$_SMALLCORE6-prod"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ D6P ]] ; then
msg "DISTRO: $_F_DRUPAL6 installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  if [ ! -e "$_D6_CORE_DIR" ] ; then
    prepare_drupal6_core
  fi
  cd $_CORE
  mkdir -p $_SHRD_PLPATH
  nocore_d6_dist_clean
  enable_drupal6_admin
fi
init_this_distro_root
msg "DISTRO: $_F_DRUPAL6 installation completed"
fi

else
  msg "DISTRO: $_F_DRUPAL6 installation skipped"
fi
fi
fi
}


drupal7_install () {
###---### Drupal 7
#
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ D7D ]] || [[ $_PLATFORMS_LIST =~ D7S ]] || [[ $_PLATFORMS_LIST =~ D7P ]] ; then
if [ ! -d "$_ROOT/distro/$_THIS_CORE/$_DRUPAL7P" ] ; then
echo " "
if prompt_yes_no "$_F_DRUPAL7 - https://drupal.org/drupal-7.28" ; then
true

###---### Drupal 7 Development
#
_REAL_PRNAME="standard"
_SHRD_PLNAME="$_DRUPAL7D"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ D7D ]] ; then
  msg "DISTRO: $_F_DRUPAL7_D installation in progress..."
  create_drupal7_basic
  msg "DISTRO: $_F_DRUPAL7_D installation completed"
  echo " "
fi

###---### Drupal 7 Staging
#
_REAL_PRNAME="standard"
_SHRD_PLNAME="$_DRUPAL7S"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ D7S ]] ; then
  msg "DISTRO: $_F_DRUPAL7_S installation in progress..."
  create_drupal7_basic
  msg "DISTRO: $_F_DRUPAL7_S installation completed"
  echo " "
fi

###---### Drupal 7 Production
#
_REAL_PRNAME="standard"
_SHRD_PLNAME="$_DRUPAL7P"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ D7P ]] ; then
  msg "DISTRO: $_F_DRUPAL7_P installation in progress..."
  create_drupal7_basic
  msg "DISTRO: $_F_DRUPAL7_P installation completed"
fi

else
  msg "DISTRO: $_F_DRUPAL7 installation skipped"
fi
fi
fi
}


drupal8_install () {
###---### Drupal 8
#
_REAL_PRNAME="standard"
_SHRD_PLNAME="drupal-$_SMALLCORE8"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_D_8_ALLOW" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ D8D ]] ; then
if [ ! -d "$_OCTO_PLPATH" ] ; then
echo " "
if prompt_yes_no "$_F_DRUPAL8 - http://drupal.org" ; then
true
msg "DISTRO: $_F_DRUPAL8 installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  cd $_CORE
  if [ ! -e "$_D8_CORE_DIR" ] ; then
    prepare_drupal8_core
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_DRUPAL8 installation completed"
else
  msg "DISTRO: $_F_DRUPAL8 installation skipped"
fi
fi
fi
fi
}


drupal_edge_8_install () {
###---### Drupal Edge 8
#
#_DRUPAL_EDGE_8="8.0-dev-$_TODAY"
#
_REAL_PRNAME="standard"
_SHRD_PLNAME="drupal-$_DRUPAL_EDGE_8"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_D_8_ALLOW" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ D8E ]] ; then
if [ ! -d "$_OCTO_PLPATH" ] ; then
echo " "
if prompt_yes_no "$_F_DRUPAL_EDGE_8 - http://drupal.org" ; then
true
msg "DISTRO: $_F_DRUPAL_EDGE_8 installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  cd $_CORE
  get_dev_contrib "drupal-8.x-dev.tar.gz"
  tar -xzf drupal-8.x-dev.tar.gz
  rm -f drupal-8.x-dev.tar.gz
  mv drupal-8.x-dev $_SHRD_PLNAME
  rm -f -r $_SHRD_PLPATH/.git
  rm -f $_SHRD_PLPATH/*.txt
  rm -f $_SHRD_PLPATH/core/*.txt
  cd $_SHRD_PLPATH
fi
init_this_distro_root
msg "DISTRO: $_F_DRUPAL_EDGE_8 installation completed"
else
  msg "DISTRO: $_F_DRUPAL_EDGE_8 installation skipped"
fi
fi
fi
fi
}


erpal_install () {
###---### ERPAL
#
_REAL_PRNAME="erpal"
_SHRD_PLNAME="$_REAL_PRNAME-$_ERPAL-$_SMALLCORE7"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_ALLOW_ALL" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ ERP ]] ; then
if [ ! -d "$_OCTO_PLPATH" ] ; then
echo " "
if prompt_yes_no "$_F_ERPAL - https://drupal.org/project/erpal" ; then
true
msg "DISTRO: $_F_ERPAL installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  cd $_CORE
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D7_CORE_DIR" ] ; then
      prepare_drupal7_core
    fi
    curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "http://ftp.drupal.org/files/projects/$_REAL_PRNAME-$_ERPAL-core.tar.gz" | tar -xzf -
    if [ -d "$_CORE/$_REAL_PRNAME-$_ERPAL" ] ; then
      mv $_REAL_PRNAME-$_ERPAL $_SHRD_PLNAME
    fi
    nocore_d7_dist_clean
    remove_default_core_seven_profiles
    rm -f -r $_SHRD_PRPATH/modules/contrib/entitycache
    if [ $_ERPAL = "7.x-2.0-beta2" ] ; then
      cd $_SHRD_PRPATH/modules/contrib
      rm -f -r {views}
      get_dev_contrib "views-7.x-3.8.tar.gz"
      cd $_SHRD_PRPATH/modules/contrib/views
      # https://drupal.org/node/1766338#comment-6445882
      patch -p1 < /opt/tmp/$_BOA_REPO_NAME/aegir/patches/views-revert-broken-filter-or-groups-1766338-7.patch &> /dev/null
      # https://drupal.org/node/2037469
      patch -p1 < /opt/tmp/$_BOA_REPO_NAME/aegir/patches/views-exposed-sorts-2037469-1.patch &> /dev/null
      # upgrade_contrib_less
    fi
  else
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_ERPAL installation completed"
else
  msg "DISTRO: $_F_ERPAL installation skipped"
fi
fi
fi
fi
}


fserver_install () {
###---### Feature Server Make
#
_REAL_PRNAME="feature_server"
_SHRD_PLNAME="fserver-$_SMALLCORE6"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ FSR ]] ; then
if [ ! -d "$_OCTO_PLPATH/modules/path_alias_cache" ] ; then
echo " "
if prompt_yes_no "$_F_FSERVER - http://bit.ly/fservermore" ; then
true
msg "DISTRO: $_F_FSERVER installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D6_CORE_DIR" ] ; then
      prepare_drupal6_core
    fi
    cd $_CORE
    echo "api = 2" > fserver.make
    echo "core = 6.x" >> fserver.make
    echo "projects[pressflow][type] = \"core\"" >> fserver.make
    echo "projects[pressflow][download][type] = \"get\"" >> fserver.make
    echo "projects[pressflow][download][url] = \"http://files.aegir.cc/core/pressflow-6.31.2.tar.gz\"" >> fserver.make
    echo "projects[$_REAL_PRNAME][type] = \"profile\"" >> fserver.make
    echo "projects[$_REAL_PRNAME][download][type] = \"git\"" >> fserver.make
    echo "projects[$_REAL_PRNAME][download][url] = \"git://github.com/omega8cc/$_REAL_PRNAME.git\"" >> fserver.make
    $_DRUSHCMD make fserver.make $_SHRD_PLNAME &> /dev/null
    nocore_d6_dist_clean
    rm -f fserver.make
    rm -f -r $_SHRD_PLPATH/profiles/default
    cd $_SHRD_PLPATH/profiles/$_REAL_PRNAME/themes
    patch -p0 < /opt/tmp/$_BOA_REPO_NAME/aegir/patches/singular.patch &> /dev/null
    patch -p0 < /opt/tmp/$_BOA_REPO_NAME/aegir/patches/singular.mft.patch &> /dev/null
  else
    cd $_CORE
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_FSERVER installation completed"
else
  msg "DISTRO: $_F_FSERVER installation skipped"
fi
fi
fi
}


guardr_install () {
###---### Guardr
#
_REAL_PRNAME="guardr"
_SHRD_PLNAME="$_REAL_PRNAME-$_GUARDR-$_SMALLCORE7"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_ALLOW_ALL" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ GDR ]] ; then
if [ ! -d "$_OCTO_PLPATH" ] ; then
echo " "
if prompt_yes_no "$_F_GUARDR - https://drupal.org/project/guardr" ; then
true
msg "DISTRO: $_F_GUARDR installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  cd $_CORE
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D7_CORE_DIR" ] ; then
      prepare_drupal7_core
    fi
    curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "http://ftp.drupal.org/files/projects/$_REAL_PRNAME-$_GUARDR-core.tar.gz" | tar -xzf -
    if [ -d "$_CORE/$_REAL_PRNAME-$_GUARDR" ] ; then
      mv $_REAL_PRNAME-$_GUARDR $_SHRD_PLNAME
    fi
    nocore_d7_dist_clean
    remove_default_core_seven_profiles
    if [ $_GUARDR = "7.x-1.0-rc3" ] ; then
      cd $_SHRD_PRPATH/modules/contrib
      rm -f -r {ds}
      get_dev_contrib "ds-7.x-1.9.tar.gz"
      upgrade_contrib_less
    fi
  else
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_GUARDR installation completed"
else
  msg "DISTRO: $_F_GUARDR installation skipped"
fi
fi
fi
fi
}


managingnews_install () {
###---### ManagingNews
#
_REAL_PRNAME="managingnews"
_SHRD_PLNAME="$_REAL_PRNAME-$_MANAGINGNEWS-$_SMALLCORE6"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ MNS ]] ; then
if [ ! -d "$_OCTO_PLPATH/modules/path_alias_cache" ] ; then
echo " "
if prompt_yes_no "$_F_MANAGINGNEWS - http://managingnews.com" ; then
true
msg "DISTRO: $_F_MANAGINGNEWS installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D6_CORE_DIR" ] ; then
      prepare_drupal6_core
    fi
    cd $_CORE
    _MANAGINGNEWS_DL=1.2
    if [ -d "$_CORE/$_REAL_PRNAME-$_MANAGINGNEWS_DL" ] ; then
      mv $_CORE/$_REAL_PRNAME-$_MANAGINGNEWS_DL $_CORE/$_REAL_PRNAME-$_MANAGINGNEWS_DL-old
    fi
    get_distro_ext "$_REAL_PRNAME-$_MANAGINGNEWS_DL.tar.gz"
    mv $_REAL_PRNAME-$_MANAGINGNEWS_DL $_SHRD_PLNAME
    if [ -d "$_CORE/$_REAL_PRNAME-$_MANAGINGNEWS_DL-old" ] ; then
      mv $_CORE/$_REAL_PRNAME-$_MANAGINGNEWS_DL-old $_CORE/$_REAL_PRNAME-$_MANAGINGNEWS_DL
    fi
    rm -f -r $_SHRD_PRPATH/modules/contrib/{boxes,context,ctools,data,features,feeds,imageapi,imagecache,jquery_ui,libraries,mapbox,openlayers,spaces,strongarm,views_rss,views}
    cd $_SHRD_PRPATH/modules/contrib/
    get_dev_contrib "boxes-6.x-1.1.tar.gz"
    get_dev_contrib "context-6.x-3.3.tar.gz"
    get_dev_contrib "ctools-6.x-1.11.tar.gz"
    get_dev_contrib "data-6.x-1.1.tar.gz"
    get_dev_contrib "features-6.x-1.2.tar.gz"
    get_dev_contrib "feeds-6.x-1.0-beta13.tar.gz"
    get_dev_contrib "imageapi-6.x-1.10.tar.gz"
    get_dev_contrib "imagecache-6.x-2.x-dev.tar.gz"
    get_dev_contrib "jquery_ui-6.x-1.5.tar.gz"
    get_dev_contrib "libraries-6.x-1.0.tar.gz"
    get_dev_contrib "mapbox-6.x-2.0-alpha1.tar.gz"
    get_dev_contrib "openlayers-6.x-2.0-beta3.tar.gz"
    get_dev_contrib "spaces-6.x-3.7.tar.gz"
    get_dev_contrib "strongarm-6.x-2.2.tar.gz"
    get_dev_contrib "views_rss-6.x-2.0-rc3.tar.gz"
    get_dev_contrib "views-6.x-2.13.tar.gz"
    cd views
    # https://drupal.org/node/853864#comment-3898996
    patch -p0 < /opt/tmp/$_BOA_REPO_NAME/aegir/patches/views-853864_2.patch &> /dev/null
    # https://drupal.org/node/402944#comment-5370400
    patch -p1 < /opt/tmp/$_BOA_REPO_NAME/aegir/patches/views-unpack_options-cache-6.2-51.patch &> /dev/null
    cd ../imagecache
    # https://drupal.org/node/1243258#comment-4850634
    patch -p1 < /opt/tmp/$_BOA_REPO_NAME/aegir/patches/imagecache-1243258-5.patch &> /dev/null
    rm -f -r $_SHRD_PRPATH/themes/{rubik,tao}
    cd $_SHRD_PRPATH/themes
    get_dev_contrib "rubik-6.x-3.0-beta5.tar.gz"
    get_dev_contrib "tao-6.x-3.3.tar.gz"
    nocore_d6_dist_clean
    enable_drupal6_admin
    rm -f -r $_SHRD_PLPATH/profiles/default
  else
    cd $_CORE
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_MANAGINGNEWS installation completed"
else
  msg "DISTRO: $_F_MANAGINGNEWS installation skipped"
fi
fi
fi
}


nodestream7_install () {
###---### NodeStream7 Make
#
_REAL_PRNAME="nodestream"
_SHRD_PLNAME="$_REAL_PRNAME-$_NODESTREAM7-$_SMALLCORE7"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_ALLOW_ALL" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ NS7 ]] ; then
if [ ! -d "$_OCTO_PLPATH" ] ; then
echo " "
if prompt_yes_no "$_F_NODESTREAM7 - http://nodestream.org" ; then
true
msg "DISTRO: $_F_NODESTREAM7 installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  cd $_CORE
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D7_CORE_DIR" ] ; then
      prepare_drupal7_core
    fi
    curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "http://ftp.drupal.org/files/projects/$_REAL_PRNAME-$_NODESTREAM7-core.tar.gz" | tar -xzf -
    if [ -d "$_CORE/$_REAL_PRNAME-$_NODESTREAM7" ] ; then
      mv $_REAL_PRNAME-$_NODESTREAM7 $_SHRD_PLNAME
    fi
    nocore_d7_dist_clean
    remove_default_core_seven_profiles
    rm -f -r $_SHRD_PRPATH/modules/contrib/speedy
    if [ $_NODESTREAM7 = "7.x-2.0-rc5" ] ; then
      cd $_SHRD_PRPATH/modules/contrib
      upgrade_contrib_less
    fi
  else
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_NODESTREAM7 installation completed"
else
  msg "DISTRO: $_F_NODESTREAM7 installation skipped"
fi
fi
fi
fi
}


openacademy_install () {
###---### Open Academy
#
_REAL_PRNAME="openacademy"
_SHRD_PLNAME="$_REAL_PRNAME-$_OPENACADEMY-$_SMALLCORE7"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_ALLOW_ALL" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ OAY ]] ; then
if [ ! -d "$_OCTO_PLPATH" ] ; then
echo " "
if prompt_yes_no "$_F_OPENACADEMY - https://drupal.org/project/openacademy" ; then
true
msg "DISTRO: $_F_OPENACADEMY installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  cd $_CORE
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D7_CORE_DIR" ] ; then
      prepare_drupal7_core
    fi
    curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "http://ftp.drupal.org/files/projects/$_REAL_PRNAME-$_OPENACADEMY-core.tar.gz" | tar -xzf -
    if [ -d "$_CORE/$_REAL_PRNAME-$_OPENACADEMY" ] ; then
      mv $_REAL_PRNAME-$_OPENACADEMY $_SHRD_PLNAME
    fi
    nocore_d7_dist_clean
    remove_default_core_seven_profiles
    if [ $_OPENACADEMY = "7.x-1.0" ] ; then
      cd $_SHRD_PRPATH/modules/contrib
      rm -f -r {image_resize_filter}
      get_dev_contrib "image_resize_filter-7.x-1.14.tar.gz"
      upgrade_contrib_less
    fi
  else
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_OPENACADEMY installation completed"
else
  msg "DISTRO: $_F_OPENACADEMY installation skipped"
fi
fi
fi
fi
}


openatrium6_install () {
###---### Open Atrium D6
#
_REAL_PRNAME="openatrium"
_SHRD_PLNAME="$_REAL_PRNAME-$_OPENATRIUM6-$_SMALLCORE6"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ OAM ]] ; then
if [ ! -d "$_OCTO_PLPATH/modules/path_alias_cache" ] ; then
echo " "
if prompt_yes_no "$_F_OPENATRIUM6 - http://openatrium.com" ; then
true
msg "DISTRO: $_F_OPENATRIUM6 installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D6_CORE_DIR" ] ; then
      prepare_drupal6_core
    fi
    cd $_CORE
    curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "http://ftp.drupal.org/files/projects/$_REAL_PRNAME-$_OPENATRIUM6-core.tar.gz" | tar -xzf -
    if [ -d "$_CORE/$_REAL_PRNAME-$_OPENATRIUM6" ] ; then
      mv $_REAL_PRNAME-$_OPENATRIUM6 $_SHRD_PLNAME
    fi
    cd $_SHRD_PRPATH/modules/contrib/imagecache
    # https://drupal.org/node/1243258#comment-4850634
    patch -p1 < /opt/tmp/$_BOA_REPO_NAME/aegir/patches/imagecache-1243258-5.patch &> /dev/null
    nocore_d6_dist_clean
    rm -f -r $_SHRD_PLPATH/profiles/default
    cd $_SHRD_PRPATH/modules/atrium_features/
    git clone git://github.com/nuvoleweb/atrium_folders.git &> /dev/null
    rm -f -r atrium_folders/.git
    cd $_SHRD_PRPATH/modules/atrium_features/
    get_dev_contrib "ideation-6.x-1.0-rc1.tar.gz"
    cd $_SHRD_PRPATH/modules/contrib/
    get_dev_contrib "better_exposed_filters-6.x-1.0.tar.gz"
    get_dev_contrib "data-6.x-1.1.tar.gz"
    get_dev_contrib "fivestar-6.x-1.20.tar.gz"
    get_dev_contrib "votingapi-6.x-2.3.tar.gz"
    rm -f -r {context,ctools,l10n_client,markdown,spaces}
    get_dev_contrib "context-6.x-3.3.tar.gz"
    get_dev_contrib "ctools-6.x-1.11.tar.gz"
    get_dev_contrib "l10n_client-6.x-2.2.tar.gz"
    get_dev_contrib "markdown-6.x-1.4.tar.gz"
    get_dev_contrib "spaces-6.x-3.7.tar.gz"
    cd $_SHRD_PRPATH/themes/
    rm -f -r {rubik}
    get_dev_contrib "rubik-6.x-3.0-beta5.tar.gz"
    cd $_CORE
  else
    cd $_CORE
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_OPENATRIUM6 installation completed"
else
  msg "DISTRO: $_F_OPENATRIUM6 installation skipped"
fi
fi
fi
}


openatrium7_install () {
###---### Open Atrium D7
#
_REAL_PRNAME="openatrium"
_SHRD_PLNAME="$_REAL_PRNAME-$_OPENATRIUM7-$_SMALLCORE7"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_ALLOW_ALL" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ OA7 ]] ; then
if [ ! -d "$_OCTO_PLPATH" ] ; then
echo " "
if prompt_yes_no "$_F_OPENATRIUM7 - http://openatrium.com" ; then
true
msg "DISTRO: $_F_OPENATRIUM7 installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  cd $_CORE
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D7_CORE_DIR" ] ; then
      prepare_drupal7_core
    fi
    curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "http://ftp.drupal.org/files/projects/$_REAL_PRNAME-$_OPENATRIUM7-core.tar.gz" | tar -xzf -
    if [ -d "$_CORE/$_REAL_PRNAME-$_OPENATRIUM7" ] ; then
      mv $_REAL_PRNAME-$_OPENATRIUM7 $_SHRD_PLNAME
    fi
    nocore_d7_dist_clean
    remove_default_core_seven_profiles
    if [ $_OPENATRIUM7 = "7.x-2.19" ] ; then
      cd $_SHRD_PRPATH/modules/contrib
      upgrade_contrib_less
    fi
  else
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_OPENATRIUM7 installation completed"
else
  msg "DISTRO: $_F_OPENATRIUM7 installation skipped"
fi
fi
fi
fi
}


openblog_install () {
###---### OpenBlog
#
_REAL_PRNAME="openblog"
_SHRD_PLNAME="$_REAL_PRNAME-$_OPENBLOG-$_SMALLCORE7"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_ALLOW_ALL" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ OBG ]] ; then
if [ ! -d "$_OCTO_PLPATH" ] ; then
echo " "
if prompt_yes_no "$_F_OPENBLOG - https://drupal.org/project/openblog" ; then
true
msg "DISTRO: $_F_OPENBLOG installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  cd $_CORE
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D7_CORE_DIR" ] ; then
      prepare_drupal7_core
    fi
    curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "http://ftp.drupal.org/files/projects/$_REAL_PRNAME-$_OPENBLOG-core.tar.gz" | tar -xzf -
    if [ -d "$_CORE/$_REAL_PRNAME-$_OPENBLOG" ] ; then
      mv $_REAL_PRNAME-$_OPENBLOG $_SHRD_PLNAME
    fi
    nocore_d7_dist_clean
    remove_default_core_seven_profiles
    if [ $_OPENBLOG = "7.x-1.0-alpha2" ] ; then
      cd $_SHRD_PRPATH/themes/contrib
      rm -f -r {subtle_simplicity}
      get_dev_contrib "subtle_simplicity-7.x-2.x-dev.tar.gz"
      cd $_SHRD_PRPATH/modules/contrib
      rm -f -r {entitycache,filefield_sources,google_analytics,honeypot,markdown,metatag,r4032login}
      get_dev_contrib "filefield_sources-7.x-1.9.tar.gz"
      get_dev_contrib "google_analytics-7.x-1.4.tar.gz"
      get_dev_contrib "honeypot-7.x-1.16.tar.gz"
      get_dev_contrib "markdown-7.x-1.2.tar.gz"
      get_dev_contrib "metatag-7.x-1.0-beta9.tar.gz"
      get_dev_contrib "r4032login-7.x-1.7.tar.gz"
      upgrade_contrib_less
    fi
  else
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_OPENBLOG installation completed"
else
  msg "DISTRO: $_F_OPENBLOG installation skipped"
fi
fi
fi
fi
}


openchurch_install () {
###---### Open Church
#
_REAL_PRNAME="openchurch"
_SHRD_PLNAME="$_REAL_PRNAME-$_OPENCHURCH-$_SMALLCORE7"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_ALLOW_ALL" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ OCH ]] ; then
if [ ! -d "$_OCTO_PLPATH" ] ; then
echo " "
if prompt_yes_no "$_F_OPENCHURCH - http://openchurchsite.com" ; then
true
msg "DISTRO: $_F_OPENCHURCH installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  cd $_CORE
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D7_CORE_DIR" ] ; then
      prepare_drupal7_core
    fi
    curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "http://ftp.drupal.org/files/projects/$_REAL_PRNAME-$_OPENCHURCH-core.tar.gz" | tar -xzf -
    if [ -d "$_CORE/$_REAL_PRNAME-$_OPENCHURCH" ] ; then
      mv $_REAL_PRNAME-$_OPENCHURCH $_SHRD_PLNAME
    fi
    nocore_d7_dist_clean
    remove_default_core_seven_profiles
    rm -f -r $_SHRD_PRPATH/libraries/plupload/examples
    if [ $_OPENCHURCH = "7.x-1.11" ] ; then
      cd $_SHRD_PRPATH/modules/contrib
      rm -f -r {metatag,panels,recaptcha,views_php,webform}
      get_dev_contrib "metatag-7.x-1.0-beta9.tar.gz"
      get_dev_contrib "panels-7.x-3.4.tar.gz"
      get_dev_contrib "recaptcha-7.x-1.11.tar.gz"
      get_dev_contrib "views_php-7.x-1.0-alpha1.tar.gz"
      get_dev_contrib "webform-7.x-3.20.tar.gz"
      upgrade_contrib_less
    fi
  else
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_OPENCHURCH installation completed"
else
  msg "DISTRO: $_F_OPENCHURCH installation skipped"
fi
fi
fi
fi
}


opendeals_install () {
###---### Open Deals
#
_REAL_PRNAME="opendeals"
_SHRD_PLNAME="$_REAL_PRNAME-$_OPEN_DEALS-$_SMALLCORE7"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_ALLOW_ALL" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ ODS ]] ; then
if [ ! -d "$_OCTO_PLPATH" ] ; then
echo " "
if prompt_yes_no "$_F_OPENDEALS - http://opendealsapp.com" ; then
true
msg "DISTRO: $_F_OPENDEALS installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  cd $_CORE
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D7_CORE_DIR" ] ; then
      prepare_drupal7_core
    fi
    curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "http://ftp.drupal.org/files/projects/$_REAL_PRNAME-$_OPENDEALS-core.tar.gz" | tar -xzf -
    if [ -d "$_CORE/$_REAL_PRNAME-$_OPENDEALS" ] ; then
      mv $_REAL_PRNAME-$_OPENDEALS $_SHRD_PLNAME
    fi
    nocore_d7_dist_clean
    remove_default_core_seven_profiles
    if [ $_OPENDEALS = "7.x-1.32" ] ; then
      cd $_SHRD_PRPATH/modules
      rm -f -r {diff,xmlsitemap}
      get_dev_contrib "diff-7.x-3.2.tar.gz"
      get_dev_contrib "xmlsitemap-7.x-2.0.tar.gz"
      upgrade_contrib_less
    fi
  else
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_OPENDEALS installation completed"
else
  msg "DISTRO: $_F_OPENDEALS installation skipped"
fi
fi
fi
fi
}


openoutreach_install () {
###---### Open Outreach
#
_REAL_PRNAME="openoutreach"
_SHRD_PLNAME="$_REAL_PRNAME-$_OPENOUTREACH-$_SMALLCORE7"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_ALLOW_ALL" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ OOH ]] ; then
if [ ! -d "$_OCTO_PLPATH" ] ; then
echo " "
if prompt_yes_no "$_F_OPENOUTREACH - http://openoutreach.org" ; then
true
msg "DISTRO: $_F_OPENOUTREACH installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  cd $_CORE
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D7_CORE_DIR" ] ; then
      prepare_drupal7_core
    fi
    curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "http://ftp.drupal.org/files/projects/$_REAL_PRNAME-$_OPENOUTREACH-core.tar.gz" | tar -xzf -
    if [ -d "$_CORE/$_REAL_PRNAME-$_OPENOUTREACH" ] ; then
      mv $_REAL_PRNAME-$_OPENOUTREACH $_SHRD_PLNAME
    fi
    nocore_d7_dist_clean
    remove_default_core_seven_profiles
    if [ $_OPENOUTREACH = "7.x-1.0-rc10" ] ; then
      cd $_SHRD_PRPATH/modules/contrib
      rm -f -r {comment_notify,libraries}
      get_dev_contrib "comment_notify-7.x-1.2.tar.gz"
      get_dev_contrib "libraries-7.x-2.x-dev.tar.gz"
      upgrade_contrib_less
    fi
  else
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_OPENOUTREACH installation completed"
else
  msg "DISTRO: $_F_OPENOUTREACH installation skipped"
fi
fi
fi
fi
}


openpublish_install () {
###---### OpenPublish
#
_REAL_PRNAME="openpublish"
_SHRD_PLNAME="$_REAL_PRNAME-$_OPENPUBLISH-$_SMALLCORE7"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_ALLOW_ALL" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ OPH ]] ; then
if [ ! -d "$_OCTO_PLPATH" ] ; then
echo " "
if prompt_yes_no "$_F_OPENPUBLISH - http://openpublishapp.com" ; then
true
msg "DISTRO: $_F_OPENPUBLISH installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  cd $_CORE
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D7_CORE_DIR" ] ; then
      prepare_drupal7_core
    fi
    curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "http://ftp.drupal.org/files/projects/$_REAL_PRNAME-$_OPENPUBLISH-core.tar.gz" | tar -xzf -
    if [ -d "$_CORE/$_REAL_PRNAME-$_OPENPUBLISH" ] ; then
      mv $_REAL_PRNAME-$_OPENPUBLISH $_SHRD_PLNAME
    fi
    nocore_d7_dist_clean
    remove_default_core_seven_profiles
    if [ $_OPENPUBLISH = "7.x-1.0-beta7" ] ; then
      cd $_SHRD_PRPATH/modules/contrib
      rm -f -r $_SHRD_PRPATH/modules/contrib/{boxes,context,diff,entity_autocomplete,features_override,filefield_sources,google_analytics,imce,link,plupload,recaptcha,references,token,xmlsitemap}
      cd $_SHRD_PRPATH/modules/contrib
      get_dev_contrib "boxes-7.x-1.1.tar.gz"
      get_dev_contrib "context-7.x-3.2.tar.gz"
      get_dev_contrib "diff-7.x-3.2.tar.gz"
      get_dev_contrib "entity_autocomplete-7.x-1.0-beta3.tar.gz"
      get_dev_contrib "features_override-7.x-2.0-beta2.tar.gz"
      get_dev_contrib "filefield_sources-7.x-1.7.tar.gz"
      get_dev_contrib "google_analytics-7.x-1.4.tar.gz"
      get_dev_contrib "imce-7.x-1.7.tar.gz"
      get_dev_contrib "link-7.x-1.1.tar.gz"
      get_dev_contrib "plupload-7.x-1.6.tar.gz"
      get_dev_contrib "recaptcha-7.x-1.9.tar.gz"
      get_dev_contrib "references-7.x-2.1.tar.gz"
      get_dev_contrib "token-7.x-1.5.tar.gz"
      get_dev_contrib "xmlsitemap-7.x-2.0-rc2.tar.gz"
      upgrade_contrib_less
    fi
  else
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_OPENPUBLISH installation completed"
else
  msg "DISTRO: $_F_OPENPUBLISH installation skipped"
fi
fi
fi
fi
}


openscholar_install () {
###---### OpenScholar
#
_REAL_PRNAME="openscholar"
_SHRD_PLNAME="$_REAL_PRNAME-$_OPENSCHOLAR-$_SMALLCORE7"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_ALLOW_ALL" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ OSR ]] ; then
if [ ! -d "$_OCTO_PLPATH" ] ; then
echo " "
if prompt_yes_no "$_F_OPENSCHOLAR - http://theopenscholar.org" ; then
true
msg "DISTRO: $_F_OPENSCHOLAR installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  cd $_CORE
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D7_CORE_DIR" ] ; then
      prepare_drupal7_core
    fi
    get_distro_ext "$_REAL_PRNAME-$_OPENSCHOLAR.tar.gz"
    if [ -d "$_CORE/$_REAL_PRNAME-$_OPENSCHOLAR" ] ; then
      mv $_REAL_PRNAME-$_OPENSCHOLAR $_SHRD_PLNAME
    fi
    nocore_d7_dist_clean
    remove_default_core_seven_profiles
    rm -f -r $_SHRD_PRPATH/modules/contrib/{entitycache,expire}
    if [ $_OPENSCHOLAR = "7.x-3.12.1" ] ; then
      cd $_SHRD_PRPATH/modules/contrib
      rm -f -r {biblio,boxes,entityreference_prepopulate,restws}
      get_dev_contrib "biblio-7.x-1.0-rc7.tar.gz"
      get_dev_contrib "boxes-7.x-1.1.tar.gz"
      get_dev_contrib "entityreference_prepopulate-7.x-1.5.tar.gz"
      get_dev_contrib "restws-7.x-2.1.tar.gz"
      upgrade_contrib_less
    fi
  else
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_OPENSCHOLAR installation completed"
else
  msg "DISTRO: $_F_OPENSCHOLAR installation skipped"
fi
fi
fi
fi
}


panopoly_install () {
###---### Panopoly
#
_REAL_PRNAME="panopoly"
_SHRD_PLNAME="$_REAL_PRNAME-$_PANOPOLY-$_SMALLCORE7"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_ALLOW_ALL" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ PPY ]] ; then
if [ ! -d "$_OCTO_PLPATH" ] ; then
echo " "
if prompt_yes_no "$_F_PANOPOLY - https://drupal.org/project/panopoly" ; then
true
msg "DISTRO: $_F_PANOPOLY installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  cd $_CORE
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D7_CORE_DIR" ] ; then
      prepare_drupal7_core
    fi
    curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "http://ftp.drupal.org/files/projects/$_REAL_PRNAME-$_PANOPOLY-core.tar.gz" | tar -xzf -
    if [ -d "$_CORE/$_REAL_PRNAME-$_PANOPOLY" ] ; then
      mv $_REAL_PRNAME-$_PANOPOLY $_SHRD_PLNAME
    fi
    nocore_d7_dist_clean
    remove_default_core_seven_profiles
    if [ $_PANOPOLY = "7.x-1.4" ] ; then
      cd $_SHRD_PRPATH/modules/contrib
      rm -f -r {fape}
      get_dev_contrib "fape-7.x-1.2.tar.gz"
    fi
    if [ ! -d "$_SHRD_PRPATH/modules/panopoly/panopoly_demo" ] ; then
      if [ -d "$_SHRD_PLPATH/sites/all/modules/panopoly_demo" ] ; then
        mv -f $_SHRD_PLPATH/sites/all/modules/panopoly_demo $_SHRD_PRPATH/modules/panopoly/ &> /dev/null
      else
        cd $_SHRD_PRPATH/modules/panopoly
        get_dev_contrib "panopoly_demo-7.x-1.6.tar.gz"
      fi
    fi
  else
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_PANOPOLY installation completed"
else
  msg "DISTRO: $_F_PANOPOLY installation skipped"
fi
fi
fi
fi
}


prosepoint_install () {
###---### Prosepoint
#
_REAL_PRNAME="prosepoint"
_SHRD_PLNAME="$_REAL_PRNAME-$_PROSEPOINT-$_SMALLCORE6"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_CLIENT_CORES" -ge "1" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ PPT ]] ; then
if [ ! -d "$_OCTO_PLPATH/modules/path_alias_cache" ] ; then
echo " "
if prompt_yes_no "$_F_PROSEPOINT - http://prosepoint.org" ; then
true
msg "DISTRO: $_F_PROSEPOINT installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D6_CORE_DIR" ] ; then
      prepare_drupal6_core
    fi
    cd $_CORE
    if [ -d "$_CORE/$_REAL_PRNAME-$_PROSEPOINT" ] ; then
      mv $_CORE/$_REAL_PRNAME-$_PROSEPOINT $_CORE/$_REAL_PRNAME-$_PROSEPOINT-old
    fi
    get_distro_ext "$_REAL_PRNAME-$_PROSEPOINT.tar.gz"
    mv $_CORE/$_REAL_PRNAME-$_PROSEPOINT $_SHRD_PLPATH
    if [ -d "$_CORE/$_REAL_PRNAME-$_PROSEPOINT-old" ] ; then
      mv $_CORE/$_REAL_PRNAME-$_PROSEPOINT-old $_CORE/$_REAL_PRNAME-$_PROSEPOINT
    fi
    rm -f -r $_SHRD_PLPATH/profiles/default
    nocore_d6_dist_clean
    sed -i "s/'robotstxt', 'path_alias_cache'/'path_alias_cache'/g" $_SHRD_PRPATH/$_REAL_PRNAME.profile &> /dev/null
  else
    cd $_CORE
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_PROSEPOINT installation completed"
else
  msg "DISTRO: $_F_PROSEPOINT installation skipped"
fi
fi
fi
fi
}


recruiter_install () {
###---### Recruiter
#
_REAL_PRNAME="recruiter"
_SHRD_PLNAME="$_REAL_PRNAME-$_RECRUITER-$_SMALLCORE7"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_ALLOW_ALL" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ RER ]] ; then
if [ ! -d "$_OCTO_PLPATH" ] ; then
echo " "
if prompt_yes_no "$_F_RECRUITER - https://drupal.org/project/recruiter" ; then
true
msg "DISTRO: $_F_RECRUITER installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  cd $_CORE
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D7_CORE_DIR" ] ; then
      prepare_drupal7_core
    fi
    curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "http://ftp.drupal.org/files/projects/$_REAL_PRNAME-$_RECRUITER-core.tar.gz" | tar -xzf -
    if [ -d "$_CORE/$_REAL_PRNAME-$_RECRUITER" ] ; then
      mv $_REAL_PRNAME-$_RECRUITER $_SHRD_PLNAME
    fi
    nocore_d7_dist_clean
    remove_default_core_seven_profiles
    if [ $_RECRUITER = "7.x-1.2" ] ; then
      cd $_SHRD_PRPATH/modules
      rm -f -r {rules}
      get_dev_contrib "rules-7.x-2.7.tar.gz"
      upgrade_contrib_less
    fi
  else
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_RECRUITER installation completed"
else
  msg "DISTRO: $_F_RECRUITER installation skipped"
fi
fi
fi
fi
}


restaurant_install () {
###---### Restaurant
#
_REAL_PRNAME="restaurant"
_SHRD_PLNAME="$_REAL_PRNAME-$_RESTAURANT-$_SMALLCORE7"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_ALLOW_ALL" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ RST ]] ; then
if [ ! -d "$_OCTO_PLPATH" ] ; then
echo " "
if prompt_yes_no "$_F_RESTAURANT - https://drupal.org/project/restaurant" ; then
true
msg "DISTRO: $_F_RESTAURANT installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  cd $_CORE
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D7_CORE_DIR" ] ; then
      prepare_drupal7_core
    fi
    curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "http://ftp.drupal.org/files/projects/$_REAL_PRNAME-$_RESTAURANT-core.tar.gz" | tar -xzf -
    if [ -d "$_CORE/$_REAL_PRNAME-$_RESTAURANT" ] ; then
      mv $_REAL_PRNAME-$_RESTAURANT $_SHRD_PLNAME
    fi
    nocore_d7_dist_clean
    remove_default_core_seven_profiles
    if [ $_RESTAURANT = "7.x-1.0-alpha5" ] ; then
      cd $_SHRD_PRPATH/modules/contrib
      rm -f -r {views}
      get_dev_contrib "views-7.x-3.8.tar.gz"
      cd $_SHRD_PRPATH/modules/contrib/views
      # https://drupal.org/node/1766338#comment-6445882
      patch -p1 < /opt/tmp/$_BOA_REPO_NAME/aegir/patches/views-revert-broken-filter-or-groups-1766338-7.patch &> /dev/null
      # https://drupal.org/node/2037469
      patch -p1 < /opt/tmp/$_BOA_REPO_NAME/aegir/patches/views-exposed-sorts-2037469-1.patch &> /dev/null
      # upgrade_contrib_less
    fi
  else
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_RESTAURANT installation completed"
else
  msg "DISTRO: $_F_RESTAURANT installation skipped"
fi
fi
fi
fi
}


spark_install () {
###---### Spark
#
_REAL_PRNAME="spark"
_SHRD_PLNAME="$_REAL_PRNAME-$_SPARK-$_SMALLCORE7"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_ALLOW_ALL" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ SRK ]] ; then
if [ ! -d "$_OCTO_PLPATH" ] ; then
echo " "
if prompt_yes_no "$_F_SPARK - https://drupal.org/project/spark" ; then
true
msg "DISTRO: $_F_SPARK installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  cd $_CORE
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D7_CORE_DIR" ] ; then
      prepare_drupal7_core
    fi
    curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "http://ftp.drupal.org/files/projects/$_REAL_PRNAME-$_SPARK-core.tar.gz" | tar -xzf -
    if [ -d "$_CORE/$_REAL_PRNAME-$_SPARK" ] ; then
      mv $_REAL_PRNAME-$_SPARK $_SHRD_PLNAME
    fi
    nocore_d7_dist_clean
    remove_default_core_seven_profiles
    if [ $_SPARK = "7.x-1.0-beta1" ] ; then
      cd $_SHRD_PRPATH/themes/contrib
      rm -f -r {ember}
      get_dev_contrib "ember-7.x-2.0-alpha2.tar.gz"
      cd $_SHRD_PRPATH/modules/contrib
      upgrade_contrib_less
    fi
  else
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_SPARK installation completed"
else
  msg "DISTRO: $_F_SPARK installation skipped"
fi
fi
fi
fi
}


totem_install () {
###---### Totem
#
_REAL_PRNAME="totem"
_SHRD_PLNAME="$_REAL_PRNAME-$_TOTEM-$_SMALLCORE7"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_ALLOW_ALL" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ TTM ]] ; then
if [ ! -d "$_OCTO_PLPATH" ] ; then
echo " "
if prompt_yes_no "$_F_TOTEM - https://drupal.org/project/totem" ; then
true
msg "DISTRO: $_F_TOTEM installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  cd $_CORE
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D7_CORE_DIR" ] ; then
      prepare_drupal7_core
    fi
    curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "http://ftp.drupal.org/files/projects/$_REAL_PRNAME-$_TOTEM-core.tar.gz" | tar -xzf -
    if [ -d "$_CORE/$_REAL_PRNAME-$_TOTEM" ] ; then
      mv $_REAL_PRNAME-$_TOTEM $_SHRD_PLNAME
    fi
    nocore_d7_dist_clean
    remove_default_core_seven_profiles
    rm -f -r $_SHRD_PRPATH/libraries/plupload/examples
    if [ $_TOTEM = "7.x-1.1" ] ; then
      cd $_SHRD_PRPATH/modules/contrib
      rm -f -r {filefield_sources,location,media,mimemail,plupload}
      get_dev_contrib "filefield_sources-7.x-1.9.tar.gz"
      get_dev_contrib "location-7.x-3.1.tar.gz"
      get_dev_contrib "media-7.x-1.4.tar.gz"
      get_dev_contrib "mimemail-7.x-1.0-beta3.tar.gz"
      get_dev_contrib "plupload-7.x-1.6.tar.gz"
      upgrade_contrib_less
    fi
  else
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_TOTEM installation completed"
else
  msg "DISTRO: $_F_TOTEM installation skipped"
fi
fi
fi
fi
}


ubercart6_install () {
###---### Ubercart 2
#
_REAL_PRNAME="uberdrupal"
_VIRT_PRNAME="ubercart"
_SHRD_PLNAME="$_VIRT_PRNAME-$_UBERCART6-$_SMALLCORE6"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ UCT ]] ; then
if [ ! -d "$_OCTO_PLPATH/modules/path_alias_cache" ] ; then
echo " "
if prompt_yes_no "$_F_UBERCART6 - http://ubercart.org" ; then
true
msg "DISTRO: $_F_UBERCART6 installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    cd $_CORE
    if [ ! -e "$_D6_CORE_DIR" ] ; then
      prepare_drupal6_core
    fi
    mkdir -p $_SHRD_PLPATH
    nocore_d6_dist_clean
    rm -f -r $_SHRD_PLPATH/profiles/default
    cd $_SHRD_PLPATH/profiles
    get_dev_contrib "uberdrupal.tar.gz"
    cd $_CORE
    mkdir -p $_SHRD_PRPATH/{modules,themes,libraries}
    cd $_SHRD_PRPATH/libraries
    curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "https://codeload.github.com/jackmoore/colorbox/zip/master" -o colorbox-master.zip
    unzip -qq colorbox-master.zip &> /dev/null
    rm -f colorbox-master.zip
    mv -f colorbox-master colorbox
    cd $_SHRD_PRPATH/modules
    get_dev_contrib "admin_menu-6.x-3.x-dev.tar.gz"
    get_dev_contrib "cck-6.x-2.9.tar.gz"
    get_dev_contrib "colorbox-6.x-1.4.tar.gz"
    get_dev_contrib "date-6.x-2.9.tar.gz"
    get_dev_contrib "filefield-6.x-3.12.tar.gz"
    get_dev_contrib "google_analytics-6.x-3.6.tar.gz"
    get_dev_contrib "imageapi-6.x-1.10.tar.gz"
    get_dev_contrib "imagecache-6.x-2.x-dev.tar.gz"
    get_dev_contrib "imagefield-6.x-3.11.tar.gz"
    get_dev_contrib "jquery_update-6.x-2.0-alpha1.tar.gz"
    get_dev_contrib "libraries-6.x-1.0.tar.gz"
    get_dev_contrib "lightbox2-6.x-1.x-dev.tar.gz"
    get_dev_contrib "rules-6.x-1.5.tar.gz"
    get_dev_contrib "skinr-6.x-1.6.tar.gz"
    get_dev_contrib "token-6.x-1.19.tar.gz"
    get_dev_contrib "ubercart-6.x-2.13.tar.gz"
    get_dev_contrib "views-6.x-3.0.tar.gz"
    get_dev_contrib "webform-6.x-3.20.tar.gz"
    ### https://drupal.org/node/1167276#comment-5138248
    cd $_SHRD_PRPATH/modules/$_VIRT_PRNAME
    patch -p1 < /opt/tmp/$_BOA_REPO_NAME/aegir/patches/$_VIRT_PRNAME-1167276-reroll.patch &> /dev/null
    cd $_SHRD_PRPATH/modules/imagecache
    # https://drupal.org/node/1243258#comment-4850634
    patch -p1 < /opt/tmp/$_BOA_REPO_NAME/aegir/patches/imagecache-1243258-5.patch &> /dev/null
    cd $_SHRD_PRPATH/themes
    get_dev_contrib "fusion-6.x-1.x-dev.tar.gz"
    get_dev_contrib "acquia_prosper-6.x-1.1.tar.gz"
  else
    cd $_CORE
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_UBERCART6 installation completed"
else
  msg "DISTRO: $_F_UBERCART6 installation skipped"
fi
fi
fi
}


ubercart7_install () {
###---### Ubercart 3
#
_REAL_PRNAME="minimal"
_VIRT_PRNAME="ubercart"
_SHRD_PLNAME="$_VIRT_PRNAME-$_UBERCART7-$_SMALLCORE7"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_ALLOW_ALL" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ UC7 ]] ; then
if [ ! -d "$_OCTO_PLPATH" ] ; then
echo " "
if prompt_yes_no "$_F_UBERCART7 - http://ubercart.org" ; then
true
msg "DISTRO: $_F_UBERCART7 installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  cd $_CORE
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D7_CORE_DIR" ] ; then
      prepare_drupal7_core
    fi
    mkdir -p $_SHRD_PLPATH
    nocore_d7_dist_clean
    rm -f -r $_SHRD_PLPATH/profiles/standard
    rm -f -r $_SHRD_PLPATH/profiles/testing
    sed -i "s/version = VERSION/version = \"$_SMALLCORE7\"/g" $_SHRD_PLPATH/profiles/minimal/minimal.info &> /dev/null
    mkdir -p $_SHRD_PRPATH/libraries
    cd $_SHRD_PRPATH/libraries
    curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "https://codeload.github.com/jackmoore/colorbox/zip/master" -o colorbox-master.zip
    unzip -qq colorbox-master.zip &> /dev/null
    rm -f colorbox-master.zip
    mv -f colorbox-master colorbox
    mkdir -p $_SHRD_PRPATH/modules
    cd $_SHRD_PRPATH/modules
    get_dev_contrib "colorbox-7.x-2.6.tar.gz"
    get_dev_contrib "ctools-7.x-1.4.tar.gz"
    get_dev_contrib "entity-7.x-1.5.tar.gz"
    get_dev_contrib "google_analytics-7.x-1.4.tar.gz"
    get_dev_contrib "libraries-7.x-2.x-dev.tar.gz"
    get_dev_contrib "pathauto-7.x-1.2.tar.gz"
    get_dev_contrib "rules-7.x-2.7.tar.gz"
    get_dev_contrib "token-7.x-1.5.tar.gz"
    get_dev_contrib "ubercart-7.x-3.6.tar.gz"
    get_dev_contrib "views-7.x-3.8.tar.gz"
    cd $_SHRD_PRPATH/modules/views
    # https://drupal.org/node/1766338#comment-6445882
    patch -p1 < /opt/tmp/$_BOA_REPO_NAME/aegir/patches/views-revert-broken-filter-or-groups-1766338-7.patch &> /dev/null
    # https://drupal.org/node/2037469
    patch -p1 < /opt/tmp/$_BOA_REPO_NAME/aegir/patches/views-exposed-sorts-2037469-1.patch &> /dev/null
  else
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_UBERCART7 installation completed"
else
  msg "DISTRO: $_F_UBERCART7 installation skipped"
fi
fi
fi
fi
}


ubercart7_testing_install () {
###---### Ubercart 3 with testing profile
#
_REAL_PRNAME="testing"
_VIRT_PRNAME="ubercart-$_REAL_PRNAME"
_SHRD_PLNAME="$_VIRT_PRNAME-$_UBERCART7-$_SMALLCORE7"
_SHRD_PLPATH="$_CORE/$_SHRD_PLNAME"
_SHRD_PRPATH="$_SHRD_PLPATH/profiles/$_REAL_PRNAME"
_OCTO_PLPATH="$_ROOT/distro/$_THIS_CORE/$_SHRD_PLNAME"
if [ "$_ALLOW_ALL" = "YES" ] ; then
if [ "$_PLATFORMS_LIST" = "ALL" ] || [[ $_PLATFORMS_LIST =~ UC7 ]] ; then
if [ ! -d "$_OCTO_PLPATH" ] ; then
echo " "
if prompt_yes_no "$_F_UBER_CART_TESTING - http://ubercart.org" ; then
true
msg "DISTRO: $_F_UBER_CART_TESTING installation in progress..."
if [ ! -d "$_SHRD_PLPATH" ] ; then
  cd $_CORE
  if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_T_BUILD" = "HEAD" ] ; then
    if [ ! -e "$_D7_CORE_DIR" ] ; then
      prepare_drupal7_core
    fi
    mkdir -p $_SHRD_PLPATH
    nocore_d7_dist_clean
    rm -f -r $_SHRD_PLPATH/profiles/standard
    rm -f -r $_SHRD_PLPATH/profiles/minimal
    sed -i "s/version = VERSION/version = \"$_SMALLCORE7\"/g" $_SHRD_PLPATH/profiles/testing/testing.info &> /dev/null
    mkdir -p $_SHRD_PRPATH/libraries
    cd $_SHRD_PRPATH/libraries
    curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "https://codeload.github.com/jackmoore/colorbox/zip/master" -o colorbox-master.zip
    unzip -qq colorbox-master.zip &> /dev/null
    rm -f colorbox-master.zip
    mv -f colorbox-master colorbox
    mkdir -p $_SHRD_PRPATH/modules
    cd $_SHRD_PRPATH/modules
    get_dev_contrib "colorbox-7.x-2.6.tar.gz"
    get_dev_contrib "ctools-7.x-1.4.tar.gz"
    get_dev_contrib "entity-7.x-1.5.tar.gz"
    get_dev_contrib "google_analytics-7.x-1.4.tar.gz"
    get_dev_contrib "libraries-7.x-2.x-dev.tar.gz"
    get_dev_contrib "pathauto-7.x-1.2.tar.gz"
    get_dev_contrib "rules-7.x-2.7.tar.gz"
    get_dev_contrib "token-7.x-1.5.tar.gz"
    get_dev_contrib "ubercart-7.x-3.6.tar.gz"
    get_dev_contrib "views-7.x-3.8.tar.gz"
    cd $_SHRD_PRPATH/modules/views
    # https://drupal.org/node/1766338#comment-6445882
    patch -p1 < /opt/tmp/$_BOA_REPO_NAME/aegir/patches/views-revert-broken-filter-or-groups-1766338-7.patch &> /dev/null
    # https://drupal.org/node/2037469
    patch -p1 < /opt/tmp/$_BOA_REPO_NAME/aegir/patches/views-exposed-sorts-2037469-1.patch &> /dev/null
  else
    get_distro_ext "$_SHRD_PLNAME.tar.gz"
  fi
fi
init_this_distro_root
msg "DISTRO: $_F_UBER_CART_TESTING installation completed"
else
  msg "DISTRO: $_F_UBER_CART_TESTING installation skipped"
fi
fi
fi
fi
}

drupal6_install
drupal7_install

agov_install
commerce_7_1_install
commerce_7_2_install
commons_6_install
commons_7_install
erpal_install
fserver_install
guardr_install
managingnews_install
openacademy_install
openatrium6_install
openatrium7_install
openblog_install
openchurch_install
opendeals_install
openoutreach_install
openscholar_install
panopoly_install
recruiter_install
restaurant_install
spark_install
totem_install
ubercart6_install
ubercart7_install
ubercart7_testing_install

if [ "$_ALLOW_UNSUPPORTED" = "YES" ] && [ "$_AEGIR_VERSION" = "HEAD" ] ; then
  acquia_install
  civicrm_m6_install
  civicrm_m7_install
  cod_install
  ### drupal_edge_8_install
  ### drupal8_install
  nodestream7_install
  openpublish_install
  prosepoint_install
fi


###---### Remove some unused core files.
#
echo " "
msg "$_STATUS C: Removing some unused core files..."
rm -f -r $_CORE/*/themes/{bluemarine,chameleon,pushbutton,README.txt}
rm -f -r $_CORE/*/scripts
rm -f $_CORE/*{.make,.tar,.tar.gz,.zip}
cd $_CORE


###---### Save & verify platforms.
#
msg "$_STATUS C: Running Platforms Save & Verify tasks, please wait..."
_LOCAL_STATUS="NOT_SET"
if [ -e "/var/run/aegir_upgrade.pid" ] ; then
  _LOCAL_STATUS=INIT
fi
if [ "$_LOCAL_STATUS" = "INIT" ] ; then
  _THIS_HOSTMASTER="$_HOSTMASTER_ROOT/sites/$_DOMAIN"
  #msg "_THIS_HOSTMASTER is read static $_THIS_HOSTMASTER because _LOCAL_STATUS is $_LOCAL_STATUS"
else
  if [ -e "$_ROOT/.drush/hostmaster.alias.drushrc.php" ] ; then
    _THIS_HOSTMASTER=`cat $_ROOT/.drush/hostmaster.alias.drushrc.php | grep 'site_path' | cut -d: -f2 | awk '{ print $3}'`
    _THIS_HOSTMASTER=`echo $_THIS_HOSTMASTER | sed "s/[\,']//g"`
    #msg "_THIS_HOSTMASTER is $_THIS_HOSTMASTER - read from $_ROOT/.drush/hostmaster.alias.drushrc.php"
  else
    _THIS_HOSTMASTER="$_HOSTMASTER_ROOT/sites/$_DOMAIN"
    #msg "_THIS_HOSTMASTER is read static $_THIS_HOSTMASTER"
  fi
fi
if [ -d "$_THIS_HOSTMASTER" ] ; then
  #msg "_THIS_HOSTMASTER is $_THIS_HOSTMASTER (1)"
  cd $_THIS_HOSTMASTER
else
  _THIS_HOSTMASTER="$_PREV_HOSTMASTER_ROOT/sites/$_DOMAIN"
  #msg "_THIS_HOSTMASTER is $_THIS_HOSTMASTER (2)"
  cd $_THIS_HOSTMASTER
fi
cp -af /opt/tmp/$_BOA_REPO_NAME/aegir/helpers/make_platform.php.txt ./
mv -f make_platform.php.txt make_platform.php &> /dev/null
if [ -d "$_ROOT/distro/$_THIS_CORE/$_DRUPAL7D" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/$_DRUPAL7D/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_DRUPAL7_D" standard $_ROOT/distro/$_THIS_CORE/$_DRUPAL7D &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/$_DRUPAL7S" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/$_DRUPAL7S/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_DRUPAL7_S" standard $_ROOT/distro/$_THIS_CORE/$_DRUPAL7S &> /dev/null
  fi
fi
if [ ! -d "$_ROOT/distro/$_THIS_CORE/$_DRUPAL7" ] ; then
  if [ -d "$_ROOT/distro/$_THIS_CORE/$_DRUPAL7P" ] ; then
    if [ ! -e "$_ROOT/distro/$_THIS_CORE/$_DRUPAL7P/drushrc.php" ] ; then
      $_DRUSHCMD php-script make_platform "$_F_DRUPAL7_P" standard $_ROOT/distro/$_THIS_CORE/$_DRUPAL7P &> /dev/null
    fi
  fi
elif [ ! -d "$_ROOT/distro/$_THIS_CORE/$_DRUPAL7P" ] ; then
  if [ -d "$_ROOT/distro/$_THIS_CORE/$_DRUPAL7" ] ; then
    if [ ! -e "$_ROOT/distro/$_THIS_CORE/$_DRUPAL7/drushrc.php" ] ; then
      $_DRUSHCMD php-script make_platform "$_F_DRUPAL7_P" standard $_ROOT/distro/$_THIS_CORE/$_DRUPAL7 &> /dev/null
    fi
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/acquia-$_SMALLCORE6" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/acquia-$_SMALLCORE6/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_ACQUIA" acquia $_ROOT/distro/$_THIS_CORE/acquia-$_SMALLCORE6 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/agov-$_AGOV-$_SMALLCORE7" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/agov-$_AGOV-$_SMALLCORE7/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_AGOV" agov $_ROOT/distro/$_THIS_CORE/agov-$_AGOV-$_SMALLCORE7 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/civicrm-$_CIVICRM_M6-$_SMALLCORE6" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/civicrm-$_CIVICRM_M6-$_SMALLCORE6/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_CIVICRM_M6" default $_ROOT/distro/$_THIS_CORE/civicrm-$_CIVICRM_M6-$_SMALLCORE6 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/civicrm-$_CIVICRM_M7-$_SMALLCORE7" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/civicrm-$_CIVICRM_M7-$_SMALLCORE7/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_CIVICRM_M7" default $_ROOT/distro/$_THIS_CORE/civicrm-$_CIVICRM_M7-$_SMALLCORE7 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/cod-$_COD-$_SMALLCORE7" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/cod-$_COD-$_SMALLCORE7/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_COD" cod $_ROOT/distro/$_THIS_CORE/cod-$_COD-$_SMALLCORE7 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/commerce-$_COMMERCE1-$_SMALLCORE7" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/commerce-$_COMMERCE1-$_SMALLCORE7/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_COMMERCE1" commerce $_ROOT/distro/$_THIS_CORE/commerce-$_COMMERCE1-$_SMALLCORE7 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/commerce-$_COMMERCE2-$_SMALLCORE7" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/commerce-$_COMMERCE2-$_SMALLCORE7/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_COMMERCE2" commerce $_ROOT/distro/$_THIS_CORE/commerce-$_COMMERCE2-$_SMALLCORE7 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/commons-$_COMMONS2-$_SMALLCORE6" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/commons-$_COMMONS2-$_SMALLCORE6/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_COMMONS2" drupal_commons $_ROOT/distro/$_THIS_CORE/commons-$_COMMONS2-$_SMALLCORE6 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/commons-$_COMMONS3-$_SMALLCORE7" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/commons-$_COMMONS3-$_SMALLCORE7/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_COMMONS3" commons $_ROOT/distro/$_THIS_CORE/commons-$_COMMONS3-$_SMALLCORE7 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/drupal-$_DRUPAL8" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/drupal-$_DRUPAL8/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_DRUPAL8" standard $_ROOT/distro/$_THIS_CORE/drupal-$_DRUPAL8 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/drupal-$_DRUPAL_EDGE_8" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/drupal-$_DRUPAL_EDGE_8/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_DRUPAL_EDGE_8" standard $_ROOT/distro/$_THIS_CORE/drupal-$_DRUPAL_EDGE_8 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/erpal-$_ERPAL-$_SMALLCORE7" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/erpal-$_ERPAL-$_SMALLCORE7/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_ERPAL" erpal $_ROOT/distro/$_THIS_CORE/erpal-$_ERPAL-$_SMALLCORE7 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/fserver-$_SMALLCORE6" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/fserver-$_SMALLCORE6/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_FSERVER" feature_server $_ROOT/distro/$_THIS_CORE/fserver-$_SMALLCORE6 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/guardr-$_GUARDR-$_SMALLCORE7" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/guardr-$_GUARDR-$_SMALLCORE7/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_GUARDR" guardr $_ROOT/distro/$_THIS_CORE/guardr-$_GUARDR-$_SMALLCORE7 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/managingnews-$_MANAGINGNEWS-$_SMALLCORE6" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/managingnews-$_MANAGINGNEWS-$_SMALLCORE6/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_MANAGINGNEWS" managingnews $_ROOT/distro/$_THIS_CORE/managingnews-$_MANAGINGNEWS-$_SMALLCORE6 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/nodestream-$_NODESTREAM7-$_SMALLCORE7" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/nodestream-$_NODESTREAM7-$_SMALLCORE7/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_NODESTREAM7" nodestream $_ROOT/distro/$_THIS_CORE/nodestream-$_NODESTREAM7-$_SMALLCORE7 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/openacademy-$_OPENACADEMY-$_SMALLCORE7" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/openacademy-$_OPENACADEMY-$_SMALLCORE7/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_OPENACADEMY" openacademy $_ROOT/distro/$_THIS_CORE/openacademy-$_OPENACADEMY-$_SMALLCORE7 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/openatrium-$_OPENATRIUM6-$_SMALLCORE6" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/openatrium-$_OPENATRIUM6-$_SMALLCORE6/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_OPENATRIUM6" openatrium $_ROOT/distro/$_THIS_CORE/openatrium-$_OPENATRIUM6-$_SMALLCORE6 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/openatrium-$_OPENATRIUM7-$_SMALLCORE7" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/openatrium-$_OPENATRIUM7-$_SMALLCORE7/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_OPENATRIUM7" openatrium $_ROOT/distro/$_THIS_CORE/openatrium-$_OPENATRIUM7-$_SMALLCORE7 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/openblog-$_OPENBLOG-$_SMALLCORE7" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/openblog-$_OPENBLOG-$_SMALLCORE7/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_OPENBLOG" openblog $_ROOT/distro/$_THIS_CORE/openblog-$_OPENBLOG-$_SMALLCORE7 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/openchurch-$_OPENCHURCH-$_SMALLCORE7" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/openchurch-$_OPENCHURCH-$_SMALLCORE7/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_OPENCHURCH" openchurch $_ROOT/distro/$_THIS_CORE/openchurch-$_OPENCHURCH-$_SMALLCORE7 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/opendeals-$_OPEN_DEALS-$_SMALLCORE7" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/opendeals-$_OPEN_DEALS-$_SMALLCORE7/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_OPENDEALS" opendeals $_ROOT/distro/$_THIS_CORE/opendeals-$_OPEN_DEALS-$_SMALLCORE7 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/openoutreach-$_OPENOUTREACH-$_SMALLCORE7" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/openoutreach-$_OPENOUTREACH-$_SMALLCORE7/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_OPENOUTREACH" openoutreach $_ROOT/distro/$_THIS_CORE/openoutreach-$_OPENOUTREACH-$_SMALLCORE7 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/openpublish-$_OPENPUBLISH-$_SMALLCORE7" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/openpublish-$_OPENPUBLISH-$_SMALLCORE7/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_OPENPUBLISH" openpublish $_ROOT/distro/$_THIS_CORE/openpublish-$_OPENPUBLISH-$_SMALLCORE7 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/openscholar-$_OPENSCHOLAR-$_SMALLCORE7" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/openscholar-$_OPENSCHOLAR-$_SMALLCORE7/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_OPENSCHOLAR" openscholar $_ROOT/distro/$_THIS_CORE/openscholar-$_OPENSCHOLAR-$_SMALLCORE7 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/panopoly-$_PANOPOLY-$_SMALLCORE7" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/panopoly-$_PANOPOLY-$_SMALLCORE7/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_PANOPOLY" panopoly $_ROOT/distro/$_THIS_CORE/panopoly-$_PANOPOLY-$_SMALLCORE7 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/prosepoint-$_PROSEPOINT-$_SMALLCORE6" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/prosepoint-$_PROSEPOINT-$_SMALLCORE6/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_PROSEPOINT" prosepoint $_ROOT/distro/$_THIS_CORE/prosepoint-$_PROSEPOINT-$_SMALLCORE6 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/recruiter-$_RECRUITER-$_SMALLCORE7" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/recruiter-$_RECRUITER-$_SMALLCORE7/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_RECRUITER" recruiter $_ROOT/distro/$_THIS_CORE/recruiter-$_RECRUITER-$_SMALLCORE7 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/restaurant-$_RESTAURANT-$_SMALLCORE7" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/restaurant-$_RESTAURANT-$_SMALLCORE7/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_RESTAURANT" restaurant $_ROOT/distro/$_THIS_CORE/restaurant-$_RESTAURANT-$_SMALLCORE7 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/spark-$_SPARK-$_SMALLCORE7" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/spark-$_SPARK-$_SMALLCORE7/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_SPARK" spark $_ROOT/distro/$_THIS_CORE/spark-$_SPARK-$_SMALLCORE7 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/totem-$_TOTEM-$_SMALLCORE7" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/totem-$_TOTEM-$_SMALLCORE7/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_TOTEM" totem $_ROOT/distro/$_THIS_CORE/totem-$_TOTEM-$_SMALLCORE7 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/ubercart-$_UBERCART6-$_SMALLCORE6" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/ubercart-$_UBERCART6-$_SMALLCORE6/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_UBERCART6" uberdrupal $_ROOT/distro/$_THIS_CORE/ubercart-$_UBERCART6-$_SMALLCORE6 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/ubercart-$_UBERCART7-$_SMALLCORE7" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/ubercart-$_UBERCART7-$_SMALLCORE7/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_UBERCART7" minimal $_ROOT/distro/$_THIS_CORE/ubercart-$_UBERCART7-$_SMALLCORE7 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/ubercart-testing-$_UBERCART7-$_SMALLCORE7" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/ubercart-testing-$_UBERCART7-$_SMALLCORE7/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_UBER_CART_TESTING" testing $_ROOT/distro/$_THIS_CORE/ubercart-testing-$_UBERCART7-$_SMALLCORE7 &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/pressflow-$_SMALLCORE6-dev" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/pressflow-$_SMALLCORE6-dev/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_DRUPAL6_D" default $_ROOT/distro/$_THIS_CORE/pressflow-$_SMALLCORE6-dev &> /dev/null
  fi
fi
if [ -d "$_ROOT/distro/$_THIS_CORE/pressflow-$_SMALLCORE6-stage" ] ; then
  if [ ! -e "$_ROOT/distro/$_THIS_CORE/pressflow-$_SMALLCORE6-stage/drushrc.php" ] ; then
    $_DRUSHCMD php-script make_platform "$_F_DRUPAL6_S" default $_ROOT/distro/$_THIS_CORE/pressflow-$_SMALLCORE6-stage &> /dev/null
  fi
fi
if [ ! -d "$_ROOT/distro/$_THIS_CORE/pressflow" ] ; then
  if [ -d "$_ROOT/distro/$_THIS_CORE/pressflow-$_SMALLCORE6-prod" ] ; then
    if [ ! -e "$_ROOT/distro/$_THIS_CORE/pressflow-$_SMALLCORE6-prod/drushrc.php" ] ; then
      $_DRUSHCMD php-script make_platform "$_F_DRUPAL6_P" default $_ROOT/distro/$_THIS_CORE/pressflow-$_SMALLCORE6-prod &> /dev/null
    fi
  fi
elif [ ! -d "$_ROOT/distro/$_THIS_CORE/pressflow-$_SMALLCORE6-prod" ] ; then
  if [ -d "$_ROOT/distro/$_THIS_CORE/pressflow" ] ; then
    if [ ! -e "$_ROOT/distro/$_THIS_CORE/pressflow/drushrc.php" ] ; then
      $_DRUSHCMD php-script make_platform "$_F_DRUPAL6_P" default $_ROOT/distro/$_THIS_CORE/pressflow &> /dev/null
    fi
  fi
fi
if [ -e "/var/run/aegir_upgrade.pid" ] ; then
  _PLATF_IMP=$(ls -la /data/u | grep $_USER | cut -d'>' -f2 | sort | uniq | awk '{ print $1}')
  for _PLATF in $_PLATF_IMP ; do
    if [[ $_PLATF =~ aegir ]] ; then
	  _FOUND_HM=YES
    else
      _PLATF_NAME=${_PLATF##*/}
      $_DRUSHCMD php-script make_platform "$_PLATF_NAME ($RANDOM)" default $_PLATF
    fi
  done
fi
rm -f make_platform.php

touch /opt/tmp/status-AegirSetupC-OK

###----------------------------------------###
###
###  Octopus Aegir Installer
###  Copyright (C) 2010-2014 Omega8.cc
###  noc@omega8.cc www.omega8.cc
###
###----------------------------------------###
