#!/bin/sh
#Nifty: Delete data from deleted customers not active in Apache
echo
echo
echo
echo
echo
echo
echo
echo
echo
for site in `ls -lta /var/www/ | awk '$3 ~ /^[0-9]+$/ { print $9 }' ` ; do
	ls -lad /var/www/$site
done

echo
echo
echo "Please check the list above and ensure that none of"
echo "the entries have non-numeric uid/gid fields. All must be numeric"
echo
echo

echo -en "Are all uid/gid fields numeric? [y|n] "
read answer

if [ "$answer" = "y" ]; then
	for site in `ls -lta /var/www/ | awk '$3 ~ /^[0-9]+$/ { print $9 }' ` ; do
		grep $site /etc/httpd/vhosts.d/vhosts.conf > /dev/null 2>&1

		if [ "$?" -eq "0" ]; then
			echo "$site was found in Apache configuration! I will not delete that"
		else
			echo "Deleting $site"
			rm -rf /var/www/$site
		fi
	done
else
	echo "Exiting!"
	exit 1

fi


exit
