#
set noglob
#####Message Texts######
set mesg1 = "Please enter the hostname by which this machine is to be known: "
set mesg2 = "Hostname "
set mesg2b = " has already been used, "
set mesg2c = "please select another: "
set mesg3 = "Address must be in the form [1-255].[0-255].[0-255].[1-255]"
set mesg4 = "Please enter the Internet address for this machine: "
set mesg5 = "Address "
set mesg6 = "Do you wish to add other entries to node address file? (y or n) " 
set mesg7 = "Please respond 'y' or 'n'"
set mesg8 = "What type of network controller does this machine have"
set mesg8b = "(for example: ex, il, none)? "
########################
# if this is the first time thru coustomize /etc/rc.local
set HID = `fgrep /bin/hostname /etc/rc.local | awk '{print $2}'`
if ( $HID != UNKNOWN ) then
	set_nodes
	exit(0)	
endif
				# prompt for hostname
echo -n  $mesg1
get_host:
set HOST = ($<)
if ( $#HOST == 0) then
	goto get_host
endif
				# check uniqueness 
grep -sw $HOST /etc/hosts 
				# if its been used already ask to reenter
if ( $status != 1 ) then 
	echo $mesg2$HOST$mesg2b$mesg2c
	goto get_host
endif
				# prompt for address
echo -n  $mesg4
get_adrs:
set ADRS = ($<)
if ( $#ADRS == 0) then
	goto get_adrs
endif
				# check uniqueness 
grep -sw $ADRS /etc/hosts 
				# if its been used already ask to reenter
if ( $status != 1 ) then 
	echo $mesg5$ADRS$mesg2b$mesg2c
	goto get_adrs
endif
				# check that address is in range
echo $ADRS | grep -s '^[0-9]' 
if ( $status == 1 ) then
	goto bad_in
endif
echo $ADRS | awk '{FS="."} {print $1}' > test
if ( `cat test` < 1 | `cat test` > 255) then
	goto bad_in
endif
echo $ADRS | awk '{FS="."} {print $2}' > test
if ( `cat test` < 0 | `cat test` > 255) then
	goto bad_in
endif
echo $ADRS | awk '{FS="."} {print $3}' > test
if ( `cat test` < 0 | `cat test` > 255) then
	goto bad_in
endif
echo $ADRS | awk '{FS="."} {print $4}' > test
if ( `cat test` < 1 | `cat test` > 255) then
	goto bad_in
endif
				# rememove scratch files
/bin/rm -f test
				# ask what kind of controller
echo $mesg8
echo -n $mesg8b
get_control:
set control = ($<)
if ( $#control == 0) then
	goto get_control
endif
if ( $control == "none") then
	set control = "ex"
endif
				# ask if the want to continue w/ set_nodes
c_loop:
echo -n $mesg6
set contin = ($<)
if ( ($contin != y) && ($contin != n)  ) then
    echo $mesg7
    goto c_loop
endif
if ( $contin == y ) then
	set_nodes
endif

exit(0)

bad_in:
echo $mesg3
echo $mesg2c
goto get_adrs
