]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - etc/rc
daily:
[FreeBSD/FreeBSD.git] / etc / rc
1 #!/bin/sh
2 #       $Id: rc,v 1.35 1994/10/25 08:23:02 davidg Exp $
3 #       From: @(#)rc    5.27 (Berkeley) 6/5/91
4
5 # System startup script run by init on autoboot
6 # or after single-user.
7 # Output and error are redirected to console by init,
8 # and the console is the controlling terminal.
9
10 stty status '^T'
11
12 # Set shell to ignore SIGINT (2), but not children;
13 # shell catches SIGQUIT (3) and returns to single user after fsck.
14 trap : 2
15 trap : 3        # shouldn't be needed
16
17 HOME=/; export HOME
18 PATH=/sbin:/bin:/usr/sbin:/usr/bin
19 export PATH
20
21 swapon -a
22
23 if [ $1x = autobootx ]
24 then
25         echo Automatic reboot in progress...
26         fsck -p
27         case $? in
28         0)
29                 ;;
30         2)
31                 exit 1
32                 ;;
33         4)
34                 reboot
35                 echo "reboot failed... help!"
36                 exit 1
37                 ;;
38         8)
39                 echo "Automatic file system check failed... help!"
40                 exit 1
41                 ;;
42         12)
43                 echo "Reboot interrupted"
44                 exit 1
45                 ;;
46         130)
47                 # interrupt before catcher installed
48                 exit 1
49                 ;;
50         *)
51                 echo "Unknown error in reboot"
52                 exit 1
53                 ;;
54         esac
55 else
56         echo Skipping disk checks ...
57 fi
58
59 trap "echo 'Reboot interrupted'; exit 1" 3
60
61 # root must be read/write both for NFS diskless and for VFS LKMs before
62 # proceeding any further.
63 mount -u -o rw /
64
65 umount -a >/dev/null 2>&1
66 mount -a -t nonfs
67
68 # This stuff needed for proper daemons tuning, comsat f.e.
69 # See profile and csh.login also.
70 # Uncomment next line if you want to setup your 8-bit locale at program
71 # startup automatically
72 # ENABLE_STARTUP_LOCALE=; export ENABLE_STARTUP_LOCALE
73 # Uncomment next line to activate russian locale
74 # LANG=ru_SU.KOI8-R; export LANG
75
76 # If the machine runs wall CMOS clock (compatible with MSDOS),
77 # activate following line by creating empty file /etc/wall_cmos_clock
78 # If this file not exist, following line does nothing (assumed
79 # the machine runs UTC CMOS clock). See adjkerntz(8) for details.
80 adjkerntz -i
81
82 # configure serial devices
83 if [ -f /etc/rc.serial ]
84 then
85         sh /etc/rc.serial
86 fi
87
88 # set hostname, turn on network
89 echo 'starting network'
90 . /etc/netstart
91
92 # clean up left-over files
93 rm -f /etc/nologin
94 rm -f /var/spool/lock/*
95 rm -f /var/spool/uucp/.Temp/*
96 (cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; })
97
98 echo -n 'starting system logger'
99 rm -f /dev/log
100 syslogd
101
102 # $timedflags is imported from /etc/netstart;
103 # if $timedflags == NO, timed isn't run.
104 if [ X${timedflags} != X"NO" ]; then
105         echo -n ', time daemon'; timed $timedflags
106 fi
107 echo '.'
108
109 # /var/crash should be a directory or a symbolic link
110 # to the crash directory if core dumps are to be saved.
111 if [ -d /var/crash ]; then
112         echo checking for core dump...
113         savecore /var/crash
114 fi
115
116 #                               echo -n 'checking quotas:'
117 #quotacheck -a
118 #                               echo ' done.'
119 #quotaon -a
120
121 # build ps databases
122 kvm_mkdb 
123 dev_mkdb
124
125 chmod 666 /dev/tty[pqrs]*
126
127 # check the password temp/lock file
128 if [ -f /etc/ptmp ]
129 then
130         logger -s -p auth.err \
131         'password file may be incorrect -- /etc/ptmp exists'
132 fi
133
134 # Recover vi editor files.
135 virecovery=/var/tmp/vi.recover/recover.*
136 if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
137         echo 'Recovering vi editor sessions'
138         for i in $virecovery; do
139                 sendmail -t < $i
140         done
141 fi
142
143 echo clearing /tmp
144
145 # prune quickly with one rm, then use find to clean up /tmp/[lq]*
146 # (not needed with mfs /tmp, but doesn't hurt there...)
147 (cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
148     find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;)
149
150 # echo 'turning on accounting'; accton /var/account/acct
151
152 echo -n standard daemons:
153 echo -n ' cron';                cron
154 echo '.'
155
156 echo -n starting network daemons:
157
158 # Portmapper should always be run, to provide RPC services for inetd.
159 if [ -x /usr/sbin/portmap ]; then
160         echo -n ' portmap';             portmap
161 fi
162
163 # $gated and $routedflags are imported from /etc/netstart.
164 # If $gated == YES, gated is used; otherwise routed.
165 # If $routedflags == NO, routed isn't run.
166 if [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
167         echo -n ' gated';       gated $gatedflags
168 elif [ X"${routedflags}" != X"NO" ]; then
169         echo -n ' routed';      routed $routedflags
170 fi
171
172 if [ X${name_server} = X"YES" -a -r /etc/named.boot ]; then
173         echo -n ' named';               named
174 fi
175
176 # $ntpdate and $xntpdflags are imported from /etc/netstart.
177 # If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly.
178 # If $xntpdflags != NO, start xntpd.
179 if [ X"${ntpdate}" != X"NO" ]; then
180         echo ' ntpdate';        ntpdate $ntpdate
181 fi
182
183 if [ X"${xntpdflags}" != X"NO" ]; then
184         if [ X"${tickadjflags}" != X"NO" ]; then
185                 echo 'adjusting kernel for xntpd'; tickadj ${tickadjflags--A}
186         fi
187         echo 'starting xntpd';  xntpd ${xntpdflags}
188 fi
189
190 if [ X"${ntpdate}" != X"NO" -o X"${xntpdflags}" != X"NO" ]; then
191         echo -n 'starting more network daemons:'
192 fi
193
194 # $rwhod is imported from /etc/netstart;
195 # if $rwhod is set to something other than NO, rwhod is run.
196 if [ ${rwhod-NO} != "NO" ]; then
197         echo -n ' rwhod';       rwhod
198 fi
199
200 echo -n ' printer';             lpd
201
202 if [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then
203         echo -n ' mountd';              mountd
204         echo -n ' nfsd';                nfsd -u -t 4
205 fi
206
207 if [ X"${nfs_client}" != X"NO" ]; then
208         echo -n ' nfsiod';              nfsiod -n 4
209 fi
210
211 if [ X"${amdflags}" != X"NO" ]; then
212         echo -n ' amd';                 amd ${amdflags}
213 fi
214
215 # $sendmail_flags is imported from /etc/netstart;
216 # if $sendmail_flags is something other than NO, sendmail is run.
217 if [ X"${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then
218         echo -n ' sendmail';            sendmail ${sendmail_flags} 
219 fi
220
221 echo -n ' inetd';               inetd
222 echo '.'
223
224 mount -a -t nfs >/dev/null 2>&1 &       # XXX shouldn't need background
225
226 # if [ -x /usr/libexec/xtend ]; then
227 #       echo -n ' xtend';   /usr/libexec/xtend
228 # fi
229
230 # Make shared lib searching a little faster.  Leave /usr/lib first if you
231 # add your own entries or you may come to grief.
232 if [ -x /sbin/ldconfig ]; then
233         _LDC=/usr/lib
234         if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi
235         if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi
236         if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi
237         if [ -d /usr/gnu/lib ]; then _LDC="${_LDC} /usr/gnu/lib" ; fi
238         echo 'setting ldconfig path:' ${_LDC}
239         ldconfig ${_LDC}
240 fi
241
242 sh /etc/rc.local
243
244 date
245
246 exit 0