#!/bin/sh # # Copyright (c) 1995, by Sun Microsystems, Inc. # All Rights Reserved # #ident "@(#)inetsvc 1.16 97/04/17 SMI" # # This is third phase of TCP/IP startup/configuration. This script # runs after the NIS/NIS+ startup script. We run things here that may # depend on NIS/NIS+ maps. # ############################################################################ # $Id: inetsvc_5.6,v 1.5 2000/07/19 00:03:28 chouanar Exp $ # # Modified by: Jean Chouanard to read /etc/yassp.conf # # # ############################################################################ if [ -f /etc/yassp.conf ] ; then . /etc/yassp.conf fi # # XXX - We need to give ypbind time to bind to a server. # sleep 5 # # Re-set the netmask and broadcast addr for all IP interfaces. This # ifconfig is run here, after NIS has been started, so that "netmask # +" will find the netmask if it lives in a NIS map. # The 'D' in -auD tells ifconfig NOT to mess with the interface # if it is under DHCP control # /usr/sbin/ifconfig -auD netmask + broadcast + # This is a good time to verify that all of the interfaces were # correctly configured. But this is too noisy to run every time we # boot. # # echo "network interface configuration:" # /usr/sbin/ifconfig -a # # If this machine is configured to be an Internet Domain Name # System (DNS) server, run the name daemon. # Start named prior to: route add net host, to avoid dns # gethostbyname timout delay for nameserver during boot. # if [ -f /usr/sbin/in.named -a -f /etc/named.boot ]; then /usr/sbin/in.named; echo "starting internet domain name server." fi if [ "X${SUNSTARTUP}" = "XYES" ] ; then # # Warning: The umask is 000 during boot, which requires explicit setting # of file permission modes. # # Configure DNS where used dnsdomain=`/sbin/dhcpinfo DNSdmain` if [ -n "$dnsdomain" ]; then dnsservers=`/sbin/dhcpinfo DNSserv` if [ -n "$dnsservers" ]; then if [ -f /etc/resolv.conf ]; then sed -e '/^domain/d' -e '/^nameserver/d' \ /etc/resolv.conf > /etc/resolv.conf.$$ fi echo "domain $dnsdomain" >> /etc/resolv.conf.$$ for name in $dnsservers; do echo nameserver $name >> /etc/resolv.conf.$$ done else if [ -f /etc/resolv.conf ]; then sed -e '/^domain/d' /etc/resolv.conf > /etc/resolv.conf.$$ fi echo "domain $dnsdomain" >> /etc/resolv.conf.$$ fi mv /etc/resolv.conf.$$ /etc/resolv.conf chmod 644 /etc/resolv.conf # Add dns to the nsswitch file, if it isn't already there. /usr/bin/awk ' $1 ~ /^hosts:/ { n = split($0, a); newl = a[1]; if ($0 !~ /dns/) { printf("#%s # Commented out by DHCP\n", $0); updated = 0; for (i = 2; i <= n; i++) { if (updated == 0 && index(a[i], "[") == 1) { newl = newl" dns"; updated++; } newl = newl" "a[i]; } if (updated == 0) { newl = newl" dns"; updated++; } if (updated != 0) newl = newl" # Added by DHCP"; else newl = $0; printf("%s\n", newl); } else printf("%s\n", $0); } $1 !~ /^hosts:/ { printf("%s\n", $0); }' /etc/nsswitch.conf > /etc/nsswitch.conf.$$ mv /etc/nsswitch.conf.$$ /etc/nsswitch.conf chmod 644 /etc/nsswitch.conf else # if we added DNS to a hosts line in the nsswitch, remove it. sed -e '/# Added by DHCP$/d' -e 's/^\(#hosts:\)\(.*[^#]\)\(#.*\)$/hosts: \2/' /etc/nsswitch.conf > /etc/nsswitch.conf.$$ mv /etc/nsswitch.conf.$$ /etc/nsswitch.conf chmod 644 /etc/nsswitch.conf fi hostname=`/sbin/dhcpinfo Hostname` if [ $? -eq 0 ]; then if [ -z "$hostname" ]; then hostname=`uname -n` fi ipaddr=`/sbin/dhcpinfo Yiaddr` thostent=`grep -s "^${ipaddr}" /etc/inet/hosts` if [ $? -eq 0 ] then # IP address is already in the hosts file. Ensure the # associated hostname is the same as what we received # via dhcp. echo $thostent | \ ( read tip thost etc; sed -e "/$ipaddr/s/$thost/$hostname/" /etc/inet/hosts > /etc/inet/hosts.temp; ) else cp -p /etc/inet/hosts /etc/inet/hosts.temp echo "$ipaddr $hostname # Added by DHCP" >> /etc/inet/hosts.temp fi # update loopback transport hosts files for inet in /etc/net/*/hosts do echo "# RPC hosts" > ${inet} echo "${hostname} ${hostname}" >> ${inet} chmod 644 ${inet} done mv /etc/inet/hosts.temp /etc/inet/hosts chmod 644 /etc/inet/hosts fi fi # SUNSTARTUP if [ "X${MULTICAST}" = "XYES" ] ; then # # Add a static route for multicast packets out our default interface. # The default interface is the interface that corresponds to the node name. # mcastif=`/sbin/dhcpinfo Yiaddr` if [ $? -ne 0 ]; then mcastif=`uname -n` fi echo "Setting default interface for multicast: \c" /usr/sbin/route add -interface -netmask "240.0.0.0" "224.0.0.0" "$mcastif" fi if [ "X${RUNINETD}" = "XYES" ] ; then # # Run inetd in "standalone" mode (-s flag) so that it doesn't have # to submit to the will of SAF. Why did we ever let them change inetd? # # Add the '-t' flags as we want to log the connections (Jean Chouanard) /usr/sbin/inetd -t -s fi # ************************************************** # $Log: inetsvc_5.6,v $ # Revision 1.5 2000/07/19 00:03:28 chouanar # license # # Revision 1.4 2000/07/04 17:55:30 chouanar # license # # Revision 1.3 2000/05/25 16:55:52 chouanar # rc.conf -> yassp.conf # # Revision 1.2 2000/05/21 18:57:48 chouanar # use rc.conf # # Revision 1.1 2000/03/15 21:48:24 chouanar # Initial revision # **************************************************