Subject: misc/1952: enhanced replacement for [misc-1919]
To: None <gnats-bugs@gnats.netbsd.org>
From: Luke Mewburn <lukem@supp.cpr.itg.telecom.com.au>
List: netbsd-bugs
Date: 01/16/1996 15:05:52
>Number:         1952
>Category:       misc
>Synopsis:       separating netstart from rc in [misc-1919]
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    misc-bug-people (Misc Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   lm
>Arrival-Date:   Tue Jan 16 00:50:02 1996
>Last-Modified:
>Originator:     Luke Mewburn
>Organization:
>Release:        NetBSD-960113
>Environment:
NetBSD shelob 1.1A NetBSD 1.1A (SHELOB) #0: Mon Jan  8 12:58:14 EST 1996     root@shelob:/z/src/sys/arch/i386/compile/SHELOB i386
>Description:
	My patch of [misc-1919] which implements /etc/rc.conf instead
	of having lots of files in /etc removed the functionality of
	/etc/netstart.

	Some people want the concept of /etc/netstart so that they
	can easily bring up networking when in single user mode.

	This patch, which should be applied instead of [misc-1919],
	re-implements /etc/netstart to do this work.

>How-To-Repeat:
	Apply [misc-1919] and find that netstart functionality is
	useful.

>Fix:
	Apply this patch instead of [misc-1919].

	PS: you can still remove /etc/{hostname.*,mygate,myname}
	etc as outlined in [misc-1919]

diff --new-file -c /tmp/etc/Makefile etc/Makefile
*** /tmp/etc/Makefile	Tue Dec 12 07:07:00 1995
--- etc/Makefile	Tue Jan 16 14:59:05 1996
***************
*** 16,22 ****
  BINGRP= wheel
  BIN1=	aliases bootptab changelist csh.cshrc csh.login csh.logout daily \
  	dm.conf ftpusers ftpchroot gettytab group hosts hosts.equiv hosts.lpd \
! 	inetd.conf man.conf monthly motd myname netstart newsyslog.conf \
  	phones printcap protocols rc rc.local remote rpc security services \
  	shells syslog.conf weekly etc.${MACHINE}/ttys etc.${MACHINE}/disktab
  
--- 16,22 ----
  BINGRP= wheel
  BIN1=	aliases bootptab changelist csh.cshrc csh.login csh.logout daily \
  	dm.conf ftpusers ftpchroot gettytab group hosts hosts.equiv hosts.lpd \
! 	inetd.conf man.conf monthly motd netstart newsyslog.conf \
  	phones printcap protocols rc rc.local remote rpc security services \
  	shells syslog.conf weekly etc.${MACHINE}/ttys etc.${MACHINE}/disktab
  
diff --new-file -c /tmp/etc/netstart etc/netstart
*** /tmp/etc/netstart	Sat Dec 30 23:09:00 1995
--- etc/netstart	Tue Jan 16 14:55:03 1996
***************
*** 1,119 ****
  #!/bin/sh -
  #
! #	$NetBSD: netstart,v 1.23 1995/12/30 01:30:03 thorpej Exp $
! #	@(#)netstart	5.9 (Berkeley) 3/30/91
  
! # set these to "NO" to turn them off.  otherwise, they're used as flags
! routed_flags=-q
! mrouted_flags=NO	# for 'normal' use: mrouted_flags=""
! rarpd_flags=NO		# for 'normal' use: rarpd_flags="-a"
! bootparamd_flags=NO	# for 'normal' use: bootparamd_flags=""
! rbootd_flags=NO		# for 'normal' use: rbootd_flags=""
! sendmail_flags=NO	# for 'normal' use: sendmail_flags="-bd -q30m"
! named_flags=NO		# for 'normal' use: named_flags=""
! timed_flags=
! 
! # set the following to "YES" to turn them on
! rwhod=NO
! nfs_server=NO
! nfs_client=NO
! gated=NO
! kerberos_server=NO
! amd=NO
! 
! # miscellaneous other flags
! # only used if the appropriate server is marked YES above
! gated_flags=
! amd_dir=/amd			# AMD's mount directory
! amd_master=/etc/amd/master	# AMD 'master' map
  
! # /etc/myname contains my symbolic name
! #
! hostname=`cat /etc/myname`
! hostname $hostname
! if [ -f /etc/defaultdomain ]; then
! 	domainname `cat /etc/defaultdomain`
  fi
  
! # configure all of the interfaces which we know about.
! # do this by reading /etc/hostname.* files, where * is the name
! # of a given interface.
! #
! # these files are formatted like the following, but with no # at the
! # beginning of the line
! #
! # addr_family hostname netmask broadcast_addr options
! # dest dest_addr
! #
! # addr_family is the address family of the interface, generally inet
! # hostname is the host name that belongs to the interface, in /etc/hosts.
! # netmask is the network mask for the interface.
! # broadcast_addr is the broadcast address for the interface
! # options are misc. options to ifconfig for the interface.
! #
! # dest is simply the string "dest" (no quotes, though) if the interface
! # has a "destination" (i.e. it's a point-to-point link, like SLIP).
! # dest_addr is the hostname of the other end of the link, in /etc/hosts
! #
! # the only required contents of the file are the addr_family field
! # and the hostname.
  
! (
!     tmp="$IFS"
!     IFS="$IFS."
!     set -- `echo /etc/hostname*`
!     IFS=$tmp
!     unset tmp
! 
!     while [ $# -ge 2 ] ; do
!         shift            # get rid of "hostname"
!         (
!             read af name mask bcaddr extras
!             read dt dtaddr 
! 
!             if [ ! -n "$name" ]; then
!                 echo "/etc/hostname.$1: invalid network configuration file"
!                 exit
!             fi
! 
! 	    cmd="ifconfig $1 $af $name "
! 	    if [ "${dt}" = "dest" ]; then cmd="$cmd $dtaddr"; fi
! 	    if [ -n "$mask" ]; then cmd="$cmd netmask $mask"; fi
! 	    if [ -n "$bcaddr" -a "X$bcaddr" != "XNONE" ]; then
! 		cmd="$cmd broadcast $bcaddr";
! 	    fi
! 	    cmd="$cmd $extras"
! 
! 	    $cmd
!         ) < /etc/hostname.$1
!         shift
!     done
! )
  
  # set the address for the loopback interface
  ifconfig lo0 inet localhost
  
  # use loopback, not the wire
  route add $hostname localhost
  
! # /etc/mygate, if it exists, contains the name of my gateway host
! # that name must be in /etc/hosts.
! if [ -f /etc/mygate ]; then
! 	route add default `cat /etc/mygate`
  fi
  
! # /etc/ifaliases, if it exists, contains the names of additional IP
! # addresses for each interface. It is formatted as a series of lines
! # that contain
! # address interface
! if [ -f /etc/ifaliases ]; then
! (
!     set -- `cat /etc/ifaliases`
! 
!     while [ $# -ge 2 ] ; do
! 	ifconfig $2 inet alias $1
! 	route add $1 localhost
!         shift 2
!     done
!  )
! fi
--- 1,80 ----
  #!/bin/sh -
  #
! #	$NetBSD$
  
! # Read in host-specific information from one file
! . /etc/rc.conf
  
! # $hostname is imported from /etc/rc.conf;
! if [ "X${hostname}" != "X" ]; then
! 	hostname ${hostname}
  fi
  
! # $domainname is imported from /etc/rc.conf;
! if [ "X${domainname}" != "X" ]; then
! 	domainname ${domainname}
! fi
  
! # configure all of the interfaces which we know about.
! # do this by running for each WORD in $interfaces, and extracting
! # the following variables, which are imported from /etc/rc.conf:
! # - interface_WORD	addr_family hostaddr [netmask [broadcast [options]]]
! # - destination_WORD	[dest_addr]
! # - ifaliases_WORD	[alias_addr [alias_addr ...]]
! #
! # addr_family:	address family of the interface, generally inet
! # hostaddr:	host addr that belongs to the interface, in /etc/hosts.
! # netmask:	network mask for the interface.
! # broadcast:	broadcast address for the interface
! # options:	misc. options to ifconfig for the interface.
! # dest_addr:	if the interface has a "destination" (i.e. it's a
! #		point-to-point link, like SLIP), this is the address
! #		of the other end of the link, in /etc/hosts
! # alias_addr:	interface aliases, in /etc/hosts.
! 
! echo -n "Configuring interfaces:"
! for iface in ${interfaces} ; do
! 	eval `echo 'args=$interface_'$iface`
! 	if [ "X$args" = "X" ] ; then continue; fi
! 	set -- $args
! 	af=$1 ; name=$2 ; mask=$3 ; bcaddr=$4 ; extras=$5
! 	if [ ! -n "$name" ]; then
! 		echo 1>&2 "\$interface_$iface: invalid network configuration"
! 		continue
! 	fi
! 
! 	cmd="ifconfig $iface $af $name"
! 	eval `echo 'dest=$destination_'$iface`
! 	if [ "X$dest" != "X" ] ; then cmd="$cmd $dest"; fi
! 	if [ -n "$mask" ]; then cmd="$cmd netmask $mask"; fi
! 	if [ -n "$bcaddr" -a "X$bcaddr" != "XNONE" ]; then
! 		cmd="$cmd broadcast $bcaddr"
! 	fi
! 	cmd="$cmd $extras"
! 
! 	$cmd
! 	echo -n " $iface"
! done
  
  # set the address for the loopback interface
  ifconfig lo0 inet localhost
+ echo " lo0."
  
  # use loopback, not the wire
  route add $hostname localhost
  
! # $defaultroute is imported from /etc/rc.conf;
! if [ "X${defaultroute}" != "X" ]; then
! 	route add default ${defaultroute}
  fi
  
! # setup any interface aliases, as described above
! for iface in ${interfaces} ; do
! 	eval `echo 'aliases=$ifaliases_'$iface`
! 	set -- $aliases
! 	while [ $# -ge 1 ] ; do
! 		ifconfig $iface inet alias $1
! 		route add $1 localhost
! 		shift
! 	done
! done
diff --new-file -c /tmp/etc/rc etc/rc
*** /tmp/etc/rc	Sat Dec 30 23:09:00 1995
--- etc/rc	Tue Jan 16 14:56:55 1996
***************
*** 17,22 ****
--- 17,25 ----
  PATH=/sbin:/bin:/usr/sbin:/usr/bin
  export PATH
  
+ # Read in host-specific information from one file
+ . /etc/rc.conf
+ 
  # Configure ccd devices.
  if [ -f /etc/ccd.conf ]
  then
***************
*** 93,99 ****
  	echo -n ' ypbind';		ypbind
  fi
  
! # $nfs_server is imported from /etc/netstart;
  # if $nfs_server == YES, the machine is setup for being an nfs server
  if [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then
  	rm -f /var/db/mountdtab	
--- 96,102 ----
  	echo -n ' ypbind';		ypbind
  fi
  
! # $nfs_server is imported from /etc/rc.conf;
  # if $nfs_server == YES, the machine is setup for being an nfs server
  if [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then
  	rm -f /var/db/mountdtab	
***************
*** 102,108 ****
  	echo -n ' nfsd';		nfsd -tun 4
  fi
  
! # $nfs_client is imported from /etc/netstart;
  # if $nfs_client == YES, the machine is setup for being an nfs client
  if [ X${nfs_client} = X"YES" ]; then
  	echo -n ' nfsiod';		nfsiod -n 4
--- 105,111 ----
  	echo -n ' nfsd';		nfsd -tun 4
  fi
  
! # $nfs_client is imported from /etc/rc.conf;
  # if $nfs_client == YES, the machine is setup for being an nfs client
  if [ X${nfs_client} = X"YES" ]; then
  	echo -n ' nfsiod';		nfsiod -n 4
***************
*** 121,127 ****
  rm -f /dev/log
  syslogd
  
! # $timed_flags is imported from /etc/netstart;
  # if $timed_flags == NO, timed isn't run.
  if [ "X${timed_flags}" != X"NO" ]; then
  	echo -n ', time daemon'; timed $timed_flags
--- 124,130 ----
  rm -f /dev/log
  syslogd
  
! # $timed_flags is imported from /etc/rc.conf;
  # if $timed_flags == NO, timed isn't run.
  if [ "X${timed_flags}" != X"NO" ]; then
  	echo -n ', time daemon'; timed $timed_flags
***************
*** 181,187 ****
  
  echo -n starting network daemons:
  
! # $gated and $routed_flags are imported from /etc/netstart.
  # If $gated == YES, gated is used; otherwise routed.
  # If $routed_flags == NO, routed isn't run.
  if [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
--- 184,190 ----
  
  echo -n starting network daemons:
  
! # $gated and $routed_flags are imported from /etc/rc.conf.
  # If $gated == YES, gated is used; otherwise routed.
  # If $routed_flags == NO, routed isn't run.
  if [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
***************
*** 190,208 ****
  	echo -n ' routed';		routed $routed_flags
  fi
  
! # $mrouted_flags is imported from /etc/netstart;
! # If $mrouted_flags == NO, then mrouted isn't run.
  if [ "X${mrouted_flags}" != X"NO" ]; then
  	echo -n ' mrouted';		mrouted $mrouted_flags
  fi
  
! # $named_flags is imported from /etc/netstart;
  # if $named_flags != NO, named is run.
  if [ "X${named_flags}" != X"NO" ]; then
  	echo -n ' named';		named $named_flags
  fi
  
! # $rwhod is imported from /etc/netstart;
  # if $rwhod == YES, rwhod is run.
  if [ X${rwhod} = X"YES" ]; then
  	echo -n ' rwhod';		rwhod
--- 193,211 ----
  	echo -n ' routed';		routed $routed_flags
  fi
  
! # $mrouted_flags is imported from /etc/rc.conf;
! # If $mrouted_flags != NO, then mrouted is run.
  if [ "X${mrouted_flags}" != X"NO" ]; then
  	echo -n ' mrouted';		mrouted $mrouted_flags
  fi
  
! # $name_flags is imported from /etc/rc.conf;
  # if $named_flags != NO, named is run.
  if [ "X${named_flags}" != X"NO" ]; then
  	echo -n ' named';		named $named_flags
  fi
  
! # $rwhod is imported from /etc/rc.conf;
  # if $rwhod == YES, rwhod is run.
  if [ X${rwhod} = X"YES" ]; then
  	echo -n ' rwhod';		rwhod
***************
*** 210,216 ****
  
  echo -n ' printer';		lpd
  
! # $sendmail_flags is imported from /etc/netstart;
  # If $sendmail_flags == NO or /etc/sendmail.cf doesn't exist, then
  # sendmail isn't run.
  if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
--- 213,219 ----
  
  echo -n ' printer';		lpd
  
! # $sendmail_flags is imported from /etc/rc.conf;
  # If $sendmail_flags == NO or /etc/sendmail.cf doesn't exist, then
  # sendmail isn't run.
  if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
***************
*** 219,239 ****
  
  echo -n ' inetd';		inetd
  
! # $rarpd_flags is imported from /etc/netstart;
  # If $rarpd_flags == NO or /etc/ethers doesn't exist, then
  # rarpd isn't run.
  if [ "X${rarpd_flags}" != X"NO" -a -r /etc/ethers ]; then
  	echo -n ' rarpd';		rarpd ${rarpd_flags}
  fi
  
! # $bootparamd_flags is imported from /etc/netstart;
  # If $bootparamd_flags == NO or /etc/bootparams doesn't exist, then
  # bootparamd isn't run.
  if [ "X${bootparamd_flags}" != X"NO" -a -r /etc/bootparams ]; then
  	echo -n ' rpc.bootparamd';	rpc.bootparamd ${bootparamd_flags}
  fi
  
! # $rbootd_flags is imported from /etc/netstart;
  # If $rbootd_flags == NO or /etc/rbootd.conf doesn't exist, then
  # rbootd isn't run.
  if [ "X${rbootd_flags}" != X"NO" -a -r /etc/rbootd.conf ]; then
--- 222,242 ----
  
  echo -n ' inetd';		inetd
  
! # $rarpd_flags is imported from /etc/rc.conf;
  # If $rarpd_flags == NO or /etc/ethers doesn't exist, then
  # rarpd isn't run.
  if [ "X${rarpd_flags}" != X"NO" -a -r /etc/ethers ]; then
  	echo -n ' rarpd';		rarpd ${rarpd_flags}
  fi
  
! # $bootparamd_flags is imported from /etc/rc.conf;
  # If $bootparamd_flags == NO or /etc/bootparams doesn't exist, then
  # bootparamd isn't run.
  if [ "X${bootparamd_flags}" != X"NO" -a -r /etc/bootparams ]; then
  	echo -n ' rpc.bootparamd';	rpc.bootparamd ${bootparamd_flags}
  fi
  
! # $rbootd_flags is imported from /etc/rc.conf;
  # If $rbootd_flags == NO or /etc/rbootd.conf doesn't exist, then
  # rbootd isn't run.
  if [ "X${rbootd_flags}" != X"NO" -a -r /etc/rbootd.conf ]; then
diff --new-file -c /tmp/etc/rc.conf.eg etc/rc.conf.eg
*** /tmp/etc/rc.conf.eg	Thu Jan  1 10:00:00 1970
--- etc/rc.conf.eg	Tue Jan 16 15:04:07 1996
***************
*** 0 ****
--- 1,54 ----
+ #
+ # Host specific configuration information
+ #
+ # $NetBSD$
+ #
+ 
+ # primary hostname
+ #
+ hostname=myname
+ 
+ # domainname for DNS and NIS
+ #
+ domainname=my.domain
+ 
+ # interfaces
+ # for each WORD in $interfaces, set the following variables:
+ # - interface_WORD	addr_family hostaddr [netmask [broadcast [options]]]
+ # - destination_WORD	[dest_addr]
+ # - ifaliases_WORD	[alias_addr [alias_addr ...]]
+ #
+ interfaces="ed0 le0"
+ interface_ed0="inet 192.168.1.2"
+ interface_le0="inet 192.168.1.3"
+ 
+ # default route. don't define if you don't want it
+ #
+ defaultroute=192.168.1.1
+ 
+ # set these to "NO" to turn them off.  otherwise, they're used as flags
+ #
+ routed_flags=-q
+ mrouted_flags=NO	# for 'normal' use: mrouted_flags=""
+ rarpd_flags=NO		# for 'normal' use: rarpd_flags="-a"
+ bootparamd_flags=NO	# for 'normal' use: bootparamd_flags=""
+ rbootd_flags=NO		# for 'normal' use: rbootd_flags=""
+ sendmail_flags=NO	# for 'normal' use: sendmail_flags="-bd -q30m"
+ named_flags=NO		# for 'normal' use: named_flags=""
+ timed_flags=
+ 
+ # set the following to "YES" to turn them on
+ #
+ rwhod=NO
+ nfs_server=NO
+ nfs_client=NO
+ gated=NO
+ kerberos_server=NO
+ amd=NO
+ 
+ # miscellaneous other flags
+ # only used if the appropriate server is marked YES above
+ #
+ gated_flags=
+ amd_dir=/amd			# AMD's mount directory
+ amd_master=/etc/amd/master	# AMD 'master' map
>Audit-Trail:
>Unformatted: