Home | History | Annotate | Line # | Download | only in etc
rc revision 1.65
      1 #	$NetBSD: rc,v 1.65 1997/02/15 10:02:25 mikel Exp $
      2 #	from: @(#)rc	8.2 (Berkeley) 3/17/94
      3 
      4 # System startup script run by init on autoboot
      5 # or after single-user.
      6 # Output and error are redirected to console by init,
      7 # and the console is the controlling terminal.
      8 
      9 stty status '^T'
     10 
     11 # Set shell to ignore SIGINT (2), but not children;
     12 # shell catches SIGQUIT (3) and returns to single user after fsck.
     13 trap : 2
     14 trap : 3	# shouldn't be needed
     15 
     16 HOME=/; export HOME
     17 PATH=/sbin:/bin:/usr/sbin:/usr/bin
     18 export PATH
     19 
     20 # Configure ccd devices.
     21 if [ -f /etc/ccd.conf ]; then
     22 	ccdconfig -C
     23 fi
     24 
     25 if [ -e /fastboot ]; then
     26 	echo "Fast boot: skipping disk checks."
     27 elif [ $1x = autobootx ]; then
     28 	echo "Automatic boot in progress: starting file system checks."
     29 	fsck -p
     30 	case $? in
     31 	0)
     32 		;;
     33 	2)
     34 		exit 1
     35 		;;
     36 	4)
     37 		echo "Rebooting..."
     38 		reboot
     39 		echo "Reboot failed; help!"
     40 		exit 1
     41 		;;
     42 	8)
     43 		echo "Automatic file system check failed; help!"
     44 		exit 1
     45 		;;
     46 	12)
     47 		echo "Boot interrupted."
     48 		exit 1
     49 		;;
     50 	130)
     51 		# interrupt before catcher installed
     52 		exit 1
     53 		;;
     54 	*)
     55 		echo "Unknown error; help!"
     56 		exit 1
     57 		;;
     58 	esac
     59 fi
     60 
     61 trap "echo 'Boot interrupted.'; exit 1" 3
     62 
     63 swapon -a
     64 
     65 umount -a >/dev/null 2>&1
     66 mount -a -t nonfs
     67 rm -f /fastboot		# XXX (root now writeable)
     68 
     69 if [ -s /etc/rc.conf ]; then
     70 	. /etc/rc.conf
     71 fi
     72 
     73 # set flags on ttys.  (do early, in case they use tty for SLIP in netstart)
     74 echo 'setting tty flags'
     75 ttyflags -a
     76 
     77 # load any kernel modules specified in /etc/lkm.conf
     78 if [ X"$lkm_init" != XNO -a -f /etc/rc.lkm ]; then
     79 	. /etc/rc.lkm
     80 fi
     81 
     82 # set hostname, turn on network
     83 echo 'starting network'
     84 . /etc/netstart
     85 
     86 mount /usr >/dev/null 2>&1
     87 mount /var >/dev/null 2>&1
     88 
     89 # clean up left-over files
     90 rm -f /etc/nologin
     91 rm -f /var/spool/lock/LCK.*
     92 rm -f /var/spool/uucp/STST/*
     93 (cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; })
     94 
     95 # start the system logger first, so that all messages
     96 # from daemons are logged, and the name server next.
     97 
     98 if [ "X$syslogd_flags" != XNO ]; then
     99 	echo 'starting system logger'
    100 	rm -f /dev/log
    101 	syslogd $syslogd_flags
    102 fi
    103 
    104 if [ "X$named_flags" != XNO ]; then
    105 	echo 'starting name server';	named $named_flags
    106 fi
    107 
    108 # now start the rpc servers, for YP server/client, NFS.
    109 echo -n 'starting rpc daemons:'
    110 
    111 # note that portmap is generally required for all other rpc services.
    112 if [ "X$portmap" != XNO ]; then
    113 	echo -n ' portmap';             portmap
    114 fi
    115 
    116 if [ "X$ypserv_flags" != XNO ]; then
    117         echo -n ' ypserv';              ypserv $ypserv_flags
    118 fi
    119 
    120 if [ "X$ypbind_flags" != XNO ]; then
    121         echo -n ' ypbind';              ypbind $ypbind_flags
    122 fi
    123 
    124 if [ "X$yppasswdd_flags" != XNO ]; then
    125         echo -n ' rpc.yppasswdd';       rpc.yppasswdd $yppasswdd_flags
    126 fi
    127 
    128 if [ "X$bootparamd_flags" != XNO -a -r /etc/bootparams ]; then
    129         echo -n ' rpc.bootparamd';      rpc.bootparamd $bootparamd_flags
    130 fi
    131 
    132 if [ "X$nfs_server" = XYES -a -r /etc/exports ]; then
    133 	if [ "X$nfsd_flags" = X ]; then
    134 		nfsd_flags="-tun 4"
    135 	fi
    136         rm -f /var/db/mountdtab
    137         echo -n > /var/db/mountdtab
    138         echo -n ' mountd';              mountd $mountd_flags
    139         echo -n ' nfsd';                nfsd $nfsd_flags
    140 fi
    141 
    142 if [ "X$nfs_client" = XYES ]; then
    143 	if [ "X$nfsiod_flags" = X ]; then
    144 		nfsiod_flags="-n 4"
    145 	fi
    146         echo -n ' nfsiod';              nfsiod $nfsiod_flags
    147 fi
    148 
    149 if [ "X$amd" = XYES -a -d "$amd_dir" -a -r "$amd_master" ]; then
    150         echo -n ' amd'
    151         amd $amd_flags -p -a $amd_dir `cat $amd_master` > /var/run/amd.pid
    152 fi
    153 
    154 echo '.'
    155 mount -a -t nfs
    156 
    157 if [ -f /sbin/ldconfig ]; then
    158 	echo 'creating runtime link editor directory cache.'
    159 	if [ -s /etc/ld.so.conf ]; then
    160 		ldconfig `cat /etc/ld.so.conf`
    161 	else
    162 		ldconfig
    163 	fi
    164 fi 
    165 
    166 # /var/crash should be a directory or a symbolic link
    167 # to the crash directory if core dumps are to be saved.
    168 if [ X"$savecore_flags" != XNO -a -d /var/crash ]; then
    169 	echo checking for core dump...
    170 	savecore $savecore_flags /var/crash
    171 fi
    172 
    173 				echo -n 'checking quotas:'
    174 quotacheck -a
    175 				echo ' done.'
    176 quotaon -a
    177 
    178 # build ps databases
    179 echo 'building databases...'
    180 kvm_mkdb /netbsd
    181 dev_mkdb
    182 
    183 chmod 666 /dev/tty[pqrs]*
    184 
    185 # check the password temp/lock file
    186 if [ -f /etc/ptmp ]
    187 then
    188 	logger -s -p auth.err \
    189 	'password file may be incorrect -- /etc/ptmp exists'
    190 fi
    191 
    192 virecovery=/var/tmp/vi.recover/recover.*
    193 if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
    194 	echo preserving editor files
    195 	for i in $virecovery; do
    196 		sendmail -t < $i
    197 	done
    198 fi
    199 
    200 echo clearing /tmp
    201 
    202 # Prune quickly with one rm, then use find to clean up /tmp/[lq]* (this
    203 # is not needed with mfs /tmp, but doesn't hurt anything).
    204 (cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
    205     find . ! -name . ! -name lost+found ! -name quota.user \
    206 	! -name quota.group -exec rm -rf -- {} \; -type d -prune)
    207 
    208 if [ -f /var/account/acct ]; then
    209 	echo 'turning on accounting';	accton /var/account/acct
    210 fi
    211 
    212 echo -n standard daemons:
    213 echo -n ' update';		update
    214 echo -n ' cron';		cron
    215 echo '.'
    216 
    217 # now start all the other daemons
    218 echo -n starting network daemons:
    219 
    220 if [ X$gated_flags != XNO -a -r /etc/gated.conf ]; then
    221 	echo -n ' gated';		gated $gated_flags
    222 elif [ "X$routed_flags" != XNO ]; then
    223 	echo -n ' routed';		routed $routed_flags
    224 fi
    225 
    226 if [ "X$mrouted_flags" != XNO ]; then
    227 	echo -n ' mrouted';		mrouted $mrouted_flags
    228 fi
    229 
    230 if [ "X$timed_flags" != XNO ]; then
    231 	echo -n ' time daemon'; 	timed $timed_flags
    232 fi
    233 
    234 if [ "X$xntpd_flags" != XNO ]; then
    235 	echo -n ' ntp daemon';		xntpd $xntpd_flags
    236 fi
    237 
    238 if [ "X$dhcpd_flags" != XNO -a -r /etc/dhcpd.conf ]; then
    239 	echo -n ' dhcpd';		dhcpd $dhcpd_flags
    240 fi
    241 
    242 if [ X$rwhod = XYES ]; then
    243 	echo -n ' rwhod';		rwhod
    244 fi
    245 
    246 if [ "X$lpd_flags" != XNO ]; then
    247 	echo -n ' printer';		lpd $lpd_flags
    248 fi
    249 
    250 # We call sendmail with a full path so that SIGHUP works.
    251 if [ "X$sendmail_flags" != XNO -a -r /etc/sendmail.cf ]; then
    252 	echo -n ' sendmail';		/usr/sbin/sendmail $sendmail_flags
    253 fi
    254 
    255 if [ "X$rarpd_flags" != XNO -a -r /etc/ethers ]; then
    256 	echo -n ' rarpd';		rarpd $rarpd_flags
    257 fi
    258 
    259 if [ "X$rbootd_flags" != XNO -a -r /etc/rbootd.conf ]; then
    260 	echo -n ' rbootd';		rbootd $rbootd_flags
    261 fi
    262 
    263 if [ "X$inetd_flags" != XNO -a -r /etc/inetd.conf ]; then
    264 	echo -n ' inetd';		inetd $inetd_flags
    265 fi
    266 
    267 echo '.'
    268 
    269 . /etc/rc.local
    270 
    271 date
    272 exit 0
    273