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