D8 reinstallation script

Public

Warning message

We recommend you to assign at least one category to this snippet so you could easily navigate it in the future. Edit your snippet here.

Resets settings.php, Removes config and php cache, Deletes all tables of a database

Get raw version
bash
  1. #!/bin/bash
  2.  
  3. # Put this into your drupal root as uninstall.sh
  4. # Make it executable with $ chmod +x uninstall.sh
  5. # Add it to your .gitignore $ echo uninstall.sh >> .gitignore
  6.  
  7. # To disable sudo to demand a password for executing this script:
  8. # execute $ visudo
  9. # and add the following lines with the correct paths and your own username:
  10. # Cmnd_Alias D8_UNINSTALL_SCRIPT = /var/www/drupal/uninstall.sh
  11. # patrickd ALL=(ALL) NOPASSWD: D8_UNINSTALL_SCRIPT
  12.  
  13.  
  14. # MySQL username
  15. MUSER="root"
  16. # MySQL password
  17. MPASS="root"
  18. # Database to delete all tables from
  19. MDB="drupal"
  20.  
  21.  
  22. echo "Removing files..."
  23. sudo rm -rf sites/default/files/*
  24.  
  25. echo "Resetting settings.php..."
  26. rm sites/default/settings.php
  27. cp sites/default/default.settings.php sites/default/settings.php
  28. chmod 777 sites/default/settings.php
  29.  
  30. MYSQL=$(which mysql)
  31. AWK=$(which awk)
  32. GREP=$(which grep)
  33.  
  34. TABLES=$($MYSQL -u $MUSER -p$MPASS $MDB -e 'show tables' | $AWK '{ print $1}' | $GREP -v '^Tables' )
  35.  
  36. for t in $TABLES
  37. do
  38. echo "Deleting $t table from $MDB database..."
  39. $MYSQL -u $MUSER -p$MPASS $MDB -e "drop table $t"
  40. done

Comments

fubhy's picture

Or simply this:

sudo rm sites/default/files -rf; sudo rm sites/default/settings.php; drush si minimal --account-pass=admin --db-url=mysql://root@drupal.local/drupal; drush en simpletest -y; sudo chmod 777 sites/default sites/default/settings.php

;)

fubhy's picture

Or you could simply do this: sudo rm sites/default/files -rf; sudo rm sites/default/settings.php; drush si minimal --account-pass=admin --db-url=mysql://root@drupal.local/drupal; drush en simpletest -y; sudo chmod 777 sites/default sites/default/settings.php

:)

patrickd's picture

@fubhy

Problem is that *sometimes* Drush 6 is broken with Drupal 8 (I'm for instance still not able to get it working) :-/