Skip to content

Instantly share code, notes, and snippets.

@neclimdul
Last active December 28, 2015 14:39
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neclimdul/7516112 to your computer and use it in GitHub Desktop.
Save neclimdul/7516112 to your computer and use it in GitHub Desktop.

Drupal 8 command line installation helper.

This script is designed to help developers quickly spin up test installations of Drupal 8. It will clean and set up all the files and directories needed to install of Drupal 8 and by default use Drush to install to run the installation from the command line.

Thanks to @timplunkett for the initial implementation.

#!/bin/bash
CREDS=root:root
clean () {
# Drop any tables from the database.
drush sql-drop --db-url=mysql://$CREDS@localhost/${1:-d_d8} -y
sudo rm -rf sites/default sites/simpletest
sudo git checkout -- sites/default
sudo chmod -R 777 sites/default
sudo git checkout -- sites/default
mkdir sites/default/files sites/simpletest
sudo chown -R www-data: sites/default/files sites/simpletest
# This isn't strictly necesary or even ideal in production but if you don't do it installer tests will fail.
sudo chown -R www-data: sites/default/default.settings.php
}
install () {
mkdir simpletest
sudo chown -R `whoami` sites/default sites/simpletest
drush si --db-url=mysql://$CREDS@localhost/${1:-d_d8} -y
drush en devel simpletest -y
sudo chown -R www-data: sites/default/default.settings.php sites/default/files sites/simpletest
}
DATABASE=d_d8
CLEAN=false
INSTALL=false
while [ "$1" != "" ]; do
case $1 in
-c | --clean )
CLEAN=true
;;
-i | --install )
INSTALL=true
;;
-d | --database )
shift
DATABASE=$1
;;
* )
;;
esac
shift
done
if ! $CLEAN && ! $INSTALL; then
CLEAN=true;
INSTALL=true;
fi
$CLEAN && clean
$INSTALL && install $DATABASE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment