#!/bin/csh -f
#The default is to delete all files for the specified user

if (! -d "userdata") then
	echo "Can't find userdata directory. Are you in the right place?"
	exit
endif

set help = 0
set data = 0
set mail = 0
set profile = 0

switch ($1)
case -a:
	set data = 1
	set mail = 1
	set profile = 1
	breaksw
case -d:
	set data = 1
	breaksw
case -m:
	set mail = 1
	breaksw
case -p:
	set profile = 1
	breaksw
case -h:
default:
	set help = 1
	breaksw
endsw

#Display usage information if supplied arguments aren't correct.
if ($help == 1 || "$2" == "" || ($data == 0 && $mail == 0 && $profile == 0)) then
	echo "Usage: deleteuser -a|-m|-p|-d|-h username"
	echo ""
	echo "Select one of the following options followed by the users name"
	echo "       -a  Delete the users data, mail, and profile files"
	echo "       -d  Delete only the users data file"
	echo "       -m  Delete only the users mail file"
	echo "       -p  Delete only the users profile file"
	echo ""
	echo "NOTE: The default is to delete none of the users files"
	echo "      You will be asked to confirm each file deletion"
	echo "      The username must have only the first character capitalized"
	echo ""
	exit 1
endif

#Looks like we have been asked to delete something so lets delete it.
if ($data == 1) then
	find userdata -name $2.D -exec rm -i {} \;
endif

if ($mail == 1) then
	find usermail -name $2.M -exec rm -i {} \;
endif

if ($profile == 1) then
	find profiles -name $2.P -exec rm -i {} \;
endif





