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