rc revision 37
137Srgrimes#	@(#)rc	5.27 (Berkeley) 6/5/91
237Srgrimes
337Srgrimes# System startup script run by init on autoboot
437Srgrimes# or after single-user.
537Srgrimes# Output and error are redirected to console by init,
637Srgrimes# and the console is the controlling terminal.
737Srgrimes
837Srgrimesstty status '^T'
937Srgrimes# yellow characters with blue background
1037Srgrimesecho -n "[3;30x"
1137Srgrimes
1237Srgrimes# Set shell to ignore SIGINT (2), but not children;
1337Srgrimes# shell catches SIGQUIT (3) and returns to single user after fsck.
1437Srgrimestrap : 2
1537Srgrimestrap : 3	# shouldn't be needed
1637Srgrimes
1737SrgrimesHOME=/; export HOME
1837SrgrimesPATH=/sbin:/bin:/usr/sbin:/usr/bin
1937Srgrimesexport PATH
2037Srgrimes
2137Srgrimesif [ -r /fastboot ]
2237Srgrimesthen
2337Srgrimes	echo Fast boot ... skipping disk checks
2437Srgrimeselif [ $1x = autobootx ]
2537Srgrimesthen
2637Srgrimes	echo Automatic reboot in progress...
2737Srgrimes	fsck -p
2837Srgrimes	case $? in
2937Srgrimes	0)
3037Srgrimes		;;
3137Srgrimes	2)
3237Srgrimes		exit 1
3337Srgrimes		;;
3437Srgrimes	4)
3537Srgrimes		reboot
3637Srgrimes		echo "reboot failed... help!"
3737Srgrimes		exit 1
3837Srgrimes		;;
3937Srgrimes	8)
4037Srgrimes		echo "Automatic file system check failed... help!"
4137Srgrimes		exit 1
4237Srgrimes		;;
4337Srgrimes	12)
4437Srgrimes		echo "Reboot interrupted"
4537Srgrimes		exit 1
4637Srgrimes		;;
4737Srgrimes	130)
4837Srgrimes		# interrupt before catcher installed
4937Srgrimes		exit 1
5037Srgrimes		;;
5137Srgrimes	*)
5237Srgrimes		echo "Unknown error in reboot"
5337Srgrimes		exit 1
5437Srgrimes		;;
5537Srgrimes	esac
5637Srgrimesfi
5737Srgrimes
5837Srgrimestrap "echo 'Reboot interrupted'; exit 1" 3
5937Srgrimes
6037Srgrimesswapon -a
6137Srgrimes
6237Srgrimesumount -a >/dev/null 2>&1
6337Srgrimesmount -a -t nonfs
6437Srgrimesrm -f /fastboot		# XXX (root now writeable)
6537Srgrimes
6637Srgrimes# set hostname, turn on network
6737Srgrimesecho 'starting network'
6837Srgrimes. /etc/netstart
6937Srgrimes
7037Srgrimesmount -a -t nfs >/dev/null 2>&1 &	# XXX shouldn't need background
7137Srgrimes
7237Srgrimes# clean up left-over files
7337Srgrimesrm -f /etc/nologin
7437Srgrimesrm -f /var/spool/uucp/LCK.*
7537Srgrimesrm -f /var/spool/uucp/STST/*
7637Srgrimes(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; })
7737Srgrimes
7837Srgrimesecho -n 'starting system logger'
7937Srgrimesrm -f /dev/log
8037Srgrimessyslogd
8137Srgrimes
8237Srgrimes# $timedflags is imported from /etc/netstart;
8337Srgrimes# if $timedflags == NO, timed isn't run.
8437Srgrimesif [ X${timedflags} != X"NO" ]; then
8537Srgrimes	echo -n ', time daemon'; timed $timedflags
8637Srgrimesfi
8737Srgrimesecho '.'
8837Srgrimes
8937Srgrimes# /var/crash should be a directory or a symbolic link
9037Srgrimes# to the crash directory if core dumps are to be saved.
9137Srgrimesif [ -d /var/crash ]; then
9237Srgrimes	echo checking for core dump...
9337Srgrimes	savecore /var/crash
9437Srgrimesfi
9537Srgrimes
9637Srgrimes#				echo -n 'checking quotas:'
9737Srgrimes#quotacheck -a
9837Srgrimes#				echo ' done.'
9937Srgrimes#quotaon -a
10037Srgrimes
10137Srgrimes# build ps databases
10237Srgrimeskvm_mkdb /386bsd
10337Srgrimesdev_mkdb
10437Srgrimes
10537Srgrimeschmod 666 /dev/tty[pqrs]*
10637Srgrimes
10737Srgrimes# check the password temp/lock file
10837Srgrimesif [ -f /etc/ptmp ]
10937Srgrimesthen
11037Srgrimes	logger -s -p auth.err \
11137Srgrimes	'password file may be incorrect -- /etc/ptmp exists'
11237Srgrimesfi
11337Srgrimes
11437Srgrimesecho preserving editor files
11537Srgrimes(cd /var/tmp && /usr/libexec/elvispreserve "-the system rebooted" elvis* &&
11637Srgrimes     rm -f elvis[0-9a-f][0-9a-f][0-9a-f][0-9a-f]* \
11737Srgrimes	 elvis_[0-9a-f][0-9a-f][0-9a-f][0-9a-f]*)
11837Srgrimes
11937Srgrimesecho clearing /tmp
12037Srgrimes
12137Srgrimes# prune quickly with one rm, then use find to clean up /tmp/[lq]*
12237Srgrimes# (not needed with mfs /tmp, but doesn't hurt there...)
12337Srgrimes(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
12437Srgrimes    find . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;)
12537Srgrimes
12637Srgrimes# echo 'turning on accounting';	accton /var/account/acct
12737Srgrimes
12837Srgrimesecho -n standard daemons:
12937Srgrimesecho -n ' update';		update
13037Srgrimesecho -n ' crond';		/usr/libexec/crond
13137Srgrimesecho '.'
13237Srgrimes
13337Srgrimesecho -n starting network daemons:
13437Srgrimes
13537Srgrimes# $gated and $routedflags are imported from /etc/netstart.
13637Srgrimes# If $gated == YES, gated is used; otherwise routed.
13737Srgrimes# If $routedflags == NO, routed isn't run.
13837Srgrimesif [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
13937Srgrimes	echo -n ' gated';	gated $gatedflags
14037Srgrimeselif [ X${routedflags} != X"NO" ]; then
14137Srgrimes	echo -n ' routed';	routed $routedflags
14237Srgrimesfi
14337Srgrimes
14437Srgrimesif [ X${name_server} = X"YES" -a -r /etc/named.boot ]; then
14537Srgrimes	echo -n ' named';		named
14637Srgrimesfi
14737Srgrimes
14837Srgrimes# $rwhod is imported from /etc/netstart;
14937Srgrimes# if $rwhod is set to something other than NO, rwhod is run.
15037Srgrimesif [ ${rwhod-NO} != "NO" ]; then
15137Srgrimes	echo -n ' rwhod';	rwhod
15237Srgrimesfi
15337Srgrimes
15437Srgrimesecho -n ' printer';		lpd
15537Srgrimes
15637Srgrimes
15737Srgrimesif [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then
15837Srgrimes	echo -n ' portmap';		portmap
15937Srgrimes	echo -n ' mountd';		mountd
16037Srgrimes	echo -n ' nfsd';		nfsd -u 0,0,4 -t 0,0
16137Srgrimes	echo -n ' nfsiod';		nfsiod 4
16237Srgrimesfi
16337Srgrimes
16437Srgrimesecho -n ' sendmail';		sendmail -bd -q30m
16537Srgrimesecho -n ' inetd';		inetd
16637Srgrimesecho '.'
16737Srgrimes
16837Srgrimessh /etc/rc.local
16937Srgrimes
17037Srgrimesdate
17137Srgrimes
17237Srgrimes# reset to normal (no colors)
17337Srgrimesecho -n "[0x"
17437Srgrimesexit 0
175