head     1.3;
access   ;
symbols  ;
locks    ; strict;
comment  @# @;


1.3
date     86.04.04.12.45.14;  author mark;  state Exp;
branches ;
next     1.2;

1.2
date     86.04.03.15.35.53;  author mark;  state Exp;
branches ;
next     1.1;

1.1
date     86.04.03.14.37.41;  author mark;  state Exp;
branches ;
next     ;


desc
@first stab at a reasonable rm_{cluster,diskless} script.
@


1.3
log
@changed /tmp/host$$ to /tmp/hosts$$ several places, added messages when
files are being deleted.
@
text
@#! /bin/csh
#
# $Header: rm_node,v 1.2 86/04/03 15:35:53 mark Exp $
#
# $Log:	rm_node,v $
# Revision 1.2  86/04/03  15:35:53  mark
# added crude error checks for selection of cluster net number
# 
# Revision 1.1  86/04/03  14:37:41  mark
# Initial revision
# 
#
# This script is actually called from the admin menu driver with an argument
# which is either "cluster" or "diskless".  It is currently ignored, but
# if you want to modify this thing to use it, its there.
#
set noglob

get_name:
echo -n "Enter the name of workstation to be removed: "
set name = ($<)
if ($#name != 1) then
	echo "Please enter a single name..."
	goto get_name	
endif


#
# First remove the private files.
#
foreach f (`cat /usr/lib/admin.scripts/PRIVATE_FILES`)
	set head = $f:h
	set tail = $f:t
	if ( $head == $tail ) then
		set private = .${head}.$name
	else
		set private = ${head}/.${tail}.$name
	endif

	if ( -e $private ) then
		/bin/rm -rf $private
		if ($status != 0) then
			echo "Unknown problem encountered in executing command"
			echo "	/bin/rm -rf $private"
			echo "Be sure to check this after exiting from Admin."
			echo -n "Type RETURN to proceed..."
			set dummy = ($<)
		else
			echo "	Removed $private."
		endif
	else
		echo -n "Can't find $private.  Type RETURN to continue..."
		set dummy = ($<)
	endif
end

#
# Now remove the name from the host file.  If there is more than one entry
# with the same name, ask for help.
#
set n = `fgrep $name /etc/hosts | wc -l`
switch ($n)
case 0:
	echo No entry exists in /etc/hosts for $name.
	echo -n Type RETURN...
	set dummy = ($<)
	exit(0)
	breaksw
case 1:
	set line = `fgrep $name /etc/hosts`
	sed -e "/$name/d" < /etc/hosts > /tmp/hosts$$
	cp /tmp/hosts$$ /etc/hosts
	rm /tmp/hosts$$
	echo "The line <<$line>> has been removed from /etc/hosts."
	echo -n "Type RETURN..."
	set dummy = ($<)
	exit(0)
	breaksw
default:
	echo There is more than one entry in /etc/hosts for $name.  Please
	echo remove use an editor to remove the desired name.
	echo Type RETURN...
	set dummy = ($<)
	breaksw
endsw
@


1.2
log
@added crude error checks for selection of cluster net number
@
text
@d3 1
a3 1
# $Header: rm_node,v 1.1 86/04/03 14:37:41 mark Exp $
d6 3
d20 1
a20 1
echo "Enter the name of workstation to be removed: "
d48 2
d52 1
a52 1
		echo "Can't find $private.  Type RETURN to continue..."
d70 1
d72 5
a76 2
	cp /tmp/host$$ /etc/hosts
	rm /tmp/host$$
@


1.1
log
@Initial revision
@
text
@d3 1
a3 1
# $Header$
d5 4
a8 1
# $Log$
a70 1
	fgrep $name /etc/hosts | awk '{print NR "	" $0}' > /tmp/${name}$$
d72 2
a73 7
	echo select the correct one from the following list by typing the
	echo line number at the left:
again:
	echo ""
	cat /tmp/${name}$$
	echo ""
	echo -n "line number?..."
a74 8
	if ( $dummy < 1 || $dummy > $n ) then
		echo "Invalid entry...please select a value between 1 and $n."
		goto again
	endif
	set line=`grep "^$dummy\t" /tmp/${name}$$ | sed -e 's/^.*:	//'`
	sed "/$line/d" < /etc/hosts > /tmp/hosts$$
	cp /tmp/hosts$$ /etc/hosts
	/bin/rm -f /tmp/hosts$$ /tmp/${name}$$
@
