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