#!/bin/bash

home="/home/bodo/addweb"
if test $1 = ""
        then
		echo "This script deletes a apache user."
                echo "Please enter the login of the user you want to delete."
                echo -n "Login: "
                read login
else
	echo "This script will delete user: $1"
        login=$1
fi

userdel $login

if test -d /var/www/$login
	then
		echo -n "Delete the user $login home directory? (Y/N): "
		read ok
		if test $ok = "Y"
			then
				rm -rf /var/www/$login
		fi
fi

if test -d /var/www/php-fcgid-scripts/$login
        then
                echo -n "Delete FCGI conf? (Y/N): "
                read ok
                if test $ok = "Y"
                        then
				wert=`chattr -V -i /var/www/php-fcgid-scripts/$login/php-fcgid-starter`
				echo "$wert"
                                rm -rf /var/www/php-fcgid-scripts/$login
                fi
fi

if test -e /etc/apache2/sites-available/$login
	then
		echo -n "Delete the user $login vHost? (Y/N): "
		read ok
		if test $ok = "Y"
			then
				rm -rf /etc/apache2/sites-enabled/$login
				rm -rf /etc/apache2/sites-available/$login
		fi
fi

echo -n "Reload the apache web server? (Y/N): "
read ok
if test $ok = "Y"
        then
                /etc/init.d/apache2 reload
fi

exit 0

