Skip to content

Instantly share code, notes, and snippets.

@davit
Last active August 29, 2015 14:21
Show Gist options
  • Save davit/a041ab70a822a2694ae2 to your computer and use it in GitHub Desktop.
Save davit/a041ab70a822a2694ae2 to your computer and use it in GitHub Desktop.
Install Drupal and create virtual host for it - requires 'create-vhosts' script to be installed.
#!/bin/bash
accountName=$1
accountPass=$2
dbUserName=$3
dbPass=$4
dbName=$5
siteName="$6"
contextRoot=$7
drupalVer=$8
MYSQL=`which mysql`
domain=${contextRoot}.com
function print_usage {
echo "USAGE: cdrupal [accountName] [accountPass] [dbUserName] [dbPass] [dbName] [siteName] [contextRoot] [drupalVersion (e.g. 7.37)]"
exit 0;
}
if [[ $# -ne 8 ]] ; then
print_usage
fi
Q1="CREATE DATABASE IF NOT EXISTS ${dbName};"
SQL="${Q1}"
$MYSQL -uroot -p${dbPass} -e "$SQL"
documentRoot=/var/www/${domain}/public_html
mkdir -p ${documentRoot}
cd ${documentRoot}
drupalVersion=drupal-${drupalVer}
drush -y dl ${drupalVersion}
mv ${drupalVersion}/* ./
mv ${drupalVersion}/.* ./
rm -rf ${drupalVersion}
drush -y site-install standard --account-name=${accountName} --account-pass=${accountPass} --db-url=mysql://${dbUserName}:$dbPass@localhost/${dbName}
drush variable-set site_name "${siteName}"
create-vhosts ${domain} true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment