no copyright needed
[unix-history] / usr / src / etc / rc
CommitLineData
d9adb69d 1# @(#)rc 5.32 (Berkeley) %G%
8c5cf0c6 2
a15e1c64
MK
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
f4ff1534
MK
8stty status '^T'
9
a15e1c64
MK
10# Set shell to ignore SIGINT (2), but not children;
11# shell catches SIGQUIT (3) and returns to single user after fsck.
12trap : 2
f4ff1534 13trap : 3 # shouldn't be needed
a15e1c64 14
aa77a7dd 15HOME=/; export HOME
3dc1e9d1 16PATH=/sbin:/bin:/usr/sbin:/usr/bin
1a91d88f 17export PATH
aa77a7dd
KB
18
19if [ -r /fastboot ]
20then
14f88e09 21 echo Fast boot ... skipping disk checks
aa77a7dd
KB
22elif [ $1x = autobootx ]
23then
14f88e09
KB
24 echo Automatic reboot in progress...
25 fsck -p
aa77a7dd
KB
26 case $? in
27 0)
aa77a7dd
KB
28 ;;
29 2)
30 exit 1
31 ;;
32 4)
a15e1c64 33 reboot
14f88e09 34 echo "reboot failed... help!"
eca41594 35 exit 1
aa77a7dd
KB
36 ;;
37 8)
14f88e09 38 echo "Automatic file system check failed... help!"
aa77a7dd
KB
39 exit 1
40 ;;
41 12)
14f88e09 42 echo "Reboot interrupted"
aa77a7dd
KB
43 exit 1
44 ;;
eca41594
MK
45 130)
46 # interrupt before catcher installed
47 exit 1
48 ;;
aa77a7dd 49 *)
14f88e09 50 echo "Unknown error in reboot"
aa77a7dd
KB
51 exit 1
52 ;;
53 esac
aa77a7dd
KB
54fi
55
a15e1c64
MK
56trap "echo 'Reboot interrupted'; exit 1" 3
57
14f88e09 58swapon -a
e6794cca 59
ad4f198f 60umount -a >/dev/null 2>&1
14f88e09 61mount -a -t nonfs
c2ce0042 62rm -f /fastboot # XXX (root now writeable)
e6794cca 63
aa77a7dd 64# set hostname, turn on network
00e5ee90 65echo 'starting network'
aa77a7dd
KB
66. /etc/netstart
67
ad4f198f 68mount -a -t nfs >/dev/null 2>&1 & # XXX shouldn't need background
c404d670 69
c2ce0042
MK
70# clean up left-over files
71rm -f /etc/nologin
72rm -f /var/spool/uucp/LCK.*
73rm -f /var/spool/uucp/STST/*
8b1a3f60 74(cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; })
c2ce0042 75
14f88e09 76echo -n 'starting system logger'
aa77a7dd
KB
77rm -f /dev/log
78syslogd
79
c404d670
MK
80# $timedflags is imported from /etc/netstart;
81# if $timedflags == NO, timed isn't run.
82if [ X${timedflags} != X"NO" ]; then
14f88e09 83 echo -n ', time daemon'; timed $timedflags
c404d670 84fi
14f88e09 85echo '.'
c404d670 86
3dc1e9d1
MK
87# /var/crash should be a directory or a symbolic link
88# to the crash directory if core dumps are to be saved.
aa77a7dd 89if [ -d /var/crash ]; then
f4ff1534 90 echo checking for core dump...
14f88e09 91 savecore /var/crash
aa77a7dd
KB
92fi
93
14f88e09
KB
94 echo -n 'checking quotas:'
95quotacheck -a
96 echo ' done.'
97quotaon -a
5e8595e4 98
d48f0247 99# build ps databases
86154b6e 100kvm_mkdb
e0804fa4 101dev_mkdb
5e8595e4
KB
102
103chmod 666 /dev/tty[pqrs]*
104
eca41594
MK
105# check the password temp/lock file
106if [ -f /etc/ptmp ]
107then
108 logger -s -p auth.err \
14f88e09 109 'password file may be incorrect -- /etc/ptmp exists'
eca41594
MK
110fi
111
14f88e09 112echo preserving editor files
c2ce0042
MK
113(cd /var/tmp && /usr/libexec/ex3.7preserve -a &&
114 rm -f Ex[0-9][0-9][0-9][0-9][0-9] Rx[0-9][0-9][0-9][0-9][0-9])
c404d670 115
14f88e09
KB
116echo clearing /tmp
117
ab96cd9f
KB
118# Prune quickly with one rm, then use find to clean up /tmp/[lq]* (this
119# is not needed with mfs /tmp, but doesn't hurt anything).
c2ce0042 120(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
ab96cd9f
KB
121 find . ! -name . ! -name lost+found ! -name quotas -type d -prune \
122 -exec rm -rf -- {} \;)
aa77a7dd 123
14f88e09
KB
124echo 'turning on accounting'; accton /var/account/acct
125
126echo -n standard daemons:
127echo -n ' update'; update
128echo -n ' cron'; cron
129echo '.'
aa77a7dd 130
14f88e09 131echo -n starting network daemons:
aa77a7dd 132
2fef9d3c
MK
133# $gated and $routedflags are imported from /etc/netstart.
134# If $gated == YES, gated is used; otherwise routed.
135# If $routedflags == NO, routed isn't run.
136if [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
c2ce0042 137 echo -n ' gated'; gated $gatedflags
2fef9d3c 138elif [ X${routedflags} != X"NO" ]; then
14f88e09 139 echo -n ' routed'; routed $routedflags
aa77a7dd
KB
140fi
141
14f88e09 142echo -n ' named'; named
aa77a7dd
KB
143
144# $rwhod is imported from /etc/netstart;
145# if $rwhod is set to something other than NO, rwhod is run.
146if [ ${rwhod-NO} != "NO" ]; then
14f88e09 147 echo -n ' rwhod'; rwhod
aa77a7dd
KB
148fi
149
14f88e09
KB
150echo -n ' printer'; lpd
151
ad4f198f 152echo -n ' portmap'; portmap
14f88e09 153echo -n ' mountd'; mountd
d9adb69d 154echo -n ' nfsd'; nfsd -u -t 6
14f88e09
KB
155echo -n ' nfsiod'; nfsiod 4
156
157echo -n ' sendmail'; sendmail -bd -q30m
f4ff1534 158echo -n ' inetd'; inetd
d9adb69d
KB
159echo -n ' amd';
160 cd /; amd -l /var/log/amd -r -a /amd -p > /var/run/amd.pid \
161 /home /etc/amd-home \
162 &
163# /n /etc/amd-n \
164# /vol /etc/amd-vol \
165
14f88e09 166echo '.'
aa77a7dd
KB
167
168sh /etc/rc.local
169
14f88e09 170date
aa77a7dd 171exit 0