rc revision 1.66 1 # $NetBSD: rc,v 1.66 1997/03/10 06:32:37 scottr Exp $
2 # from: @(#)rc 8.2 (Berkeley) 3/17/94
3
4 # System startup script run by init on autoboot
5 # or after single-user.
6 # Output and error are redirected to console by init,
7 # and the console is the controlling terminal.
8
9 stty status '^T'
10
11 # Set shell to ignore SIGINT (2), but not children;
12 # shell catches SIGQUIT (3) and returns to single user after fsck.
13 trap : 2
14 trap : 3 # shouldn't be needed
15
16 HOME=/; export HOME
17 PATH=/sbin:/bin:/usr/sbin:/usr/bin
18 export PATH
19
20 # Configure ccd devices.
21 if [ -f /etc/ccd.conf ]; then
22 ccdconfig -C
23 fi
24
25 if [ -e /fastboot ]; then
26 echo "Fast boot: skipping disk checks."
27 elif [ $1x = autobootx ]; then
28 echo "Automatic boot in progress: starting file system checks."
29 fsck -p
30 case $? in
31 0)
32 ;;
33 2)
34 exit 1
35 ;;
36 4)
37 echo "Rebooting..."
38 reboot
39 echo "Reboot failed; help!"
40 exit 1
41 ;;
42 8)
43 echo "Automatic file system check failed; help!"
44 exit 1
45 ;;
46 12)
47 echo "Boot interrupted."
48 exit 1
49 ;;
50 130)
51 # interrupt before catcher installed
52 exit 1
53 ;;
54 *)
55 echo "Unknown error; help!"
56 exit 1
57 ;;
58 esac
59 fi
60
61 trap "echo 'Boot interrupted.'; exit 1" 3
62
63 swapon -a
64
65 umount -a >/dev/null 2>&1
66 mount -a -t nonfs
67 rm -f /fastboot # XXX (root now writeable)
68
69 if [ -s /etc/rc.conf ]; then
70 . /etc/rc.conf
71 fi
72
73 # set flags on ttys. (do early, in case they use tty for SLIP in netstart)
74 echo 'setting tty flags'
75 ttyflags -a
76
77 # load any kernel modules specified in /etc/lkm.conf
78 if [ X"$lkm_init" != XNO -a -f /etc/rc.lkm ]; then
79 . /etc/rc.lkm
80 fi
81
82 # set hostname, turn on network
83 echo 'starting network'
84 . /etc/netstart
85
86 mount /usr >/dev/null 2>&1
87 mount /var >/dev/null 2>&1
88
89 # clean up left-over files
90 rm -f /etc/nologin
91 rm -f /var/spool/lock/LCK.*
92 rm -f /var/spool/uucp/STST/*
93 (cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; })
94
95 # start the system logger first, so that all messages
96 # from daemons are logged, and the name server next.
97
98 if [ "X$syslogd_flags" != XNO ]; then
99 echo 'starting system logger'
100 rm -f /dev/log
101 syslogd $syslogd_flags
102 fi
103
104 if [ "X$named_flags" != XNO ]; then
105 echo 'starting name server'; named $named_flags
106 fi
107
108 # now start the rpc servers, for YP server/client, NFS.
109 echo -n 'starting rpc daemons:'
110
111 # note that portmap is generally required for all other rpc services.
112 if [ "X$portmap" != XNO ]; then
113 echo -n ' portmap'; portmap
114 fi
115
116 if [ "X$ypserv_flags" != XNO ]; then
117 echo -n ' ypserv'; ypserv $ypserv_flags
118 fi
119
120 if [ "X$ypbind_flags" != XNO ]; then
121 echo -n ' ypbind'; ypbind $ypbind_flags
122 fi
123
124 if [ "X$yppasswdd_flags" != XNO ]; then
125 echo -n ' rpc.yppasswdd'; rpc.yppasswdd $yppasswdd_flags
126 fi
127
128 if [ "X$bootparamd_flags" != XNO -a -r /etc/bootparams ]; then
129 echo -n ' rpc.bootparamd'; rpc.bootparamd $bootparamd_flags
130 fi
131
132 if [ "X$nfs_server" = XYES -a -r /etc/exports ]; then
133 if [ "X$nfsd_flags" = X ]; then
134 nfsd_flags="-tun 4"
135 fi
136 rm -f /var/db/mountdtab
137 echo -n > /var/db/mountdtab
138 echo -n ' mountd'; mountd $mountd_flags
139 echo -n ' nfsd'; nfsd $nfsd_flags
140 fi
141
142 if [ "X$nfs_client" = XYES ]; then
143 if [ "X$nfsiod_flags" = X ]; then
144 nfsiod_flags="-n 4"
145 fi
146 echo -n ' nfsiod'; nfsiod $nfsiod_flags
147 fi
148
149 if [ "X$nfs_server" = XYES -a -r /etc/exports -o "X$nfs_client" = XYES ]; then
150 if [ "X$statd_flags" != XNO ]; then
151 echo ' statd'; rpc.statd $statd_flags
152 fi
153
154 if [ "X$lockd_flags" != XNO ]; then
155 echo ' lockd'; rpc.lockd $lockd_flags
156 fi
157 fi
158
159 if [ "X$amd" = XYES -a -d "$amd_dir" -a -r "$amd_master" ]; then
160 echo -n ' amd'
161 amd $amd_flags -p -a $amd_dir `cat $amd_master` > /var/run/amd.pid
162 fi
163
164 echo '.'
165 mount -a -t nfs
166
167 if [ -f /sbin/ldconfig ]; then
168 echo 'creating runtime link editor directory cache.'
169 if [ -s /etc/ld.so.conf ]; then
170 ldconfig `cat /etc/ld.so.conf`
171 else
172 ldconfig
173 fi
174 fi
175
176 # /var/crash should be a directory or a symbolic link
177 # to the crash directory if core dumps are to be saved.
178 if [ X"$savecore_flags" != XNO -a -d /var/crash ]; then
179 echo checking for core dump...
180 savecore $savecore_flags /var/crash
181 fi
182
183 echo -n 'checking quotas:'
184 quotacheck -a
185 echo ' done.'
186 quotaon -a
187
188 # build ps databases
189 echo 'building databases...'
190 kvm_mkdb /netbsd
191 dev_mkdb
192
193 chmod 666 /dev/tty[pqrs]*
194
195 # check the password temp/lock file
196 if [ -f /etc/ptmp ]
197 then
198 logger -s -p auth.err \
199 'password file may be incorrect -- /etc/ptmp exists'
200 fi
201
202 virecovery=/var/tmp/vi.recover/recover.*
203 if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
204 echo preserving editor files
205 for i in $virecovery; do
206 sendmail -t < $i
207 done
208 fi
209
210 echo clearing /tmp
211
212 # Prune quickly with one rm, then use find to clean up /tmp/[lq]* (this
213 # is not needed with mfs /tmp, but doesn't hurt anything).
214 (cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
215 find . ! -name . ! -name lost+found ! -name quota.user \
216 ! -name quota.group -exec rm -rf -- {} \; -type d -prune)
217
218 if [ -f /var/account/acct ]; then
219 echo 'turning on accounting'; accton /var/account/acct
220 fi
221
222 echo -n standard daemons:
223 echo -n ' update'; update
224 echo -n ' cron'; cron
225 echo '.'
226
227 # now start all the other daemons
228 echo -n starting network daemons:
229
230 if [ X$gated_flags != XNO -a -r /etc/gated.conf ]; then
231 echo -n ' gated'; gated $gated_flags
232 elif [ "X$routed_flags" != XNO ]; then
233 echo -n ' routed'; routed $routed_flags
234 fi
235
236 if [ "X$mrouted_flags" != XNO ]; then
237 echo -n ' mrouted'; mrouted $mrouted_flags
238 fi
239
240 if [ "X$timed_flags" != XNO ]; then
241 echo -n ' time daemon'; timed $timed_flags
242 fi
243
244 if [ "X$xntpd_flags" != XNO ]; then
245 echo -n ' ntp daemon'; xntpd $xntpd_flags
246 fi
247
248 if [ "X$dhcpd_flags" != XNO -a -r /etc/dhcpd.conf ]; then
249 echo -n ' dhcpd'; dhcpd $dhcpd_flags
250 fi
251
252 if [ X$rwhod = XYES ]; then
253 echo -n ' rwhod'; rwhod
254 fi
255
256 if [ "X$lpd_flags" != XNO ]; then
257 echo -n ' printer'; lpd $lpd_flags
258 fi
259
260 # We call sendmail with a full path so that SIGHUP works.
261 if [ "X$sendmail_flags" != XNO -a -r /etc/sendmail.cf ]; then
262 echo -n ' sendmail'; /usr/sbin/sendmail $sendmail_flags
263 fi
264
265 if [ "X$rarpd_flags" != XNO -a -r /etc/ethers ]; then
266 echo -n ' rarpd'; rarpd $rarpd_flags
267 fi
268
269 if [ "X$rbootd_flags" != XNO -a -r /etc/rbootd.conf ]; then
270 echo -n ' rbootd'; rbootd $rbootd_flags
271 fi
272
273 if [ "X$inetd_flags" != XNO -a -r /etc/inetd.conf ]; then
274 echo -n ' inetd'; inetd $inetd_flags
275 fi
276
277 echo '.'
278
279 . /etc/rc.local
280
281 date
282 exit 0
283