Subject: RE: status of install tools for 1.5.1
To: 'mw@blobulent.com' <mw@blobulent.com>
From: Bruce Korb <bkorb@allegronetworks.com>
List: port-macppc
Date: 04/11/2001 10:20:44
Due to the variety of places where network information gets
stashed on initial machine setup, we here cooked up this
little setup script that may or may not be convenient for
others.  This script is intended to run in single user mode
immediately after a fresh install + a r/w remount of root
(otherwise ksh chokes trying to create a scratch file).

===================================

#! /bin/ksh

please_enter()
{
    typeset var=$1
    typeset val=""

    shift
    typeset pmt="Please enter your $*"
    while [ -z "${val}" ]
    do
        read val?"$pmt: "
        pmt="You must enter your $*"
    done
    eval ${var}="'$val'"
    export ${var}
}

cat <<_EOF_ |&
DOMAIN_NAME  network domain name
NET_MASK     network mask
MACH_NAME    machine name
IP_ADDR      ip address
NAMESERVER1  primary name server
NAMESERVER2  secondary name server
DEFAULT_RT   default route
SEARCH       domain search list
_EOF_

while read -p v p
do
  eval f="\${$v+set}"
  if [ X$f = Xset ]
  then :
  else please_enter $v $p ; fi
  list="$list $v"
done

typeset -L12 x

for f in $list
do
  x=$f
  eval print \"\$x is \$$f\"
done

print "to change any of these, enter NAME='new-value'"
print "press <enter> by itself when you are done"
while read v?"Change:  "
do [ -z "$v" ] && break
   case "$v" in
   *=* ) eval "$v" ;;
   * )   print "Format must be:  NAME='new-value'" ;;
   esac
done

mount -a
cd /etc
# # # # # # # # # # # # # # # # # # #
#
#  NETWORK
#
if [ ! -f hosts.ori ]
then
  mv hosts hosts.ori || {
    echo Cannot move hosts out of the way.  Is it writable? >&2
    exit 1
  }
fi

cat > hosts <<_EOF_
# Host Database
# This file should contain the addresses and aliases for local hosts that
# share this file.  It is used only for "ifconfig" and other operations
# before the nameserver is started.
#
127.0.0.1               localhost
::1                     localhost
${IP_ADDR}              ${MACH_NAME}
# RFC 1918 specifies that these networks are "internal".
# 10.0.0.0      10.255.255.255
# 172.16.0.0    172.31.255.255
# 192.168.0.0   192.168.255.255
_EOF_

echo "${MACH_NAME} netmask ${NET_MASK} media autoselect" > ifconfig.gm0


cat > resolv.conf <<_EOF_
domain ${DOMAIN_NAME}
nameserver ${NAMESERVER1}
nameserver ${NAMESERVER2}`

if [ -n "${SEARCH}" ]
then echo ; echo search ${SEARCH} ; fi`
_EOF_

# # # # # # # # # # # # # # # # # # #
#
#  FSTAB Manipulations
#
cp -fp fstab fstab.ori
for f in kern proc
do
  [ ! -d /${f} ] && mkdir /${f}

  if egrep "^/${f}" fstab > /dev/null
  then :
  else echo "/${f} /${f} ${f}fs rw 0 0" >> fstab ; fi
done

mv -f rc.conf rc.conf.ori
sed "s,^rc_configured=[A-Z]*,rc_configured=YES,
     s,^hostname=.*,hostname=\"${MACH_NAME}\",
     s,^defaultroute=.*,defaultroute=\"${DEFAULT_RT}\",
     s,^nfs_client=[A-Z]*,nfs_client=YES,
     s,^nfs_server=[A-Z]*,nfs_server=YES,
     s,^rpcbind=[A-Z]*,rpcbind=YES," \
     rc.conf.ori > rc.conf