rc revision 1.40 1 # @(#)rc 5.27 (Berkeley) 6/5/91
2 # $Id: rc,v 1.40 1994/04/10 06:42:40 cgd Exp $
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 if [ -e /fastboot ]
21 then
22 echo "Fast boot: skipping disk checks."
23 elif [ $1x = autobootx ]
24 then
25 echo "Automatic boot in progress: starting file system checks."
26 fsck -p
27 case $? in
28 0)
29 ;;
30 2)
31 exit 1
32 ;;
33 4)
34 echo "Rebooting..."
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 "Boot interrupted."
45 exit 1
46 ;;
47 130)
48 # interrupt before catcher installed
49 exit 1
50 ;;
51 *)
52 echo "Unknown error; help!"
53 exit 1
54 ;;
55 esac
56 fi
57
58 trap "echo 'Boot interrupted.'; exit 1" 3
59
60 swapon -a
61
62 umount -a >/dev/null 2>&1
63 mount -a -t nonfs
64 rm -f /fastboot # XXX (root now writeable)
65
66 # set flags on ttys. (do early, in case they use tty for SLIP in netstart)
67 echo 'setting tty flags'
68 ttyflags -a
69
70 # set hostname, turn on network
71 echo 'starting network'
72 . /etc/netstart
73
74 mount /usr >/dev/null 2>&1
75
76 echo -n 'starting rpc daemons:'
77 echo -n ' portmap'; portmap
78
79 if [ -f /usr/sbin/ypbind -a -d /var/yp ]; then
80 echo -n ' ypbind'; ypbind
81 fi
82
83 # $nfs_server is imported from /etc/netstart;
84 # if $nfs_server == YES, the machine is setup for being an nfs server
85 if [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then
86 rm -f /var/db/mountdtab
87 echo -n ' mountd'; mountd
88 echo -n ' nfsd'; nfsd -u 0,0,4 -t 0,0
89 fi
90
91 # $nfs_client is imported from /etc/netstart;
92 # if $nfs_client == YES, the machine is setup for being an nfs client
93 if [ X${nfs_client} = X"YES" ]; then
94 echo -n ' nfsiod'; nfsiod 4
95 fi
96
97 if [ X${amd} = X"YES" -a -d ${amd_dir} -a -r ${amd_master} ]; then
98 echo -n ' amd'
99 amd -l syslog -x error,noinfo,nostats -p > /var/run/amd.pid \
100 -a ${amd_dir} `cat ${amd_master}`
101 fi
102
103 echo '.'
104 mount -a -t nfs
105
106 # clean up left-over files
107 rm -f /etc/nologin
108 rm -f /var/spool/lock/LCK.*
109 rm -f /var/spool/uucp/STST/*
110 (cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; })
111
112 echo 'runtime link editor directory cache'
113 rm -f /var/run/ld.so.hints
114 ldconfig
115
116 echo -n 'starting system logger'
117 rm -f /dev/log
118 syslogd
119
120 # $timed_flags is imported from /etc/netstart;
121 # if $timed_flags == NO, timed isn't run.
122 if [ "X${timed_flags}" != X"NO" ]; then
123 echo -n ', time daemon'; timed $timed_flags
124 fi
125 echo '.'
126
127 # /var/crash should be a directory or a symbolic link
128 # to the crash directory if core dumps are to be saved.
129 if [ -d /var/crash ]; then
130 echo checking for core dump...
131 savecore /var/crash
132 fi
133
134 # echo -n 'checking quotas:'
135 #quotacheck -a
136 # echo ' done.'
137 #quotaon -a
138
139 # build ps databases
140 echo 'building databases...'
141 kvm_mkdb /netbsd
142 dev_mkdb
143
144 chmod 666 /dev/tty[pqrs]*
145
146 # check the password temp/lock file
147 if [ -f /etc/ptmp ]
148 then
149 logger -s -p auth.err \
150 'password file may be incorrect -- /etc/ptmp exists'
151 fi
152
153 virecovery=/var/tmp/vi.recover/recover.*
154 if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
155 echo preserving editor files
156 for i in $virecovery; do
157 sendmail -t < $i
158 done
159 fi
160
161 echo clearing /tmp
162
163 # prune quickly with one rm, then use find to clean up /tmp/[lq]*
164 # (not needed with mfs /tmp, but doesn't hurt there...)
165 (cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
166 find . ! -name . ! -name lost+found ! -name quotas \
167 -exec rm -rf -- {} \; -type d -prune)
168
169 if [ -f /var/account/acct ]; then
170 echo 'turning on accounting'; accton /var/account/acct
171 fi
172
173 echo -n standard daemons:
174 echo -n ' update'; update
175 echo -n ' cron'; cron
176 echo '.'
177
178 echo -n starting network daemons:
179
180 # $gated and $routed_flags are imported from /etc/netstart.
181 # If $gated == YES, gated is used; otherwise routed.
182 # If $routed_flags == NO, routed isn't run.
183 if [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
184 echo -n ' gated'; gated $gated_flags
185 elif [ "X${routed_flags}" != X"NO" ]; then
186 echo -n ' routed'; routed $routed_flags
187 fi
188
189 # $name_server is imported from /etc/netstart;
190 # if $name_server == YES, named is run.
191 if [ X${name_server} = X"YES" -a -r /etc/named.boot ]; then
192 echo -n ' named'; named
193 fi
194
195 # $rwhod is imported from /etc/netstart;
196 # if $rwhod == YES, rwhod is run.
197 if [ X${rwhod} = X"YES" ]; then
198 echo -n ' rwhod'; rwhod
199 fi
200
201 echo -n ' printer'; lpd
202
203 # $sendmail_flags is imported from /etc/netstart;
204 # If $sendmail_flags == NO or /etc/sendmail.cf doesn't exist, then
205 # sendmail isn't run.
206 if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
207 echo -n ' sendmail'; sendmail ${sendmail_flags}
208 fi
209
210 echo -n ' inetd'; inetd
211
212 # $rarpd_flags is importent from /etc/netstart;
213 # If $rarpd_flags == NO or /etc/ethers doesn't exist, then
214 # rarpd isn't run.
215 if [ "X${rarpd_flags}" != X"NO" -a -r /etc/ethers ]; then
216 echo -n ' rarpd'; rarpd ${rarpd_flags}
217 fi
218
219 # $bootparamd_flags is importent from /etc/netstart;
220 # If $bootparamd_flags == NO or /etc/bootparams doesn't exist, then
221 # bootparamd isn't run.
222 if [ "X${bootparamd_flags}" != X"NO" -a -r /etc/bootparams ]; then
223 echo -n ' rpc.bootparamd'; rpc.bootparamd ${bootparamd_flags}
224 fi
225
226 echo '.'
227
228 . /etc/rc.local
229
230 date
231
232 exit 0
233