initial commit of already existing scripts

This commit is contained in:
2015-06-12 11:42:25 +03:00
commit 92bf42faec
7 changed files with 1017 additions and 0 deletions

40
server/del-web-user.sh Executable file
View File

@@ -0,0 +1,40 @@
#!/bin/bash
WEBROOT="/var/www"
DATASHEETS="/root/datasheets"
function checkwait {
read -p "Continue? Press Ctrl+C to cancel." END
}
read -p "Name of the user which should be deleted: " 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..."
chattr -i -V $WEBDIR/php-fcgi/php-fcgi-starter
rm -rf $WEBDIR
rm -f /etc/apache2/sites-available/$USER.conf
a2dissite $USER.conf
service apache2 restart
echo "[INFO] Deleting MySQL databases and user..."
echo "DROP DATABASE $USER;" | mysql
echo "DROP USER '$USER'@'localhost';" | mysql
echo "[INFO] Deleting datasheets..."
rm -f $DATASHEETS/datasheet-$USER.*
rm -f /var/share/teachers/datasheet-$USER.pdf
echo "[INFO] Deleting user and all its files from system..."
deluser --remove-home $USER
groupdel $USER
echo "[INFO] Done."