Home | History | Annotate | Line # | Download | only in etc
rc revision 1.74
      1  1.74    perry #	$NetBSD: rc,v 1.74 1997/04/23 01:24:22 perry Exp $
      2  1.73    perry #	originally from: @(#)rc	8.2 (Berkeley) 3/17/94
      3   1.1      cgd 
      4   1.1      cgd # System startup script run by init on autoboot
      5   1.1      cgd # or after single-user.
      6   1.1      cgd # Output and error are redirected to console by init,
      7   1.1      cgd # and the console is the controlling terminal.
      8   1.1      cgd 
      9   1.1      cgd stty status '^T'
     10   1.1      cgd 
     11   1.1      cgd # Set shell to ignore SIGINT (2), but not children;
     12   1.1      cgd # shell catches SIGQUIT (3) and returns to single user after fsck.
     13   1.1      cgd trap : 2
     14   1.1      cgd trap : 3	# shouldn't be needed
     15   1.1      cgd 
     16  1.68  mycroft export HOME=/
     17  1.68  mycroft export PATH=/sbin:/bin:/usr/sbin:/usr/bin
     18  1.50  thorpej 
     19  1.50  thorpej # Configure ccd devices.
     20  1.63      mrg if [ -f /etc/ccd.conf ]; then
     21  1.50  thorpej 	ccdconfig -C
     22  1.50  thorpej fi
     23   1.1      cgd 
     24  1.63      mrg if [ -e /fastboot ]; then
     25  1.38      cgd 	echo "Fast boot: skipping disk checks."
     26  1.68  mycroft elif [ "$1" = autoboot ]; then
     27  1.38      cgd 	echo "Automatic boot in progress: starting file system checks."
     28   1.1      cgd 	fsck -p
     29   1.1      cgd 	case $? in
     30   1.1      cgd 	0)
     31   1.1      cgd 		;;
     32   1.1      cgd 	2)
     33   1.1      cgd 		exit 1
     34   1.1      cgd 		;;
     35   1.1      cgd 	4)
     36  1.35      cgd 		echo "Rebooting..."
     37   1.1      cgd 		reboot
     38  1.38      cgd 		echo "Reboot failed; help!"
     39   1.1      cgd 		exit 1
     40   1.1      cgd 		;;
     41   1.1      cgd 	8)
     42  1.38      cgd 		echo "Automatic file system check failed; help!"
     43   1.1      cgd 		exit 1
     44   1.1      cgd 		;;
     45   1.1      cgd 	12)
     46  1.38      cgd 		echo "Boot interrupted."
     47   1.1      cgd 		exit 1
     48   1.1      cgd 		;;
     49   1.1      cgd 	130)
     50   1.1      cgd 		# interrupt before catcher installed
     51   1.1      cgd 		exit 1
     52   1.1      cgd 		;;
     53   1.1      cgd 	*)
     54  1.38      cgd 		echo "Unknown error; help!"
     55   1.1      cgd 		exit 1
     56   1.1      cgd 		;;
     57   1.1      cgd 	esac
     58   1.1      cgd fi
     59   1.1      cgd 
     60  1.38      cgd trap "echo 'Boot interrupted.'; exit 1" 3
     61   1.1      cgd 
     62   1.1      cgd swapon -a
     63   1.1      cgd 
     64   1.1      cgd umount -a >/dev/null 2>&1
     65   1.1      cgd mount -a -t nonfs
     66   1.1      cgd rm -f /fastboot		# XXX (root now writeable)
     67  1.40      cgd 
     68  1.71  mycroft if [ -f /etc/rc.conf ]; then
     69  1.63      mrg 	. /etc/rc.conf
     70  1.63      mrg fi
     71  1.63      mrg 
     72  1.40      cgd # set flags on ttys.  (do early, in case they use tty for SLIP in netstart)
     73  1.40      cgd echo 'setting tty flags'
     74  1.40      cgd ttyflags -a
     75   1.1      cgd 
     76  1.63      mrg # load any kernel modules specified in /etc/lkm.conf
     77  1.67  mycroft if [ "$lkm_init" != NO ] && [ -f /etc/rc.lkm ]; then
     78  1.63      mrg 	. /etc/rc.lkm
     79  1.63      mrg fi
     80  1.63      mrg 
     81   1.1      cgd # set hostname, turn on network
     82   1.1      cgd echo 'starting network'
     83   1.1      cgd . /etc/netstart
     84   1.1      cgd 
     85  1.26  deraadt mount /usr >/dev/null 2>&1
     86  1.42  mycroft mount /var >/dev/null 2>&1
     87  1.26  deraadt 
     88  1.41      jtc # clean up left-over files
     89  1.41      jtc rm -f /etc/nologin
     90  1.41      jtc rm -f /var/spool/lock/LCK.*
     91  1.41      jtc rm -f /var/spool/uucp/STST/*
     92  1.45      cgd (cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; })
     93  1.41      jtc 
     94  1.63      mrg # start the system logger first, so that all messages
     95  1.63      mrg # from daemons are logged, and the name server next.
     96  1.63      mrg 
     97  1.67  mycroft if [ "$syslogd_flags" != NO ]; then
     98  1.67  mycroft 	if [ "$syslogd_flags" = DEFAULT ]; then
     99  1.67  mycroft 		syslogd_flags=""
    100  1.67  mycroft 	fi
    101  1.63      mrg 	echo 'starting system logger'
    102  1.63      mrg 	rm -f /dev/log
    103  1.63      mrg 	syslogd $syslogd_flags
    104  1.63      mrg fi
    105  1.63      mrg 
    106  1.67  mycroft if [ "$named_flags" != NO ]; then
    107  1.67  mycroft 	if [ "$named_flags" = DEFAULT ]; then
    108  1.67  mycroft 		named_flags=""
    109  1.67  mycroft 	fi
    110  1.63      mrg 	echo 'starting name server';	named $named_flags
    111  1.63      mrg fi
    112  1.63      mrg 
    113  1.63      mrg # now start the rpc servers, for YP server/client, NFS.
    114  1.63      mrg echo -n 'starting rpc daemons:'
    115  1.63      mrg 
    116  1.63      mrg # note that portmap is generally required for all other rpc services.
    117  1.67  mycroft if [ "$portmap" != NO ]; then
    118  1.63      mrg 	echo -n ' portmap';             portmap
    119  1.63      mrg fi
    120  1.63      mrg 
    121  1.67  mycroft if [ "$ypserv_flags" != NO ]; then
    122  1.67  mycroft 	if [ "$ypserv_flags" = DEFAULT ]; then
    123  1.67  mycroft 		ypserv_flags="-d"
    124  1.67  mycroft 	fi
    125  1.63      mrg         echo -n ' ypserv';              ypserv $ypserv_flags
    126  1.63      mrg fi
    127  1.63      mrg 
    128  1.67  mycroft if [ "$ypbind_flags" != NO ]; then
    129  1.67  mycroft 	if [ "$ypbind_flags" = DEFAULT ]; then
    130  1.67  mycroft 		ypbind_flags=""
    131  1.67  mycroft 	fi
    132  1.63      mrg         echo -n ' ypbind';              ypbind $ypbind_flags
    133  1.63      mrg fi
    134  1.63      mrg 
    135  1.67  mycroft if [ "$yppasswdd_flags" != NO ]; then
    136  1.67  mycroft 	if [ "$yppasswdd_flags" = DEFAULT ]; then
    137  1.67  mycroft 		yppasswdd_flags=""
    138  1.67  mycroft 	fi
    139  1.63      mrg         echo -n ' rpc.yppasswdd';       rpc.yppasswdd $yppasswdd_flags
    140  1.63      mrg fi
    141  1.63      mrg 
    142  1.67  mycroft if [ "$bootparamd_flags" != NO ] && [ -r /etc/bootparams ]; then
    143  1.67  mycroft 	if [ "$bootparamd_flags" = DEFAULT ]; then
    144  1.67  mycroft 		bootparamd_flags=""
    145  1.67  mycroft 	fi
    146  1.63      mrg         echo -n ' rpc.bootparamd';      rpc.bootparamd $bootparamd_flags
    147  1.63      mrg fi
    148  1.63      mrg 
    149  1.67  mycroft nfs_locking=NO
    150  1.67  mycroft 
    151  1.67  mycroft if [ "$nfs_server" = YES ] && [ -r /etc/exports ]; then
    152  1.69  mycroft 	if [ "$mountd_flags" = DEFAULT ]; then
    153  1.69  mycroft 		mountd_flags=""
    154  1.63      mrg 	fi
    155  1.63      mrg         rm -f /var/db/mountdtab
    156  1.63      mrg         echo -n > /var/db/mountdtab
    157  1.63      mrg         echo -n ' mountd';              mountd $mountd_flags
    158  1.69  mycroft 	if [ "$nfsd_flags" = DEFAULT ]; then
    159  1.69  mycroft 		nfsd_flags="-tun 4"
    160  1.69  mycroft 	fi
    161  1.63      mrg         echo -n ' nfsd';                nfsd $nfsd_flags
    162  1.67  mycroft 	nfs_locking=MAYBE
    163   1.1      cgd fi
    164  1.63      mrg 
    165  1.67  mycroft if [ "$nfs_client" = YES ]; then
    166  1.67  mycroft 	if [ "$nfsiod_flags" = DEFAULT ]; then
    167  1.63      mrg 		nfsiod_flags="-n 4"
    168  1.63      mrg 	fi
    169  1.63      mrg         echo -n ' nfsiod';              nfsiod $nfsiod_flags
    170  1.67  mycroft 	nfs_locking=MAYBE
    171  1.66   scottr fi
    172  1.66   scottr 
    173  1.67  mycroft if [ "$nfs_locking" != NO ]; then
    174  1.67  mycroft 	if [ "$statd_flags" != NO ]; then
    175  1.67  mycroft 		if [ "$statd_flags" = DEFAULT ]; then
    176  1.67  mycroft 			statd_flags=""
    177  1.67  mycroft 		fi
    178  1.71  mycroft 		echo -n ' rpc.statd';		rpc.statd $statd_flags
    179  1.66   scottr 	fi
    180  1.66   scottr 
    181  1.67  mycroft 	if [ "$lockd_flags" != NO ]; then
    182  1.67  mycroft 		if [ "$lockd_flags" = DEFAULT ]; then
    183  1.67  mycroft 			lockd_flags=""
    184  1.67  mycroft 		fi
    185  1.71  mycroft 		echo -n ' rpc.lockd';		rpc.lockd $lockd_flags
    186  1.66   scottr 	fi
    187  1.63      mrg fi
    188  1.63      mrg 
    189  1.67  mycroft if [ "$amd_flags" != NO ] && [ -d "$amd_dir" -a -r "$amd_master" ]; then
    190  1.67  mycroft 	if [ "$amd_flags" = DEFAULT ]; then
    191  1.67  mycroft 		amd_flags="-l syslog -x error,noinfo,nostats"
    192  1.67  mycroft 	fi
    193  1.63      mrg         echo -n ' amd'
    194  1.63      mrg         amd $amd_flags -p -a $amd_dir `cat $amd_master` > /var/run/amd.pid
    195  1.63      mrg fi
    196  1.63      mrg 
    197   1.1      cgd echo '.'
    198  1.63      mrg mount -a -t nfs
    199  1.63      mrg 
    200  1.63      mrg if [ -f /sbin/ldconfig ]; then
    201  1.63      mrg 	echo 'creating runtime link editor directory cache.'
    202  1.71  mycroft 	if [ -f /etc/ld.so.conf ]; then
    203  1.63      mrg 		ldconfig `cat /etc/ld.so.conf`
    204  1.63      mrg 	else
    205  1.63      mrg 		ldconfig
    206  1.63      mrg 	fi
    207  1.63      mrg fi 
    208   1.1      cgd 
    209   1.1      cgd # /var/crash should be a directory or a symbolic link
    210   1.1      cgd # to the crash directory if core dumps are to be saved.
    211  1.67  mycroft if [ "$savecore_flags" != NO ] && [ -d /var/crash ]; then
    212  1.67  mycroft 	if [ "$savecore_flags" = DEFAULT ]; then
    213  1.67  mycroft 		savecore_flags=""
    214  1.67  mycroft 	fi
    215   1.1      cgd 	echo checking for core dump...
    216  1.63      mrg 	savecore $savecore_flags /var/crash
    217   1.1      cgd fi
    218   1.1      cgd 
    219  1.47  deraadt 				echo -n 'checking quotas:'
    220  1.47  deraadt quotacheck -a
    221  1.47  deraadt 				echo ' done.'
    222  1.47  deraadt quotaon -a
    223   1.1      cgd 
    224   1.1      cgd # build ps databases
    225   1.2      cgd echo 'building databases...'
    226  1.11      cgd kvm_mkdb /netbsd
    227   1.1      cgd dev_mkdb
    228   1.1      cgd 
    229   1.1      cgd chmod 666 /dev/tty[pqrs]*
    230   1.1      cgd 
    231   1.1      cgd # check the password temp/lock file
    232   1.1      cgd if [ -f /etc/ptmp ]
    233   1.1      cgd then
    234   1.1      cgd 	logger -s -p auth.err \
    235   1.1      cgd 	'password file may be incorrect -- /etc/ptmp exists'
    236   1.1      cgd fi
    237   1.1      cgd 
    238  1.32  mycroft virecovery=/var/tmp/vi.recover/recover.*
    239  1.32  mycroft if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
    240  1.32  mycroft 	echo preserving editor files
    241  1.32  mycroft 	for i in $virecovery; do
    242  1.32  mycroft 		sendmail -t < $i
    243  1.32  mycroft 	done
    244  1.32  mycroft fi
    245   1.1      cgd 
    246   1.1      cgd echo clearing /tmp
    247   1.1      cgd 
    248  1.65    mikel # Prune quickly with one rm, then use find to clean up /tmp/[lq]* (this
    249  1.65    mikel # is not needed with mfs /tmp, but doesn't hurt anything).
    250   1.1      cgd (cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
    251  1.46  deraadt     find . ! -name . ! -name lost+found ! -name quota.user \
    252  1.46  deraadt 	! -name quota.group -exec rm -rf -- {} \; -type d -prune)
    253   1.1      cgd 
    254  1.74    perry # Update kernel info in /etc/motd
    255  1.74    perry # Must be done *before* interactive logins are possible to prevent
    256  1.74    perry # possible race conditions.
    257  1.74    perry if [ "$update_motd" != NO ]; then
    258  1.74    perry 	echo 'updating motd.'
    259  1.74    perry 	if [ ! -f /etc/motd ]; then
    260  1.74    perry 		install -c -o root -g wheel -m 664 /dev/null /etc/motd
    261  1.74    perry 	fi
    262  1.74    perry 	T=/tmp/_motd
    263  1.74    perry 	rm -f $T
    264  1.74    perry 	sysctl -n kern.version | sed 1q > $T
    265  1.74    perry 	echo "" >> $T
    266  1.74    perry 	sed '1,/^$/d' < /etc/motd >> $T
    267  1.74    perry 	cmp -s $T /etc/motd || cp $T /etc/motd
    268  1.74    perry 	rm -f $T
    269  1.74    perry fi
    270  1.74    perry 
    271  1.34      cgd if [ -f /var/account/acct ]; then
    272  1.34      cgd 	echo 'turning on accounting';	accton /var/account/acct
    273  1.34      cgd fi
    274   1.1      cgd 
    275   1.1      cgd echo -n standard daemons:
    276  1.70  mycroft if [ "$update_flags" != NO ]; then
    277  1.70  mycroft 	if [ "$update_flags" = DEFAULT ]; then
    278  1.70  mycroft 		update_flags="30"
    279  1.70  mycroft 	fi
    280  1.70  mycroft 	echo -n ' update';		update $update_flags
    281  1.70  mycroft fi
    282  1.31      jtc echo -n ' cron';		cron
    283   1.1      cgd echo '.'
    284   1.1      cgd 
    285  1.63      mrg # now start all the other daemons
    286   1.1      cgd echo -n starting network daemons:
    287   1.1      cgd 
    288  1.67  mycroft if [ "$gated_flags" != NO ] && [ -r /etc/gated.conf ]; then
    289  1.67  mycroft 	if [ "$gated_flags" = DEFAULT ]; then
    290  1.67  mycroft 		gated_flags=""
    291  1.67  mycroft 	fi
    292  1.48  mycroft 	echo -n ' gated';		gated $gated_flags
    293  1.67  mycroft elif [ "$routed_flags" != NO ]; then
    294  1.67  mycroft 	if [ "$routed_flags" = DEFAULT ]; then
    295  1.67  mycroft 		routed_flags="-q"
    296  1.67  mycroft 	fi
    297  1.48  mycroft 	echo -n ' routed';		routed $routed_flags
    298   1.1      cgd fi
    299   1.1      cgd 
    300  1.67  mycroft if [ "$mrouted_flags" != NO ]; then
    301  1.67  mycroft 	if [ "$mrouted_flags" = DEFAULT ]; then
    302  1.67  mycroft 		mrouted_flags=""
    303  1.67  mycroft 	fi
    304  1.55  thorpej 	echo -n ' mrouted';		mrouted $mrouted_flags
    305  1.55  thorpej fi
    306  1.55  thorpej 
    307  1.67  mycroft if [ "$timed_flags" != NO ]; then
    308  1.67  mycroft 	if [ "$timed_flags" = DEFAULT ]; then
    309  1.67  mycroft 		timed_flags=""
    310  1.67  mycroft 	fi
    311  1.67  mycroft 	echo -n ' timed'; 		timed $timed_flags
    312  1.63      mrg fi
    313  1.63      mrg 
    314  1.67  mycroft if [ "$xntpd_flags" != NO ]; then
    315  1.67  mycroft 	if [ "$xntpd_flags" = DEFAULT ]; then
    316  1.67  mycroft 		xntpd_flags=""
    317  1.67  mycroft 	fi
    318  1.67  mycroft 	echo -n ' xntpd';		xntpd $xntpd_flags
    319  1.61      mrg fi
    320  1.61      mrg 
    321  1.67  mycroft if [ "$dhcpd_flags" != NO ] && [ -r /etc/dhcpd.conf ]; then
    322  1.67  mycroft 	if [ "$dhcpd_flags" = DEFAULT ]; then
    323  1.67  mycroft 		dhcpd_flags=""
    324  1.67  mycroft 	fi
    325  1.61      mrg 	echo -n ' dhcpd';		dhcpd $dhcpd_flags
    326  1.29  mycroft fi
    327  1.29  mycroft 
    328  1.67  mycroft if [ "$rwhod" = YES ]; then
    329  1.48  mycroft 	echo -n ' rwhod';		rwhod
    330   1.1      cgd fi
    331   1.1      cgd 
    332  1.67  mycroft if [ "$lpd_flags" != NO ]; then
    333  1.67  mycroft 	if [ "$lpd_flags" = DEFAULT ]; then
    334  1.67  mycroft 		lpd_flags=""
    335  1.67  mycroft 	fi
    336  1.63      mrg 	echo -n ' printer';		lpd $lpd_flags
    337  1.60      tls fi
    338  1.60      tls 
    339  1.63      mrg # We call sendmail with a full path so that SIGHUP works.
    340  1.67  mycroft if [ "$sendmail_flags" != NO ] && [ -r /etc/sendmail.cf ]; then
    341  1.67  mycroft 	if [ "$sendmail_flags" = DEFAULT ]; then
    342  1.67  mycroft 		sendmail_flags="-bd -q30m"
    343  1.67  mycroft 	fi
    344  1.63      mrg 	echo -n ' sendmail';		/usr/sbin/sendmail $sendmail_flags
    345  1.60      tls fi
    346  1.60      tls 
    347  1.67  mycroft if [ "$rarpd_flags" != NO ] && [ -r /etc/ethers ]; then
    348  1.67  mycroft 	if [ "$rarpd_flags" = DEFAULT ]; then
    349  1.67  mycroft 		rarpd_flags="-a"
    350  1.67  mycroft 	fi
    351  1.63      mrg 	echo -n ' rarpd';		rarpd $rarpd_flags
    352  1.60      tls fi
    353  1.60      tls 
    354  1.67  mycroft if [ "$rbootd_flags" != NO ] && [ -r /etc/rbootd.conf ]; then
    355  1.67  mycroft 	if [ "$rbootd_flags" = DEFAULT ]; then
    356  1.67  mycroft 		rbootd_flags=""
    357  1.67  mycroft 	fi
    358  1.63      mrg 	echo -n ' rbootd';		rbootd $rbootd_flags
    359  1.72      cjs fi
    360  1.72      cjs 
    361  1.72      cjs if [ "$mopd_flags" != NO ]; then
    362  1.72      cjs 	if [ "$mopd_flags" = DEFAULT ]; then
    363  1.72      cjs 		mopd_flags="-a"
    364  1.72      cjs 	fi
    365  1.72      cjs 	echo -n ' mopd';		mopd $mopd_flags
    366  1.52  thorpej fi
    367  1.52  thorpej 
    368  1.67  mycroft if [ "$inetd_flags" != NO ] && [ -r /etc/inetd.conf ]; then
    369  1.67  mycroft 	if [ "$inetd_flags" = DEFAULT ]; then
    370  1.67  mycroft 		inetd_flags=""
    371  1.67  mycroft 	fi
    372  1.63      mrg 	echo -n ' inetd';		inetd $inetd_flags
    373  1.30  mycroft fi
    374  1.30  mycroft 
    375   1.1      cgd echo '.'
    376  1.73    perry 
    377  1.73    perry # Kerberos runs ONLY on the Kerberos server machine
    378  1.73    perry if [ "$kerberos_server" = YES ]; then
    379  1.73    perry 	echo -n 'starting kerberos daemons:'
    380  1.73    perry 	echo -n ' kerberos';	kerberos >> /var/log/kerberos.log &
    381  1.73    perry 	echo -n ' kadmind';	kadmind -n >> /var/log/kadmind.log &
    382  1.73    perry 	echo '.'
    383  1.73    perry fi
    384   1.1      cgd 
    385  1.25  mycroft . /etc/rc.local
    386   1.1      cgd 
    387   1.1      cgd date
    388   1.1      cgd exit 0
    389