#!/bin/sh
# Use this file to finish MediaWiki removal ONLY if you don't want to keep it on your system.

clear
echo "WARNING!!!"
echo "This script will delete:"
echo "     - MediaWiki MySQL database"
echo "     - MediaWiki MySQL User"
echo "     - MediaWiki DB entries..."
echo "     - MediaWiki SME groups..."
echo "     - All Install files"
echo -n "ARE YOU SURE YOU WANT TO DELETE PERMANENTLY MEDIAWIKI? (y/n) [n] "
read del
if [ "$del" = "y" -o "$del" = "Y" ]; then
	echo "Deleting MySQL database..."
	mysql -u root -e "DROP DATABASE mediawiki"
	echo "Deleting MySQL User..."
	mysql -u root -e "REVOKE ALL PRIVILEGES ON mediawiki.* FROM 'mediawikiuser'@'localhost';"
	mysql -u root -e "DROP USER mediawikiuser@localhost;"
	echo "Removing SME DB entries..."
	/sbin/e-smith/config delete mediawiki
	echo "Removing SME group entries..."
#	/sbin/e-smith/db accounts set mw_read deleted
#	/sbin/e-smith/db accounts set mw_edit deleted
#	/sbin/e-smith/db accounts set mw_createpage deleted
#	/sbin/e-smith/db accounts set mw_createtalk deleted
#	/sbin/e-smith/signal-event group-delete mw_read
#	/sbin/e-smith/signal-event group-delete mw_edit
#	/sbin/e-smith/signal-event group-delete mw_createpage
#	/sbin/e-smith/signal-event group-delete mw_createtalk
	echo "Removing Install files..."
	rm -rf /opt/mediawiki
	echo "Done!"
	rm -f /root/MW-Full-Uninstall.sh
fi
