Created
June 19, 2013 11:59
-
-
Save deekayen/5813738 to your computer and use it in GitHub Desktop.
D8 reinstallation script by patrickd http://dropbucket.org/node/657. Resets settings.php, removes config and php cache, deletes all tables of a database.
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 | |
# Put this into your drupal root as uninstall.sh | |
# Make it executable with $ chmod +x uninstall.sh | |
# Add it to your .gitignore $ echo uninstall.sh >> .gitignore | |
# To disable sudo to demand a password for executing this script: | |
# execute $ visudo | |
# and add the following lines with the correct paths and your own username: | |
# Cmnd_Alias D8_UNINSTALL_SCRIPT = /var/www/drupal/uninstall.sh | |
# patrickd ALL=(ALL) NOPASSWD: D8_UNINSTALL_SCRIPT | |
# MySQL username | |
MUSER="root" | |
# MySQL password | |
MPASS="root" | |
# Database to delete all tables from | |
MDB="drupal" | |
echo "Removing files..." | |
sudo rm -rf sites/default/files/* | |
echo "Resetting settings.php..." | |
rm sites/default/settings.php | |
cp sites/default/default.settings.php sites/default/settings.php | |
chmod 777 sites/default/settings.php | |
MYSQL=$(which mysql) | |
AWK=$(which awk) | |
GREP=$(which grep) | |
TABLES=$($MYSQL -u $MUSER -p$MPASS $MDB -e 'show tables' | $AWK '{ print $1}' | $GREP -v '^Tables' ) | |
for t in $TABLES | |
do | |
echo "Deleting $t table from $MDB database..." | |
$MYSQL -u $MUSER -p$MPASS $MDB -e "drop table $t" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment