Annotation of src/etc/rc, Revision 1.18
1.18 ! deraadt 1: # $OpenBSD: rc,v 1.17 1996/06/18 15:30:01 deraadt Exp $
1.1 deraadt 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:
8: stty 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.
12: trap : 2
13: trap : 3 # shouldn't be needed
14:
15: HOME=/; export HOME
16: PATH=/sbin:/bin:/usr/sbin:/usr/bin
17: export PATH
18:
19: # Configure ccd devices.
1.17 deraadt 20: if [ -f /etc/ccd.conf ]; then
1.1 deraadt 21: ccdconfig -C
22: fi
23:
1.17 deraadt 24: if [ -e /fastboot ]; then
1.1 deraadt 25: echo "Fast boot: skipping disk checks."
1.17 deraadt 26: elif [ $1x = autobootx ]; then
1.1 deraadt 27: echo "Automatic boot in progress: starting file system checks."
28: fsck -p
29: case $? in
30: 0)
31: ;;
32: 2)
33: exit 1
34: ;;
35: 4)
36: echo "Rebooting..."
37: reboot
38: echo "Reboot failed; help!"
39: exit 1
40: ;;
41: 8)
42: echo "Automatic file system check failed; help!"
43: exit 1
44: ;;
45: 12)
46: echo "Boot interrupted."
47: exit 1
48: ;;
49: 130)
50: # interrupt before catcher installed
51: exit 1
52: ;;
53: *)
54: echo "Unknown error; help!"
55: exit 1
56: ;;
57: esac
58: fi
59:
60: trap "echo 'Boot interrupted.'; exit 1" 3
61:
62: swapon -a
63:
64: umount -a >/dev/null 2>&1
65: mount -a -t nonfs
66: rm -f /fastboot # XXX (root now writeable)
67:
68: # set flags on ttys. (do early, in case they use tty for SLIP in netstart)
69: echo 'setting tty flags'
70: ttyflags -a
71:
72: # set hostname, turn on network
73: echo 'starting network'
74: . /etc/netstart
75:
76: mount /usr >/dev/null 2>&1
77: mount /var >/dev/null 2>&1
78:
1.5 dm 79: if [ X"${ipfilter}" = X"YES" -a X"${ipmon_flags}" != X"NO" ]; then
80: ipmon ${ipmon_flags} &
81: fi
82:
1.1 deraadt 83: # clean up left-over files
84: rm -f /etc/nologin
85: rm -f /var/spool/lock/LCK.*
86: rm -f /var/spool/uucp/STST/*
87: (cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; })
88:
89: echo -n 'starting rpc daemons:'
90: echo -n ' portmap'; portmap
91:
1.9 deraadt 92: if [ -d /var/yp/binding ]; then
1.8 deraadt 93: echo -n ' ypbind'; ypbind
94:
95: if [ -d /var/yp/`domainname` ]; then
96: # yp server capabilities needed...
1.10 deraadt 97: echo -n ' ypserv'; ypserv -d
1.16 deraadt 98: #echo -n ' ypxfrd'; ypxfrd
1.8 deraadt 99:
100: # if we are the master server, run rpc.yppasswdd
101: _host1=`ypwhich -m passwd 2> /dev/null`
102: _host2=`hostname`
1.15 deraadt 103: if [ `grep '^lookup' /etc/resolv.conf | grep yp | wc -c` -ne 0 ]; then
1.8 deraadt 104: _host1=`ypmatch $_host1 hosts | cut -d' ' -f2`
105: _host2=`ypmatch $_host2 hosts | cut -d' ' -f2 | head -1`
106: else
107: _host1=`nslookup $_host1 | grep '^Name: ' | \
108: sed -e 's/^Name: //'`
109: _host2=`nslookup $_host2 | grep '^Name: ' | \
110: sed -e 's/^Name: //'`
111: fi
1.13 deraadt 112: if [ "$_host2" = "$_host1" ]; then
1.10 deraadt 113: echo -n ' rpc.yppasswdd'; rpc.yppasswdd
1.8 deraadt 114: fi
1.7 deraadt 115: fi
1.1 deraadt 116: fi
117:
118: # $nfs_server is imported from /etc/netstart;
119: # if $nfs_server == YES, the machine is setup for being an nfs server
120: if [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then
121: rm -f /var/db/mountdtab
122: echo -n > /var/db/mountdtab
123: echo -n ' mountd'; mountd
124: echo -n ' nfsd'; nfsd -tun 4
125: fi
126:
127: # $nfs_client is imported from /etc/netstart;
128: # if $nfs_client == YES, the machine is setup for being an nfs client
129: if [ X${nfs_client} = X"YES" ]; then
130: echo -n ' nfsiod'; nfsiod -n 4
131: fi
132:
133: if [ X${amd} = X"YES" -a -d ${amd_dir} -a -r ${amd_master} ]; then
134: echo -n ' amd'
135: amd -l syslog -x error,noinfo,nostats -p \
136: -a ${amd_dir} `cat ${amd_master}` > /var/run/amd.pid
137: fi
138:
139: echo '.'
140: mount -a -t nfs
141:
142: echo -n 'starting system logger'
143: rm -f /dev/log
1.18 ! deraadt 144: syslogd -s # "-s" is for greater security
1.1 deraadt 145:
146: # $timed_flags is imported from /etc/netstart;
147: # if $timed_flags == NO, timed isn't run.
148: if [ "X${timed_flags}" != X"NO" ]; then
149: echo -n ', time daemon'; timed $timed_flags
150: fi
151: echo '.'
152:
153: # /var/crash should be a directory or a symbolic link
154: # to the crash directory if core dumps are to be saved.
155: if [ -d /var/crash ]; then
156: echo checking for core dump...
157: savecore /var/crash
158: fi
159:
160: echo -n 'checking quotas:'
161: quotacheck -a
162: echo ' done.'
163: quotaon -a
164:
165: # build ps databases
166: echo 'building databases...'
1.2 deraadt 167: kvm_mkdb /bsd
1.1 deraadt 168: dev_mkdb
169:
170: chmod 666 /dev/tty[pqrs]*
171:
172: # check the password temp/lock file
1.17 deraadt 173: if [ -f /etc/ptmp ]; then
1.1 deraadt 174: logger -s -p auth.err \
175: 'password file may be incorrect -- /etc/ptmp exists'
176: fi
177:
178: virecovery=/var/tmp/vi.recover/recover.*
179: if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
180: echo preserving editor files
181: for i in $virecovery; do
182: sendmail -t < $i
183: done
184: fi
185:
186: echo clearing /tmp
187:
188: # prune quickly with one rm, then use find to clean up /tmp/[lq]*
189: # (not needed with mfs /tmp, but doesn't hurt there...)
190: (cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
191: find . ! -name . ! -name lost+found ! -name quota.user \
192: ! -name quota.group -exec rm -rf -- {} \; -type d -prune)
193:
194: if [ -f /var/account/acct ]; then
195: echo 'turning on accounting'; accton /var/account/acct
196: fi
197:
198: echo -n standard daemons:
199: echo -n ' cron'; cron
200: echo '.'
201:
202: echo -n starting network daemons:
203:
204: # $gated and $routed_flags are imported from /etc/netstart.
205: # If $gated == YES, gated is used; otherwise routed.
206: # If $routed_flags == NO, routed isn't run.
207: if [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
208: echo -n ' gated'; gated $gated_flags
209: elif [ "X${routed_flags}" != X"NO" ]; then
210: echo -n ' routed'; routed $routed_flags
211: fi
212:
1.4 deraadt 213: # $mrouted_flags is imported from /etc/netstart;
214: # If $mrouted_flags == NO, then mrouted isn't run.
215: if [ "X${mrouted_flags}" != X"NO" ]; then
216: echo -n ' mrouted'; mrouted $mrouted_flags
217: fi
218:
219: # $named_flags is imported from /etc/netstart;
1.1 deraadt 220: # if $named_flags != NO, named is run.
221: if [ "X${named_flags}" != X"NO" ]; then
222: echo -n ' named'; named $named_flags
223: fi
224:
225: # $rwhod is imported from /etc/netstart;
226: # if $rwhod == YES, rwhod is run.
227: if [ X${rwhod} = X"YES" ]; then
228: echo -n ' rwhod'; rwhod
229: fi
230:
231: echo -n ' printer'; lpd
232:
233: # $sendmail_flags is imported from /etc/netstart;
234: # If $sendmail_flags == NO or /etc/sendmail.cf doesn't exist, then
1.6 deraadt 235: # sendmail isn't run. We call sendmail with a full path so that
236: # SIGHUP works.
1.1 deraadt 237: if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
1.6 deraadt 238: echo -n ' sendmail'; /usr/sbin/sendmail ${sendmail_flags}
1.1 deraadt 239: fi
240:
241: echo -n ' inetd'; inetd
242:
243: # $rarpd_flags is imported from /etc/netstart;
244: # If $rarpd_flags == NO or /etc/ethers doesn't exist, then
245: # rarpd isn't run.
246: if [ "X${rarpd_flags}" != X"NO" -a -r /etc/ethers ]; then
247: echo -n ' rarpd'; rarpd ${rarpd_flags}
248: fi
249:
250: # $bootparamd_flags is imported from /etc/netstart;
251: # If $bootparamd_flags == NO or /etc/bootparams doesn't exist, then
252: # bootparamd isn't run.
253: if [ "X${bootparamd_flags}" != X"NO" -a -r /etc/bootparams ]; then
254: echo -n ' rpc.bootparamd'; rpc.bootparamd ${bootparamd_flags}
255: fi
256:
257: # $rbootd_flags is imported from /etc/netstart;
258: # If $rbootd_flags == NO or /etc/rbootd.conf doesn't exist, then
259: # rbootd isn't run.
260: if [ "X${rbootd_flags}" != X"NO" -a -r /etc/rbootd.conf ]; then
261: echo -n ' rbootd'; rbootd ${rbootd_flags}
262: fi
263:
264: echo '.'
265:
1.12 deraadt 266: if [ -f /sbin/kbd -a -f /etc/kbdtype ]; then
267: kbd `cat /etc/kbdtype`
268: fi
1.17 deraadt 269:
270: # patch /etc/motd
271: if [ ! -f /etc/motd ]; then
272: install -c -o root -g wheel -m 664 /dev/null /etc/motd
273: fi
274: T=/tmp/_motd
275: rm -f $T
276: sysctl -n kern.version | sed 1q > $T
277: echo "" >> $T
278: sed '1,/^$/d' < /etc/motd >> $T
279: cmp -s $T /etc/motd || cp $T /etc/motd
280: rm -f $T
281:
282: if [ -f /sbin/ldconfig ]; then
283: echo 'creating runtime link editor directory cache.'
284: ldconfig /usr/X11R6/lib
285: fi
286:
287: # Kerberos runs ONLY on the Kerberos server machine
288: if [ X${kerberos_server} = X"YES" ]; then
289: echo 'kerberos server'; kerberos >> /var/log/kerberos.log &
290: fi
291:
292: . /etc/rc.local
1.1 deraadt 293:
294: date
295: exit 0