Home | History | Annotate | Line # | Download | only in etc
rc revision 1.68
      1 #	$NetBSD: rc,v 1.68 1997/03/10 09:34:59 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 [ "$nfsd_flags" = DEFAULT ]; then
    153 		nfsd_flags="-tun 4"
    154 	fi
    155         rm -f /var/db/mountdtab
    156         echo -n > /var/db/mountdtab
    157         echo -n ' mountd';              mountd $mountd_flags
    158         echo -n ' nfsd';                nfsd $nfsd_flags
    159 	nfs_locking=MAYBE
    160 fi
    161 
    162 if [ "$nfs_client" = YES ]; then
    163 	if [ "$nfsiod_flags" = DEFAULT ]; then
    164 		nfsiod_flags="-n 4"
    165 	fi
    166         echo -n ' nfsiod';              nfsiod $nfsiod_flags
    167 	nfs_locking=MAYBE
    168 fi
    169 
    170 if [ "$nfs_locking" != NO ]; then
    171 	if [ "$statd_flags" != NO ]; then
    172 		if [ "$statd_flags" = DEFAULT ]; then
    173 			statd_flags=""
    174 		fi
    175 		echo ' statd';		rpc.statd $statd_flags
    176 	fi
    177 
    178 	if [ "$lockd_flags" != NO ]; then
    179 		if [ "$lockd_flags" = DEFAULT ]; then
    180 			lockd_flags=""
    181 		fi
    182 		echo ' lockd';		rpc.lockd $lockd_flags
    183 	fi
    184 fi
    185 
    186 if [ "$amd_flags" != NO ] && [ -d "$amd_dir" -a -r "$amd_master" ]; then
    187 	if [ "$amd_flags" = DEFAULT ]; then
    188 		amd_flags="-l syslog -x error,noinfo,nostats"
    189 	fi
    190         echo -n ' amd'
    191         amd $amd_flags -p -a $amd_dir `cat $amd_master` > /var/run/amd.pid
    192 fi
    193 
    194 echo '.'
    195 mount -a -t nfs
    196 
    197 if [ -f /sbin/ldconfig ]; then
    198 	echo 'creating runtime link editor directory cache.'
    199 	if [ -s /etc/ld.so.conf ]; then
    200 		ldconfig `cat /etc/ld.so.conf`
    201 	else
    202 		ldconfig
    203 	fi
    204 fi 
    205 
    206 # /var/crash should be a directory or a symbolic link
    207 # to the crash directory if core dumps are to be saved.
    208 if [ "$savecore_flags" != NO ] && [ -d /var/crash ]; then
    209 	if [ "$savecore_flags" = DEFAULT ]; then
    210 		savecore_flags=""
    211 	fi
    212 	echo checking for core dump...
    213 	savecore $savecore_flags /var/crash
    214 fi
    215 
    216 				echo -n 'checking quotas:'
    217 quotacheck -a
    218 				echo ' done.'
    219 quotaon -a
    220 
    221 # build ps databases
    222 echo 'building databases...'
    223 kvm_mkdb /netbsd
    224 dev_mkdb
    225 
    226 chmod 666 /dev/tty[pqrs]*
    227 
    228 # check the password temp/lock file
    229 if [ -f /etc/ptmp ]
    230 then
    231 	logger -s -p auth.err \
    232 	'password file may be incorrect -- /etc/ptmp exists'
    233 fi
    234 
    235 virecovery=/var/tmp/vi.recover/recover.*
    236 if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
    237 	echo preserving editor files
    238 	for i in $virecovery; do
    239 		sendmail -t < $i
    240 	done
    241 fi
    242 
    243 echo clearing /tmp
    244 
    245 # Prune quickly with one rm, then use find to clean up /tmp/[lq]* (this
    246 # is not needed with mfs /tmp, but doesn't hurt anything).
    247 (cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
    248     find . ! -name . ! -name lost+found ! -name quota.user \
    249 	! -name quota.group -exec rm -rf -- {} \; -type d -prune)
    250 
    251 if [ -f /var/account/acct ]; then
    252 	echo 'turning on accounting';	accton /var/account/acct
    253 fi
    254 
    255 echo -n standard daemons:
    256 echo -n ' update';		update
    257 echo -n ' cron';		cron
    258 echo '.'
    259 
    260 # now start all the other daemons
    261 echo -n starting network daemons:
    262 
    263 if [ "$gated_flags" != NO ] && [ -r /etc/gated.conf ]; then
    264 	if [ "$gated_flags" = DEFAULT ]; then
    265 		gated_flags=""
    266 	fi
    267 	echo -n ' gated';		gated $gated_flags
    268 elif [ "$routed_flags" != NO ]; then
    269 	if [ "$routed_flags" = DEFAULT ]; then
    270 		routed_flags="-q"
    271 	fi
    272 	echo -n ' routed';		routed $routed_flags
    273 fi
    274 
    275 if [ "$mrouted_flags" != NO ]; then
    276 	if [ "$mrouted_flags" = DEFAULT ]; then
    277 		mrouted_flags=""
    278 	fi
    279 	echo -n ' mrouted';		mrouted $mrouted_flags
    280 fi
    281 
    282 if [ "$timed_flags" != NO ]; then
    283 	if [ "$timed_flags" = DEFAULT ]; then
    284 		timed_flags=""
    285 	fi
    286 	echo -n ' timed'; 		timed $timed_flags
    287 fi
    288 
    289 if [ "$xntpd_flags" != NO ]; then
    290 	if [ "$xntpd_flags" = DEFAULT ]; then
    291 		xntpd_flags=""
    292 	fi
    293 	echo -n ' xntpd';		xntpd $xntpd_flags
    294 fi
    295 
    296 if [ "$dhcpd_flags" != NO ] && [ -r /etc/dhcpd.conf ]; then
    297 	if [ "$dhcpd_flags" = DEFAULT ]; then
    298 		dhcpd_flags=""
    299 	fi
    300 	echo -n ' dhcpd';		dhcpd $dhcpd_flags
    301 fi
    302 
    303 if [ "$rwhod" = YES ]; then
    304 	echo -n ' rwhod';		rwhod
    305 fi
    306 
    307 if [ "$lpd_flags" != NO ]; then
    308 	if [ "$lpd_flags" = DEFAULT ]; then
    309 		lpd_flags=""
    310 	fi
    311 	echo -n ' printer';		lpd $lpd_flags
    312 fi
    313 
    314 # We call sendmail with a full path so that SIGHUP works.
    315 if [ "$sendmail_flags" != NO ] && [ -r /etc/sendmail.cf ]; then
    316 	if [ "$sendmail_flags" = DEFAULT ]; then
    317 		sendmail_flags="-bd -q30m"
    318 	fi
    319 	echo -n ' sendmail';		/usr/sbin/sendmail $sendmail_flags
    320 fi
    321 
    322 if [ "$rarpd_flags" != NO ] && [ -r /etc/ethers ]; then
    323 	if [ "$rarpd_flags" = DEFAULT ]; then
    324 		rarpd_flags="-a"
    325 	fi
    326 	echo -n ' rarpd';		rarpd $rarpd_flags
    327 fi
    328 
    329 if [ "$rbootd_flags" != NO ] && [ -r /etc/rbootd.conf ]; then
    330 	if [ "$rbootd_flags" = DEFAULT ]; then
    331 		rbootd_flags=""
    332 	fi
    333 	echo -n ' rbootd';		rbootd $rbootd_flags
    334 fi
    335 
    336 if [ "$inetd_flags" != NO ] && [ -r /etc/inetd.conf ]; then
    337 	if [ "$inetd_flags" = DEFAULT ]; then
    338 		inetd_flags=""
    339 	fi
    340 	echo -n ' inetd';		inetd $inetd_flags
    341 fi
    342 
    343 echo '.'
    344 
    345 . /etc/rc.local
    346 
    347 date
    348 exit 0
    349