initial commit of already existing scripts
This commit is contained in:
37
server/refresh-web-user.sh
Executable file
37
server/refresh-web-user.sh
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/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."
|
||||
Reference in New Issue
Block a user