#
#####Message Texts######
set mesg1 = "Please enter the logon ID of the user to be delete:"
set mesg2a = "Logon ID "
set mesg2b = " not found, please check and try again."
set mesg3a = "Delete "
set mesg3b = " from password and group files(yes or no):"
set mesg4a = "Do you want to archive the content of "
set mesg4b = "(yes or no):"
set mesg5a = "Move the content of "
set mesg5b = " to another directory(yes or no):"
set mesg6 = "Enter the pathname of the destination directory:"
set mesg7a = "Delete all files in "
set mesg7b = "(yes or no):"
set mesg8a = "Delete all files in "
set mesg8b = " owned by "
set mesg8c = "(yes or no):"
########################
cp getinfo getinfo.sav
					# find out who we're removing	
echo -n $mesg1' '
scanname:
set name = ($<)
if ($#name == 0) then
	goto scanname
endif

						# make sure this user exists
awk '{FS=":"} {print $1}' /etc/passwd > foo
fgrep -s $name foo
if ($status == 1) then
	echo -n $mesg2a $name $mesg2b' '
	goto scanname
endif
					# ask for verification
echo -n $mesg3a $name $mesg3b' '
set verify =($<)
if (($verify == n) | ($verify == no)) then
	exit(0)				# if verification neg., quit here
endif


sed s/xx/$name/g getinfo > temp
mv temp getinfo
awk -f getinfo /etc/passwd > hold
mv getinfo.sav getinfo			# restore getinfo
chmod 644 /etc/passwd
				# remove user entry from group file
				# handles entreies at start and end
				# of lines specially
chmod 644 /etc/group

					# removal of user directory


echo -n $mesg4a `cat hold` $mesg4b' '
set totar = ($<)
if (($totar == y) | ($totar == yes)) then 
	goto ret
endif

echo -n $mesg5a `cat hold` $mesg5b' '
set totar = ($<)
if (($totar == y) | ($totar == yes)) then 
	echo -n $mesg6' '
scandest:
	set dest = ($<)
	if ($#dest == 0) then
		goto scandest
	endif
endif 

ret:
echo -n $mesg7a `cat hold` $mesg7b' '
set remove = ($<)
if (($remove == y) | ($remove == yes)) then 
	exit(0)
endif

echo -n $mesg8a `cat hold` $mesg8b $name $mesg8c' '
set remove = ($<)
if (($remove == y) | ($remove == yes)) then 
endif

/bin/rm hold
/bin/rm foo
exit(0)
