38 lines
796 B
Bash
Executable File
38 lines
796 B
Bash
Executable File
#!/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
|
|
<html>
|
|
<head>
|
|
<title>Welcome!</title>
|
|
</head>
|
|
<body>
|
|
<p>Welcome to $USER's website.</p>
|
|
<p>This is a placeholder. Please upload content via an SFTP program.</p>
|
|
</body>
|
|
</html>
|
|
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."
|