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