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