#!/bin/bash WEBROOT="/var/www" read -p "Name of the user which should be refreshed: " USER WEBDIR="$WEBROOT/$USER" if [ "$USER" == "" ]; then echo "User is empty. Abort." exit 1 elif [ $(grep -q "$USER" /etc/passwd; echo $?) == "1" ]; then echo "User does not exist. Abort." exit 1 fi echo "[INFO] Deleting website..." rm -rf $WEBDIR/html/* rm -rf $WEBDIR/html/.* cat > $WEBDIR/html/default.html << EOF Welcome!

Welcome to $USER's website.

This is a placeholder. Please upload content via an SFTP program.

EOF chown $USER:$USER $WEBDIR/html/default.html echo "[INFO] Cleaning MySQL database..." mysql -Nse "show tables" $USER | while read table; do mysql -e "drop table $table" $USER; done echo "[INFO] Done."