Skip to content

Instantly share code, notes, and snippets.

@joachim-n
Forked from cam8001/d8_reset.sh
Last active August 29, 2015 13:57
Show Gist options
  • Save joachim-n/9481465 to your computer and use it in GitHub Desktop.
Save joachim-n/9481465 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Removes an existing Drupal 8 install, then install again.
# Requires Drush 7 - https://github.com/drush-ops/drush
#
# Run this script from the docroot of a Drupal 8 checkout.
# Installs to mysql://localhost/drupal, user 1 user/pass is admin/admin.
# Variables.
# These should be customized to your setup.
# Note that bash won't tolerate spaces either side of the '='.
DATABASE='drupal-8'
DB_USER=drupal
DB_PASSWORD=hello
if [ ! -e ./core/core.services.yml ]
then
echo "You need to run this script from the root of a Drupal 8 install."
exit
fi
# MySQL
echo "Dropping and recreating '$DATABASE' database.\n"
mysql --user=$DB_USER --password=$DB_PASSWORD -e "drop database \`$DATABASE\`"
mysql --user=$DB_USER --password=$DB_PASSWORD -e "create database \`$DATABASE\`"
echo "Removing files created during drupal install. You will be asked for your password, for sudo.\n"
sudo rm -f ./sites/default/settings.php
sudo rm -rf ./sites/simpletest
sudo cp ./sites/default/default.settings.php ./sites/default/settings.php
sudo chmod 777 ./sites/default/settings.php
sudo rm -rf ./sites/default/files
sudo chmod 777 ./sites/default
# Now install a Drupal.
drush si --account-name=admin --account-pass=admin --db-url=mysql://$DB_USER:$DB_PASSWORD@localhost/$DATABASE -yv
drush en devel simpletest -y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment