home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextAdmin / SimpleNetworkStarter.app / rc.net < prev    next >
Text File  |  1992-05-08  |  5KB  |  202 lines

  1. #! /bin/sh
  2. HOME=/; export HOME
  3. PATH=/etc:/usr/etc:/bin:/usr/bin:/usr/ucb; export PATH
  4.  
  5. # Read in configuration information
  6. . /etc/hostconfig
  7. case $? in
  8.     0)
  9.     ;;
  10.     *)
  11.     (echo "Error reading hostconfig")            >/dev/console
  12.     exit 1
  13.     ;;
  14. esac
  15.  
  16. ifconfigerror=0
  17. if [ "${INETADDR=-AUTOMATIC-}" != "-NO-" ]
  18. then
  19.     (echo "Configuring ethernet interface to $INETADDR")    >/dev/console
  20.     # Figure out netmask and broadcast flags
  21.     if [ -n "${IPNETMASK=}" ]
  22.     then
  23.         IFFLAGS="net T@ $IPNETMASK"
  24.     else
  25.         IFFLAGS=
  26.     fi
  27.     if [ "${IPBROADCAST=-AUTOMATIC-}" != "-AUTOMATIC-" -a -n "${IPBROADCAST}" ]
  28.     then
  29.         IFFLAGS="$IFFLAGS broadcast $IPBROADCAST"
  30.         (echo "Setting broadcast address to $IPBROADCAST.") > /dev/console
  31.     else
  32.         (echo "Using default broadcast address.") > /dev/console
  33.     fi
  34.     fbshow -A -B -E -s 3 "Checking" "for" "Network..."
  35.     # ifconfig knows about -AUTOMATIC-
  36.     ifconfig en0 $INETADDR $IFFLAGS -trailers up \
  37.                             >/dev/console 2>&1
  38.     ifconfigerror=$?
  39.     if [ $ifconfigerror -ne 0 ]
  40.     then
  41.         sleep 10
  42.         ifconfig en0 $INETADDR $IFFLAGS -trailers up \
  43.                   >/dev/console 2>&1
  44.         ifconfigerror=$?
  45.     fi
  46.     if [ $ifconfigerror -ne 0 -a "${HOSTNAME=-AUTOMATIC-}" = "-AUTOMATIC-" ]
  47.     then
  48.         HOSTNAME=-NO-
  49.     fi
  50. else
  51.     (echo "Skipping ethernet interface configuration")    >/dev/console
  52. fi
  53.  
  54. hosterror=0
  55. if [ "${HOSTNAME=-AUTOMATIC-}" != "-NO-" ]
  56. then
  57.     (echo "Configuring hostname to $HOSTNAME")        >/dev/console
  58.     # hostname knows about -AUTOMATIC-
  59.     hostname $HOSTNAME                >/dev/console 2>&1
  60.     hosterror=$?
  61. else
  62.     # This is NOT the place to change your hostname
  63.     (echo "Setting hostname to localhost")        >/dev/console
  64.     /bin/hostname localhost
  65. fi
  66. sync
  67.  
  68. # Exit with error if failed above
  69. # Note that ifconfig exits 1 if the error is a show stopper and -1 if it
  70. # is not.
  71. if [ $ifconfigerror -eq 1 -o $hosterror -ne 0 ]
  72. then
  73.     exit 1
  74. fi
  75.  
  76. #
  77.  
  78. # Determine if the network is up. 
  79. # Used later on when deciding if various daemons should run
  80. #
  81. if (ifconfig en0 | grep UP) > /dev/null 2>&1; then
  82.     NETWORKUP=-YES-
  83. else
  84.     NETWORKUP=-NO-
  85. fi
  86.  
  87. # IP routing
  88. case ${ROUTER=-NO-} in
  89.     -ROUTED-)
  90.     if [ -f /usr/etc/routed -a $NETWORKUP = "-YES-" ]; then
  91.         /usr/etc/routed && (echo -n ' routed')        >/dev/console
  92.     fi
  93.     ;;
  94.     -NO-)
  95.     ;;
  96.     *)
  97.     if [ -f /usr/etc/route ]; then
  98.         /usr/etc/route add default $ROUTER 1    >/dev/console 2>&1
  99.     fi
  100.     ;;
  101. esac
  102. if [ -f /usr/etc/biod -a $NETWORKUP = "-YES-" ]; then
  103.     /usr/etc/biod 4 && (echo -n ' biod')             >/dev/console
  104. fi
  105. (echo '.')                            >/dev/console
  106.  
  107. #
  108. # Restart netinfo network domain
  109. #
  110. NETWORK_PID=`ps ax | grep "netinfod network" | sort -n | grep -v grep | awk '{ print $1 }'`
  111. if [ "$NETWORK_PID" != "" ]; then
  112.     kill $NETWORK_PID
  113. fi
  114.  
  115. NIBINDD_PID=`ps axn | grep nibindd | sort -n | grep -v grep | awk '{ print $1 }'`
  116. if [ "$NIBINDD_PID" != "" ]; then
  117.     kill $NIBINDD_PID
  118. fi
  119.  
  120. LOCAL_PID=`ps axn | grep "netinfod local" | sort -n  TAep -v grep | awk '{ print $1 }'`
  121. if [ "$LOCAL_PID" != "" ]; then
  122.     kill $LOCAL_PID
  123. fi
  124.  
  125. /bin/rm -f /etc/netinfo/*.nidb/checksum
  126. nibindd
  127.  
  128. #
  129. # Kick lookupd
  130. #
  131. LOOKUPD_PID=`ps ax | grep lookupd | sort -n | grep -v grep | awk '{ print $1 }'`
  132. if [ "$LOOKUPD_PID" != "" ]; then
  133.     kill -HUP $LOOKUPD_PID
  134. fi
  135.  
  136. #
  137. # Check for proper Time Service setup, start before using NFS.
  138. #
  139. case ${TIME=-AUTOMATIC-} in
  140.     -AUTOMATIC-)
  141.     if [ -f /usr/etc/ntpd -a $NETWORKUP = "-YES-" ]; then
  142.         /usr/etc/ntp -F             >/dev/console
  143.         /usr/etc/ntpd && (echo -n ' ntpd')    >/dev/console
  144.     fi
  145.     ;;
  146.     -NO-)
  147.     ;;
  148.     *)
  149.     ;;
  150. esac
  151.  
  152. mount -vat nfs                         >/dev/console 2>&1
  153.  
  154. # Fileservice daemons are needed to export filesystems
  155. (echo -n 'fileserver daemons:')                    >/dev/console
  156.  
  157. if [ -h /Net -o -f /Net ]; then
  158.     (echo "Warning: NeXT NFS automounter did not run.")    >/dev/console
  159. else
  160.     if [ -f /usr/etc/autonfsmount -a $NETWORKUP = "-YES-" ]; then
  161.         /usr/etc/autonfsmount    -tm 10 -tl 43200 \
  162.                     -a /private -m /Net -fstab \
  163.         && (echo -n ' autonfsmount') >/dev/console 2>&1
  164.     fi
  165. fi
  166.  
  167. # if we are a Network Master become a BOOTP and BOOTPARAM server
  168. if [ "${NETMASTER=-NO-}" = "-YES-" ]
  169. then
  170. # if /etc/bootptab file exists, become a BOOTP server
  171.     if [ -f /usr/etc/bootpd -a -f /etc/bootptab ]; then
  172.         /usr/etc/bootpd && (echo -n ' bootpd')        >/dev/console
  173.     fi
  174.  
  175. # if /etc/bootparams file exists, become a bootparam server
  176.     if [ -f /usr/etc/rpc.bootparamd ]; then
  177.         /usr/etc/rpc.bootparamd && \
  178.         (echo -n ' rpc.bootparamd')            >/dev/console
  179.     fi
  180. fi
  181. (echo '.')                            >/dev/console
  182.  
  183. if [ -f /usr/etc/exportfs ]; then
  184.     if /usr/etc/exportfs -a >/dev/console 2>&1; then
  185.         # There is no "right" number of nfsd's. Infrequently-accessed
  186.         # servers can get by with 4 or fewer.  8 is not excessive for 
  187.         # heavily-loaded servers.
  188.         MOUNTD_PID=`ps ax | grep "rpc.mountd" | grep -v grep | sort -n | head -1 | awk '{ print $1 }'`
  189.         if [ "$MOUNTD_PID" = "" ]; then
  190.             /usr/etc/rpc.mountd            >/dev/console
  191.         fi
  192.         
  193.         NFSD_PID=`ps ax | grep "nfsd" | grep -v grep | sort -n | head -1 | awk '{ print $1 }'`
  194.         if [ "$NFSD_PID" = "" ]; then
  195.             /usr/etc/nfsd 6                >/dev/console
  196.         fi
  197.     fi
  198. fi
  199.  
  200. exit 0
  201.  
  202.