Annotation of src/etc/rc, Revision 1.59
1.59 ! downsj 1: # $OpenBSD: rc,v 1.58 1997/12/21 06:40:50 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."
1.31 millert 28: fsck -p
1.1 deraadt 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
1.57 niklas 66: mount -uw / # root on nfs requires this, others aren't hurt
1.1 deraadt 67: rm -f /fastboot # XXX (root now writeable)
68:
69: # set flags on ttys. (do early, in case they use tty for SLIP in netstart)
70: echo 'setting tty flags'
71: ttyflags -a
72:
73: # set hostname, turn on network
74: echo 'starting network'
75: . /etc/netstart
76:
77: mount /usr >/dev/null 2>&1
78: mount /var >/dev/null 2>&1
1.29 deraadt 79:
1.55 deraadt 80: # clean up left-over files
81: rm -f /etc/nologin
82: rm -f /var/spool/lock/LCK.*
83: rm -f /var/spool/uucp/STST/*
84: (cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; })
85:
1.58 deraadt 86: echo 'starting system logger'
87: rm -f /dev/log
88: syslogd
89:
1.54 deraadt 90: # $named_flags is imported from /etc/rc.conf;
91: # if $named_flags != NO, named is run.
92: if [ "X${named_flags}" != X"NO" ]; then
1.58 deraadt 93: echo 'starting named'; named $named_flags
1.54 deraadt 94: fi
95:
1.29 deraadt 96: # /etc/ifaliases, if it exists, contains the names of additional IP
97: # addresses for each interface. It is formatted as a series of lines
98: # that contain
99: # interface address netmask
100: if [ -f /etc/ifaliases ]; then
101: (
102: # delete comments and blank lines
103: set -- `sed -e 's/#.*$//' /etc/ifaliases | grep -v '^$'`
104: while [ $# -ge 3 ] ; do
105: ifconfig $1 inet alias $2 netmask $3
1.44 millert 106: route add -host $2 localhost
1.29 deraadt 107: shift 3
108: done
109: )
110: fi
1.1 deraadt 111:
1.5 dm 112: if [ X"${ipfilter}" = X"YES" -a X"${ipmon_flags}" != X"NO" ]; then
1.43 mickey 113: echo 'starting ipmon'; ipmon ${ipmon_flags}
1.25 deraadt 114: fi
115:
116: if [ X"${rfc1323}" = X"NO" ]; then
117: echo 'disabling rfc1323'; sysctl -w net.inet.tcp.rfc1323=0
1.5 dm 118: fi
119:
1.52 deraadt 120: # $photurisd_flags is imported from /etc/rc.conf;
1.45 kstailey 121: # If $photurisd_flags == NO or /etc/photuris/photuris.conf doesn't exist, then
1.40 provos 122: # photurisd isn't run.
1.45 kstailey 123: if [ "X${photurisd_flags}" != X"NO" -a -e /etc/photuris/photuris.conf ]; then
1.40 provos 124: echo 'starting photurisd'; photurisd ${photurisd_flags}
125: fi
1.1 deraadt 126:
127: echo -n 'starting rpc daemons:'
1.24 millert 128:
1.52 deraadt 129: # $portmap is imported from /etc/rc.conf;
1.24 millert 130: # if $portmap == YES, the portmapper is started.
131: if [ X"${portmap}" = X"YES" ]; then
1.23 deraadt 132: echo -n ' portmap'; portmap
133: fi
1.1 deraadt 134:
1.9 deraadt 135: if [ -d /var/yp/binding ]; then
1.8 deraadt 136: if [ -d /var/yp/`domainname` ]; then
137: # yp server capabilities needed...
1.36 niklas 138: echo -n ' ypserv'; ypserv ${ypserv_flags}
1.16 deraadt 139: #echo -n ' ypxfrd'; ypxfrd
1.21 deraadt 140: fi
141:
142: echo -n ' ypbind'; ypbind
1.8 deraadt 143:
1.21 deraadt 144: if [ -d /var/yp/`domainname` ]; then
1.8 deraadt 145: # if we are the master server, run rpc.yppasswdd
146: _host1=`ypwhich -m passwd 2> /dev/null`
147: _host2=`hostname`
1.15 deraadt 148: if [ `grep '^lookup' /etc/resolv.conf | grep yp | wc -c` -ne 0 ]; then
1.8 deraadt 149: _host1=`ypmatch $_host1 hosts | cut -d' ' -f2`
150: _host2=`ypmatch $_host2 hosts | cut -d' ' -f2 | head -1`
151: else
152: _host1=`nslookup $_host1 | grep '^Name: ' | \
153: sed -e 's/^Name: //'`
154: _host2=`nslookup $_host2 | grep '^Name: ' | \
155: sed -e 's/^Name: //'`
156: fi
1.13 deraadt 157: if [ "$_host2" = "$_host1" ]; then
1.35 niklas 158: echo -n ' rpc.yppasswdd'
159: rpc.yppasswdd ${yppasswdd_flags}
1.8 deraadt 160: fi
1.7 deraadt 161: fi
1.1 deraadt 162: fi
163:
1.52 deraadt 164: # $nfs_server is imported from /etc/rc.conf;
1.1 deraadt 165: # if $nfs_server == YES, the machine is setup for being an nfs server
1.46 deraadt 166: if [ X${nfs_server} = X"YES" -a -r /etc/exports -a \
1.47 deraadt 167: `cat /etc/exports | sed -e '/^#/d' | wc -l` -ne 0 ]; then
1.1 deraadt 168: rm -f /var/db/mountdtab
169: echo -n > /var/db/mountdtab
170: echo -n ' mountd'; mountd
1.42 niklas 171: echo -n ' nfsd'; nfsd ${nfsd_flags}
172: if [ X${lockd} = X"YES" ]; then
173: echo -n ' rpc.lockd'; rpc.lockd
174: fi
1.1 deraadt 175: fi
176:
1.52 deraadt 177: # $nfs_client is imported from /etc/rc.conf;
1.1 deraadt 178: # if $nfs_client == YES, the machine is setup for being an nfs client
179: if [ X${nfs_client} = X"YES" ]; then
1.59 ! downsj 180: echo -n ' nfsiod'; nfsiod ${nfsiod_flags}
1.1 deraadt 181: fi
182:
183: if [ X${amd} = X"YES" -a -d ${amd_dir} -a -r ${amd_master} ]; then
184: echo -n ' amd'
185: amd -l syslog -x error,noinfo,nostats -p \
186: -a ${amd_dir} `cat ${amd_master}` > /var/run/amd.pid
187: fi
188:
1.52 deraadt 189: # $timed_flags is imported from /etc/rc.conf;
1.1 deraadt 190: # if $timed_flags == NO, timed isn't run.
191: if [ "X${timed_flags}" != X"NO" ]; then
1.58 deraadt 192: echo -n ' timed'; timed $timed_flags
1.1 deraadt 193: fi
194: echo '.'
1.58 deraadt 195:
196: mount -a -t nfs
1.1 deraadt 197:
198: # /var/crash should be a directory or a symbolic link
199: # to the crash directory if core dumps are to be saved.
200: if [ -d /var/crash ]; then
201: echo checking for core dump...
202: savecore /var/crash
203: fi
204:
1.41 downsj 205: if [ "X${check_quotas}" = X"YES" ]; then
206: echo -n 'checking quotas:'
207: quotacheck -a
208: echo ' done.'
209: quotaon -a
210: fi
1.1 deraadt 211:
212: # build ps databases
213: echo 'building databases...'
1.2 deraadt 214: kvm_mkdb /bsd
1.1 deraadt 215: dev_mkdb
216:
217: chmod 666 /dev/tty[pqrs]*
218:
219: # check the password temp/lock file
1.17 deraadt 220: if [ -f /etc/ptmp ]; then
1.1 deraadt 221: logger -s -p auth.err \
222: 'password file may be incorrect -- /etc/ptmp exists'
1.32 deraadt 223: fi
224:
1.49 millert 225: echo clearing /tmp
226:
227: # prune quickly with one rm, then use find to clean up /tmp/[lq]*
228: # (not needed with mfs /tmp, but doesn't hurt there...)
229: (cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
230: find . ! -name . ! -name lost+found ! -name quota.user \
231: ! -name quota.group -exec rm -rf -- {} \; -type d -prune)
232:
1.33 millert 233: test -f /etc/rc.securelevel && . /etc/rc.securelevel
1.32 deraadt 234: if [ X${securelevel} != X"" ]; then
1.33 millert 235: echo -n 'setting kernel security level: '
1.32 deraadt 236: sysctl -w kern.securelevel=${securelevel}
1.1 deraadt 237: fi
238:
1.34 deraadt 239: # patch /etc/motd
240: if [ ! -f /etc/motd ]; then
241: install -c -o root -g wheel -m 664 /dev/null /etc/motd
242: fi
243: T=/tmp/_motd
244: rm -f $T
245: sysctl -n kern.version | sed 1q > $T
246: echo "" >> $T
247: sed '1,/^$/d' < /etc/motd >> $T
248: cmp -s $T /etc/motd || cp $T /etc/motd
249: rm -f $T
250:
1.51 millert 251: # nvi file recovery
1.50 millert 252: if [ ! -d /var/tmp/vi.recover ]; then
253: if [ -e /var/tmp/vi.recover ]; then
254: echo "Warning! /var/tmp/vi.recover is not a directory!"
255: else
256: mkdir /var/tmp/vi.recover
257: chmod 1777 /var/tmp/vi.recover
258: fi
259: fi
1.51 millert 260: vibackup=/var/tmp/vi.recover/vi.*
261: if [ "$vibackup" != "/var/tmp/vi.recover/vi.*" ]; then
262: for i in $vibackup; do
263: # Unmodified nvi editor backup files either have the
264: # execute bit set or are zero length. Delete them.
265: if test -x $i -o ! -s $i; then
266: rm $i
267: fi
268: done
269: fi
1.1 deraadt 270: virecovery=/var/tmp/vi.recover/recover.*
271: if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
272: echo preserving editor files
273: for i in $virecovery; do
1.51 millert 274: # Delete any recovery files that are zero length, corrupted,
275: # or that have no corresponding backup file. Else send mail
276: # to the user.
277: recfile=`awk '/^X-vi-recover-path:/{print $2}' < $i`
278: if test -n "$recfile" -a -s "$recfile"; then
279: sendmail -t < $i
280: else
281: rm $i
282: fi
1.1 deraadt 283: done
284: fi
285:
286: if [ -f /var/account/acct ]; then
287: echo 'turning on accounting'; accton /var/account/acct
288: fi
289:
290: echo -n standard daemons:
291: echo -n ' cron'; cron
292: echo '.'
293:
294: echo -n starting network daemons:
295:
1.52 deraadt 296: # $gated and $routed_flags are imported from /etc/rc.conf.
1.1 deraadt 297: # If $gated == YES, gated is used; otherwise routed.
298: # If $routed_flags == NO, routed isn't run.
299: if [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
300: echo -n ' gated'; gated $gated_flags
301: elif [ "X${routed_flags}" != X"NO" ]; then
302: echo -n ' routed'; routed $routed_flags
303: fi
304:
1.52 deraadt 305: # $mrouted_flags is imported from /etc/rc.conf;
1.4 deraadt 306: # If $mrouted_flags == NO, then mrouted isn't run.
307: if [ "X${mrouted_flags}" != X"NO" ]; then
308: echo -n ' mrouted'; mrouted $mrouted_flags
309: fi
1.1 deraadt 310:
1.52 deraadt 311: # $rwhod is imported from /etc/rc.conf;
1.1 deraadt 312: # if $rwhod == YES, rwhod is run.
313: if [ X${rwhod} = X"YES" ]; then
314: echo -n ' rwhod'; rwhod
315: fi
316:
1.23 deraadt 317:
318: if [ X${lpd} = X"YES" ]; then
319: echo -n ' printer'; lpd
320: fi
1.1 deraadt 321:
1.52 deraadt 322: # $sendmail_flags is imported from /etc/rc.conf;
1.1 deraadt 323: # If $sendmail_flags == NO or /etc/sendmail.cf doesn't exist, then
1.6 deraadt 324: # sendmail isn't run. We call sendmail with a full path so that
325: # SIGHUP works.
1.1 deraadt 326: if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
1.6 deraadt 327: echo -n ' sendmail'; /usr/sbin/sendmail ${sendmail_flags}
1.1 deraadt 328: fi
329:
1.23 deraadt 330: if [ X${inetd} = X"YES" ]; then
331: echo -n ' inetd'; inetd
332: fi
1.1 deraadt 333:
1.52 deraadt 334: # $rarpd_flags is imported from /etc/rc.conf;
1.1 deraadt 335: # If $rarpd_flags == NO or /etc/ethers doesn't exist, then
336: # rarpd isn't run.
337: if [ "X${rarpd_flags}" != X"NO" -a -r /etc/ethers ]; then
338: echo -n ' rarpd'; rarpd ${rarpd_flags}
339: fi
340:
1.52 deraadt 341: # $bootparamd_flags is imported from /etc/rc.conf;
1.1 deraadt 342: # If $bootparamd_flags == NO or /etc/bootparams doesn't exist, then
343: # bootparamd isn't run.
344: if [ "X${bootparamd_flags}" != X"NO" -a -r /etc/bootparams ]; then
345: echo -n ' rpc.bootparamd'; rpc.bootparamd ${bootparamd_flags}
346: fi
347:
1.52 deraadt 348: # $rbootd_flags is imported from /etc/rc.conf;
1.1 deraadt 349: # If $rbootd_flags == NO or /etc/rbootd.conf doesn't exist, then
350: # rbootd isn't run.
351: if [ "X${rbootd_flags}" != X"NO" -a -r /etc/rbootd.conf ]; then
352: echo -n ' rbootd'; rbootd ${rbootd_flags}
1.56 maja 353: fi
354:
355: # $mopd_flags is imported from /etc/rc.conf;
356: # If $mopd_flags == NO or /tftpboot/mop doesn't exist, then
357: # mopd isn't run.
358: if [ "X${mopd_flags}" != X"NO" -a -d /tftpboot/mop ]; then
359: echo -n ' mopd'; mopd ${mopd_flags}
1.37 deraadt 360: fi
361:
362: if [ -x /usr/sbin/screenblank ]; then
363: echo -n ' screenblank'; /usr/sbin/screenblank
1.1 deraadt 364: fi
365:
366: echo '.'
367:
1.12 deraadt 368: if [ -f /sbin/kbd -a -f /etc/kbdtype ]; then
369: kbd `cat /etc/kbdtype`
370: fi
1.17 deraadt 371:
372: if [ -f /sbin/ldconfig ]; then
373: echo 'creating runtime link editor directory cache.'
1.26 deraadt 374: _LIBS=
375: if [ -d /usr/local/lib ]; then
376: _LIBS="$_LIBS /usr/local/lib"
377: fi
378: if [ -d /usr/X11R6/lib ]; then
379: _LIBS="$_LIBS /usr/X11R6/lib"
380: fi
381: ldconfig $_LIBS
1.53 deraadt 382: fi
1.17 deraadt 383:
384: # Kerberos runs ONLY on the Kerberos server machine
385: if [ X${kerberos_server} = X"YES" ]; then
1.30 tholo 386: echo 'kerberos server'
387: kerberos >> /var/log/kerberos.log &
388: kadmind -n >> /var/log/kadmind.log &
1.17 deraadt 389: fi
390:
391: . /etc/rc.local
1.1 deraadt 392:
393: date
394: exit 0