rc revision 958
1#!/bin/sh
2#	$Id: rc,v 1.13 1994/01/04 18:06:18 ache 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# If the machine runs wall CMOS clock (compatible with MSDOS),
67# activate following line by creating empty file /etc/wall_cmos_clock
68# If this file not exist, following line does nothing (assumed
69# the machine runs UTC CMOS clock). See adjkerntz(8) for details.
70adjkerntz -i
71
72# set hostname, turn on network
73echo 'starting network'
74. /etc/netstart
75
76# clean up left-over files
77rm -f /etc/nologin
78rm -f /var/spool/uucp/LCK.*
79rm -f /var/spool/uucp/STST/*
80# don't add .[a-z]* to rm, because of .adjkerntz file
81(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; })
82
83# Make shared lib searching a little faster.  Leave /usr/lib first if you
84# add your own entries or you may come to grief.
85if [ -x /sbin/ldconfig ]; then
86	_LDC=/usr/lib
87	if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi
88	if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi
89	if [ -d /usr/gnu/lib ]; then _LDC="${_LDC} /usr/gnu/lib" ; fi
90	echo 'setting ldconfig path:' ${_LDC}
91	ldconfig ${_LDC}
92fi
93
94echo -n 'starting system logger'
95rm -f /dev/log
96syslogd
97
98# $timedflags is imported from /etc/netstart;
99# if $timedflags == NO, timed isn't run.
100if [ X${timedflags} != X"NO" ]; then
101	echo -n ', time daemon'; timed $timedflags
102fi
103echo '.'
104
105# /var/crash should be a directory or a symbolic link
106# to the crash directory if core dumps are to be saved.
107if [ -d /var/crash ]; then
108	echo checking for core dump...
109	savecore /var/crash
110fi
111
112#				echo -n 'checking quotas:'
113#quotacheck -a
114#				echo ' done.'
115#quotaon -a
116
117# build ps databases
118kvm_mkdb /386bsd
119dev_mkdb
120
121chmod 666 /dev/tty[pqrs]*
122
123# check the password temp/lock file
124if [ -f /etc/ptmp ]
125then
126	logger -s -p auth.err \
127	'password file may be incorrect -- /etc/ptmp exists'
128fi
129
130echo preserving editor files
131(cd /var/tmp && /usr/libexec/elvispreserve "-the system rebooted" elvis* &&
132     rm -f elvis[0-9a-f][0-9a-f][0-9a-f][0-9a-f]* \
133	 elvis_[0-9a-f][0-9a-f][0-9a-f][0-9a-f]*)
134
135echo clearing /tmp
136
137# prune quickly with one rm, then use find to clean up /tmp/[lq]*
138# (not needed with mfs /tmp, but doesn't hurt there...)
139(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
140    find . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;)
141
142# echo 'turning on accounting';	accton /var/account/acct
143
144echo -n standard daemons:
145echo -n ' crond';		/usr/libexec/crond
146echo '.'
147
148echo -n starting network daemons:
149
150# Portmapper should always be run, to provide RPC services for inetd.
151if [ -x /usr/sbin/portmap ]; then
152	echo -n ' portmap';		portmap
153fi
154
155# $gated and $routedflags are imported from /etc/netstart.
156# If $gated == YES, gated is used; otherwise routed.
157# If $routedflags == NO, routed isn't run.
158if [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
159	echo -n ' gated';	gated $gatedflags
160elif [ X${routedflags} != X"NO" ]; then
161	echo -n ' routed';	routed $routedflags
162fi
163
164if [ X${name_server} = X"YES" -a -r /etc/named.boot ]; then
165	echo -n ' named';		named
166fi
167
168# $ntpdate and $xntpdflags are imported from /etc/netstart.
169# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly.
170# If $xntpdflags != NO, start xntpd.
171if [ X"${ntpdate}" != X"NO" ]; then
172	echo -n ' ntpdate';	ntpdate $ntpdate
173fi
174
175if [ X"${xntpdflags}" != X"NO" ]; then
176	echo -n ' xntpd';	xntpd ${xntpdflags}
177fi
178
179# $rwhod is imported from /etc/netstart;
180# if $rwhod is set to something other than NO, rwhod is run.
181if [ ${rwhod-NO} != "NO" ]; then
182	echo -n ' rwhod';	rwhod
183fi
184
185echo -n ' printer';		lpd
186
187if [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then
188	echo -n ' mountd';		mountd
189	echo -n ' nfsd';		nfsd -u 0,0,4 -t 0,0
190	echo -n ' nfsiod';		nfsiod 4
191fi
192
193# $sendmail_flags is imported from /etc/netstart;
194# if $sendmail_flags is something other than NO, sendmail is run.
195if [ X"${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
196	echo -n ' sendmail';		sendmail ${sendmail_flags} 
197fi
198
199echo -n ' inetd';		inetd
200echo '.'
201
202mount -a -t nfs >/dev/null 2>&1 &	# XXX shouldn't need background
203
204sh /etc/rc.local
205
206date
207
208exit 0
209