rc revision 796
1#!/bin/sh
2#	$Id: rc,v 1.4 1993/11/07 01:19:06 wollman Exp $
3#	From: @(#)rc	5.27 (Berkeley) 6/5/91
4
5# System startup script run by init on autoboot
6# or after single-user.
7# Output and error are redirected to console by init,
8# and the console is the controlling terminal.
9
10stty status '^T'
11
12# Set shell to ignore SIGINT (2), but not children;
13# shell catches SIGQUIT (3) and returns to single user after fsck.
14trap : 2
15trap : 3	# shouldn't be needed
16
17HOME=/; export HOME
18PATH=/sbin:/bin:/usr/sbin:/usr/bin
19export PATH
20
21if [ -e /fastboot ]
22then
23	echo Fast boot ... skipping disk checks
24elif [ $1x = autobootx ]
25then
26	echo Automatic reboot in progress...
27	fsck -p
28	case $? in
29	0)
30		;;
31	2)
32		exit 1
33		;;
34	4)
35		reboot
36		echo "reboot failed... help!"
37		exit 1
38		;;
39	8)
40		echo "Automatic file system check failed... help!"
41		exit 1
42		;;
43	12)
44		echo "Reboot interrupted"
45		exit 1
46		;;
47	130)
48		# interrupt before catcher installed
49		exit 1
50		;;
51	*)
52		echo "Unknown error in reboot"
53		exit 1
54		;;
55	esac
56fi
57
58trap "echo 'Reboot interrupted'; exit 1" 3
59
60swapon -a
61
62umount -a >/dev/null 2>&1
63mount -a -t nonfs
64rm -f /fastboot		# XXX (root now writeable)
65
66# set hostname, turn on network
67echo 'starting network'
68. /etc/netstart
69
70mount -a -t nfs >/dev/null 2>&1 &	# XXX shouldn't need background
71
72# clean up left-over files
73rm -f /etc/nologin
74rm -f /var/spool/uucp/LCK.*
75rm -f /var/spool/uucp/STST/*
76(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; })
77
78if [ -x /sbin/ldconfig ]; then
79	ldconfig /usr/X386/lib
80fi
81
82echo -n 'starting system logger'
83rm -f /dev/log
84syslogd
85
86# $timedflags is imported from /etc/netstart;
87# if $timedflags == NO, timed isn't run.
88if [ X${timedflags} != X"NO" ]; then
89	echo -n ', time daemon'; timed $timedflags
90fi
91echo '.'
92
93# /var/crash should be a directory or a symbolic link
94# to the crash directory if core dumps are to be saved.
95if [ -d /var/crash ]; then
96	echo checking for core dump...
97	savecore /var/crash
98fi
99
100#				echo -n 'checking quotas:'
101#quotacheck -a
102#				echo ' done.'
103#quotaon -a
104
105# build ps databases
106kvm_mkdb /386bsd
107dev_mkdb
108
109chmod 666 /dev/tty[pqrs]*
110
111# check the password temp/lock file
112if [ -f /etc/ptmp ]
113then
114	logger -s -p auth.err \
115	'password file may be incorrect -- /etc/ptmp exists'
116fi
117
118echo preserving editor files
119(cd /var/tmp && /usr/libexec/elvispreserve "-the system rebooted" elvis* &&
120     rm -f elvis[0-9a-f][0-9a-f][0-9a-f][0-9a-f]* \
121	 elvis_[0-9a-f][0-9a-f][0-9a-f][0-9a-f]*)
122
123echo clearing /tmp
124
125# prune quickly with one rm, then use find to clean up /tmp/[lq]*
126# (not needed with mfs /tmp, but doesn't hurt there...)
127(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
128    find . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;)
129
130# echo 'turning on accounting';	accton /var/account/acct
131
132echo -n standard daemons:
133echo -n ' update';		update
134echo -n ' crond';		/usr/libexec/crond
135echo '.'
136
137echo -n starting network daemons:
138
139# $gated and $routedflags are imported from /etc/netstart.
140# If $gated == YES, gated is used; otherwise routed.
141# If $routedflags == NO, routed isn't run.
142if [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
143	echo -n ' gated';	gated $gatedflags
144elif [ X${routedflags} != X"NO" ]; then
145	echo -n ' routed';	routed $routedflags
146fi
147
148if [ X${name_server} = X"YES" -a -r /etc/named.boot ]; then
149	echo -n ' named';		named
150fi
151
152# $rwhod is imported from /etc/netstart;
153# if $rwhod is set to something other than NO, rwhod is run.
154if [ ${rwhod-NO} != "NO" ]; then
155	echo -n ' rwhod';	rwhod
156fi
157
158echo -n ' printer';		lpd
159
160# Portmapper should always be run, to provide RPC services for inetd.
161if [ -x /usr/sbin/portmap ]; then
162	echo -n ' portmap';		portmap
163fi
164
165if [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then
166	echo -n ' mountd';		mountd
167	echo -n ' nfsd';		nfsd -u 0,0,4 -t 0,0
168	echo -n ' nfsiod';		nfsiod 4
169fi
170
171# $sendmail_flags is imported from /etc/netstart;
172# if $sendmail_flags is something other than NO, sendmail is run.
173if [ X${sendmail_flags} = X"NO" -a -r /etc/sendmail.cf ]; then
174	echo -n ' sendmail';		sendmail ${sendmail_flags} 
175fi
176
177echo -n ' inetd';		inetd
178echo '.'
179
180sh /etc/rc.local
181
182date
183
184exit 0
185