-
-
Save sidharrell/34f9663e3bc87548a86e to your computer and use it in GitHub Desktop.
Reinstall D8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# edits if using: | |
# current hostname: dev01.vhwebdev.com | |
# this only affects the message output with the link to the new site, not any functionality | |
# current local git clone of Drupal 8: /home/$user/Development/drupal | |
# you will need to locally clone drupal 8. It's a lot more efficient on whatever hosts drupal's git repo. | |
# current OS: Centos6 | |
# you would need to modify it to work on straight apache2 on Ubuntu, or make a symlink of /etc/httpd to /etc/apache2 | |
# and modify the apache2 main conf file to pick up .conf files in /etc/httpd/conf.d/ | |
# You will need to put https://gist.github.com/sidharrell/47767f2bb468ec65a84d , the template file, | |
# into /etc/httpd/conf.d/template | |
# requires pwgen, drush, sed, awk, git | |
if [ $# -eq 2 ] && [ `whoami` == root ]; then | |
echo "Usage: setupd8 <domain> <user>" | |
user=$2 | |
usertrunc=$(echo $2 | cut -c1-3) | |
domain=$(echo $usertrunc"_"$1 | tr '-' '_' | cut -c1-16); | |
echo "This will set up a Drupal 8 installation from the current state of your repository in /home/$user/Development/drupal." | |
echo "The new site will be reachable in the browser at http://$domain.dev01.vhwebdev.com" | |
echo "At the end of this script Drush will give you the new password for the admin user to login." | |
echo "/var/www/$domain and it's database will be reset." | |
else | |
echo "Incorrect usage"; | |
echo "Usage: setupd8 <domain> <user>" | |
echo "You must be running as sudo for this to work." | |
exit 1; | |
fi | |
while true; do | |
read -p "OK? (y/n): " ok; | |
case $ok in | |
[Yy]* ) break;; | |
[Nn]* ) exit;; | |
* ) echo "Please answer y or n.";; | |
esac | |
done | |
root="/var/www/$domain/htdocs" | |
rm -rf /etc/httpd/conf.d/$domain.conf /etc/httpd/conf.d/$domain.conf /var/www/$domain | |
sed "s/XXXXXX/$domain/g" /etc/httpd/conf.d/template > /etc/httpd/conf.d/$domain.conf | |
git clone /home/$user/Development/drupal $root | |
service httpd reload | |
chown -R $user.apache $root | |
find $root -type f -exec chmod 644 {} \; | |
find $root -type d -exec chmod 2755 {} \; | |
pw=$(pwgen 13 1) | |
mysql -e "drop database $domain; drop user '$domain'@'localhost';" | |
mysql -e "create database $domain; create user '$domain'@'localhost' identified by '$pw';" | |
mysql -e "grant all on $domain.* to '$domain'@'localhost';" | |
drush --root=$root si --db-url=mysql://$domain:$pw@localhost:3306/$domain -y | |
# Enable the development settings (disable CSS/JS aggregation, render caches, etc.) | |
cp $root/sites/example.settings.local.php $root/sites/default/settings.local.php | |
echo "include __DIR__ . '/settings.local.php';" | sudo tee -a $root/sites/default/settings.php > /dev/null | |
# Enable simpletest.module | |
drush --root=$root en simpletest -y | |
chown -R $user.apache $root |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment