rc revision 1675
139287Ssos#!/bin/sh
239643Syokota#	$Id: rc,v 1.24 1994/06/01 17:04:01 paul Exp $
339287Ssos#	From: @(#)rc	5.27 (Berkeley) 6/5/91
439287Ssos
539287Ssos# System startup script run by init on autoboot
639287Ssos# or after single-user.
739287Ssos# Output and error are redirected to console by init,
839287Ssos# and the console is the controlling terminal.
939643Syokota
1039643Syokotastty status '^T'
1139287Ssos
1239287Ssos# Set shell to ignore SIGINT (2), but not children;
1339287Ssos# shell catches SIGQUIT (3) and returns to single user after fsck.
1439287Ssostrap : 2
1539643Syokotatrap : 3	# shouldn't be needed
1639643Syokota
1739643SyokotaHOME=/; export HOME
1839643SyokotaPATH=/sbin:/bin:/usr/sbin:/usr/bin
1939643Syokotaexport PATH
2039643Syokota
2139643Syokotaif [ -e /fastboot ]
2239643Syokotathen
2339643Syokota	echo Fast boot ... skipping disk checks
2439643Syokotaelif [ $1x = autobootx ]
2539287Ssosthen
2650477Speter	echo Automatic reboot in progress...
2739287Ssos	fsck -p
2839287Ssos	case $? in
2942504Syokota	0)
3042504Syokota		;;
3139287Ssos	2)
3242504Syokota		exit 1
3339287Ssos		;;
3442504Syokota	4)
3542504Syokota		reboot
3642504Syokota		echo "reboot failed... help!"
3739287Ssos		exit 1
3847678Sjlemon		;;
3942504Syokota	8)
4039287Ssos		echo "Automatic file system check failed... help!"
4139287Ssos		exit 1
4239287Ssos		;;
4342179Syokota	12)
4439287Ssos		echo "Reboot interrupted"
4548104Syokota		exit 1
4648104Syokota		;;
4739287Ssos	130)
4848104Syokota		# interrupt before catcher installed
4948104Syokota		exit 1
5039287Ssos		;;
5139287Ssos	*)
5239287Ssos		echo "Unknown error in reboot"
5339287Ssos		exit 1
5439287Ssos		;;
5539287Ssos	esac
5639287Ssosfi
5742504Syokota
5842504Syokotatrap "echo 'Reboot interrupted'; exit 1" 3
5939287Ssos
6042504Syokotaswapon -a
6142504Syokota
6242504Syokotaumount -a >/dev/null 2>&1
6342504Syokotamount -a -t nonfs
6442504Syokotarm -f /fastboot		# XXX (root now writeable)
6542504Syokota
6642504Syokota# If the machine runs wall CMOS clock (compatible with MSDOS),
6742611Syokota# activate following line by creating empty file /etc/wall_cmos_clock
6842504Syokota# If this file not exist, following line does nothing (assumed
6942504Syokota# the machine runs UTC CMOS clock). See adjkerntz(8) for details.
7039287Ssosadjkerntz -i
7139287Ssos
7239287Ssos# configure serial devices
7339287Ssosif [ -f /etc/rc.serial ]
7439287Ssosthen
7539287Ssos	sh /etc/rc.serial
7639287Ssosfi
7739287Ssos
7839287Ssos# set hostname, turn on network
7939287Ssosecho 'starting network'
8039287Ssos. /etc/netstart
8139287Ssos
8239287Ssos# clean up left-over files
8348399Speterrm -f /etc/nologin
8442504Syokotarm -f /var/spool/lock/*
8548399Speterrm -f /var/spool/uucp/.Temp/*
8648104Syokota# don't add .[a-z]* to rm, because of .adjkerntz file name
8742504Syokota(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; })
8839287Ssos
8939287Ssosecho -n 'starting system logger'
9039287Ssosrm -f /dev/log
9139287Ssossyslogd
9239287Ssos
9339287Ssos# $timedflags is imported from /etc/netstart;
9439287Ssos# if $timedflags == NO, timed isn't run.
9539287Ssosif [ X${timedflags} != X"NO" ]; then
9639287Ssos	echo -n ', time daemon'; timed $timedflags
9739287Ssosfi
9839287Ssosecho '.'
9939287Ssos
10039287Ssos# /var/crash should be a directory or a symbolic link
10139287Ssos# to the crash directory if core dumps are to be saved.
10239287Ssosif [ -d /var/crash ]; then
10342504Syokota	echo checking for core dump...
10448104Syokota	savecore /var/crash
10542504Syokotafi
10648104Syokota
10748104Syokota#				echo -n 'checking quotas:'
10848104Syokota#quotacheck -a
10948104Syokota#				echo ' done.'
11039287Ssos#quotaon -a
11148104Syokota
11244846Sjlemon# build ps databases
11339287Ssoskvm_mkdb /386bsd
11442504Syokotadev_mkdb
11542504Syokota
11642504Syokotachmod 666 /dev/tty[pqrs]*
11742504Syokota
11842504Syokota# check the password temp/lock file
11942504Syokotaif [ -f /etc/ptmp ]
12042504Syokotathen
12142504Syokota	logger -s -p auth.err \
12242504Syokota	'password file may be incorrect -- /etc/ptmp exists'
12342504Syokotafi
12442504Syokota
12542504Syokota# Recover elvis editor files.
12642504Syokotaecho preserving editor files
12742504Syokota(cd /var/tmp && /usr/libexec/elvispreserve "-the system rebooted" elv* &&
12842504Syokota	rm -f elvis[0-9a-f][0-9a-f][0-9a-f][0-9a-f]* \
12942504Syokota	elvis_[0-9a-f][0-9a-f][0-9a-f][0-9a-f]*)
13042504Syokota
13142504Syokota# Recover vi editor files.
13248104Syokotavirecovery=/var/tmp/vi.recover/recover.*
13342504Syokotaif [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
13448104Syokota	echo 'Recovering vi editor sessions'
13548104Syokota	for i in $virecovery; do
13648104Syokota		sendmail -t < $i
13748104Syokota	done
13848104Syokotafi
13948104Syokota
14039287Ssosecho clearing /tmp
14139287Ssos
14239287Ssos# prune quickly with one rm, then use find to clean up /tmp/[lq]*
14342504Syokota# (not needed with mfs /tmp, but doesn't hurt there...)
14439287Ssos(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
14539287Ssos    find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;)
14639287Ssos
14739287Ssos# echo 'turning on accounting';	accton /var/account/acct
14839287Ssos
14939287Ssosecho -n standard daemons:
15048104Syokotaecho -n ' cron';		cron
15139287Ssosecho '.'
15248104Syokota
15348104Syokotaecho -n starting network daemons:
15448104Syokota
15548104Syokota# Portmapper should always be run, to provide RPC services for inetd.
15639287Ssosif [ -x /usr/sbin/portmap ]; then
15739287Ssos	echo -n ' portmap';		portmap
15839287Ssosfi
15939287Ssos
16039858Syokota# $gated and $routedflags are imported from /etc/netstart.
16139858Syokota# If $gated == YES, gated is used; otherwise routed.
16239858Syokota# If $routedflags == NO, routed isn't run.
16339858Syokotaif [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
16439287Ssos	echo -n ' gated';	gated $gatedflags
16539287Ssoselif [ X"${routedflags}" != X"NO" ]; then
16639287Ssos	echo -n ' routed';	routed $routedflags
16739287Ssosfi
16842504Syokota
16939287Ssosif [ X${name_server} = X"YES" -a -r /etc/named.boot ]; then
17039287Ssos	echo -n ' named';		named
17145117Syokotafi
17239287Ssos
17342729Syokota# $ntpdate and $xntpdflags are imported from /etc/netstart.
17442729Syokota# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly.
17548104Syokota# If $xntpdflags != NO, start xntpd.
17648104Syokotaif [ X"${ntpdate}" != X"NO" ]; then
17742729Syokota	echo ' ntpdate';	ntpdate $ntpdate
17842729Syokotafi
17948399Speter
18048104Syokotaif [ X"${xntpdflags}" != X"NO" ]; then
18148104Syokota	if [ X"${tickadjflags}" != X"NO" ]; then
18248399Speter		echo 'adjusting kernel for xntpd'; tickadj ${tickadjflags--A}
18339287Ssos	fi
18439287Ssos	echo 'starting xntpd';	xntpd ${xntpdflags}
18539287Ssosfi
18639287Ssos
18739287Ssosif [ X"${ntpdate}" != X"NO" -o X"${xntpdflags}" != X"NO" ]; then
18839287Ssos	echo -n 'starting more network daemons:'
18939287Ssosfi
19039287Ssos
19139287Ssos# $rwhod is imported from /etc/netstart;
19239287Ssos# if $rwhod is set to something other than NO, rwhod is run.
19339287Ssosif [ ${rwhod-NO} != "NO" ]; then
19443664Syokota	echo -n ' rwhod';	rwhod
19550446Syokotafi
19648399Speter
19748104Syokotaecho -n ' printer';		lpd
19848399Speter
19948104Syokotaif [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then
20039591Syokota	echo -n ' mountd';		mountd
20139591Syokota	echo -n ' nfsd';		nfsd -u 0,0,4 -t 0,0
20248104Syokota	echo -n ' nfsiod';		nfsiod 4
20339858Syokotafi
20439858Syokota
20539287Ssos# $sendmail_flags is imported from /etc/netstart;
20639591Syokota# if $sendmail_flags is something other than NO, sendmail is run.
20748104Syokotaif [ X"${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
20848104Syokota	echo -n ' sendmail';		sendmail ${sendmail_flags} 
20939287Ssosfi
21048399Speter
21148104Syokotaecho -n ' inetd';		inetd
21248399Speterecho '.'
21348104Syokota
21439287Ssosmount -a -t nfs >/dev/null 2>&1 &	# XXX shouldn't need background
21539287Ssos
21639287Ssosif [ -x /usr/libexec/xtend ]; then
21739287Ssos	echo -n ' xtend';   /usr/libexec/xtend
21839287Ssosfi
21939287Ssos
22039287Ssos# Make shared lib searching a little faster.  Leave /usr/lib first if you
22139287Ssos# add your own entries or you may come to grief.
22239287Ssosif [ -x /sbin/ldconfig ]; then
22339287Ssos	_LDC=/usr/lib
22439287Ssos	if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi
22539287Ssos	if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi
22642504Syokota	if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi
22742504Syokota	if [ -d /usr/gnu/lib ]; then _LDC="${_LDC} /usr/gnu/lib" ; fi
22842504Syokota	echo 'setting ldconfig path:' ${_LDC}
22942504Syokota	ldconfig ${_LDC}
23042504Syokotafi
23142504Syokota
23242504Syokotash /etc/rc.local
23342504Syokota
23442504Syokotadate
23542504Syokota
23642504Syokotaexit 0
23742504Syokota