2 # $Id: rc,v 1.159 1998/10/08 18:47:29 des Exp $
3 # From: @(#)rc 5.27 (Berkeley) 6/5/91
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.
10 # Note that almost all the user-configurable behavior is no longer in
11 # this file, but rather in /etc/rc.conf. Please check this file
12 # first before contemplating any changes here.
16 # Set shell to ignore SIGINT (2), but not children;
17 # shell catches SIGQUIT (3) and returns to single user after fsck.
19 trap : 3 # shouldn't be needed
22 PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin
25 # Configure ccd devices.
26 if [ -f /etc/ccd.conf ]; then
32 if [ $1x = autobootx ]; then
33 echo Automatic reboot in progress...
43 echo "reboot failed... help!"
47 echo "Automatic file system check failed... help!"
51 echo "Reboot interrupted"
55 # interrupt before catcher installed
59 echo "Unknown error in reboot"
64 echo Skipping disk checks ...
67 trap "echo 'Reboot interrupted'; exit 1" 3
69 # root must be read/write both for NFS diskless and for VFS LKMs before
70 # proceeding any further.
73 echo "Filesystem mount failed, startup aborted"
77 umount -a >/dev/null 2>&1
81 echo "Filesystem mount failed, startup aborted"
85 # If there is a global system configuration file, suck it in.
86 if [ -f /etc/rc.conf ]; then
90 # If old file exists, whine until they fix it.
91 if [ -f /etc/sysconfig ]; then
92 echo "Warning: /etc/sysconfig has been replaced by /etc/rc.conf."
93 echo "You should switch to /etc/rc.conf ASAP to eliminate this warning."
99 if [ ! -f /var/run/clean_var ]; then
101 rm -f /var/spool/lock/*
102 rm -rf /var/spool/uucp/.Temp/*
103 # Keep a copy of the boot messages around
104 dmesg >/var/run/dmesg.boot
105 # And an initial utmp file
106 (cd /var/run && cp /dev/null utmp && chmod 644 utmp; )
111 if [ -d /var/run -a -d /var/spool/lock -a -d /var/spool/uucp/.Temp ]; then
112 # network_pass1() *may* end up writing stuff to /var - we don't want to
113 # remove it immediately afterwards - *nor* to we want to fail to clean
114 # an nfs-mounted /var.
118 # Add additional swapfile, if configured.
119 if [ "x$swapfile" != "xNO" -a -w "$swapfile" -a -b /dev/vn0b ]; then
120 echo "Adding $swapfile as additional swap."
121 vnconfig /dev/vn0b $swapfile && swapon /dev/vn0b
124 # configure serial devices
125 if [ -f /etc/rc.serial ]; then
129 # start up PC-card configuration
130 if [ -f /etc/rc.pccard ]; then
134 # start up the initial network configuration.
135 if [ -f /etc/rc.network ]; then
136 . /etc/rc.network # We only need to do this once.
140 echo -n "Mounting NFS file systems"
144 # Whack the pty perms back into shape.
145 chmod 666 /dev/tty[pqrsPQRS]*
147 # clean up left-over files
150 clean_var # If it hasn't already been done
151 rm /var/run/clean_var
154 # Clearing /tmp at boot-time seems to have a long tradition. It doesn't
155 # help in any way for long-living systems, and it might accidentally
156 # clobber files you would rather like to have preserved after a crash
157 # (if not using mfs /tmp anyway).
159 # See also the example of another cleanup policy in /etc/periodic/daily.
161 if [ "X${clear_tmp_enable}" = X"YES" ]; then
164 # prune quickly with one rm, then use find to clean up /tmp/[lq]*
165 # (not needed with mfs /tmp, but doesn't hurt there...)
166 (cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
167 find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;)
171 # Remove X lock files, since they will prevent you from restarting X11
172 # after a system crash.
173 rm -f /tmp/.X*-lock /tmp/.X11-unix/*
175 # snapshot any kernel -c changes back to disk
176 echo 'recording kernel -c changes'
179 echo -n 'additional daemons:'
180 # start system logging and name service (named needs to start before syslogd
181 # if you don't have a /etc/resolv.conf)
183 if [ "X${syslogd_enable}" = X"YES" ]; then
184 # Transitional symlink (for the next couple of years :) until all
185 # binaries had a chance to move towards /var/run/log.
186 if [ ! -h /dev/log ] ; then
187 # might complain for r/o root f/s
188 ln -sf /var/run/log /dev/log
192 echo -n ' syslogd'; syslogd ${syslogd_flags}
196 # enable dumpdev so that savecore can see it
197 # /var/crash should be a directory or a symbolic link
198 # to the crash directory if core dumps are to be saved.
199 if [ "X${dumpdev}" != X"NO" -a -e ${dumpdev} -a -d /var/crash ]; then
201 echo -n checking for core dump...
205 if [ -n "$network_pass1_done" ]; then
209 # Check the quotas (must be after ypbind if using NIS)
210 if [ "X${check_quotas}" = X"YES" ]; then
211 echo -n 'checking quotas:'
217 if [ -n "$network_pass2_done" ]; then
226 # check the password temp/lock file
229 logger -s -p auth.err \
230 "password file may be incorrect -- /etc/ptmp exists"
233 if [ "X${accounting_enable}" = X"YES" -a -d /var/account ]; then
234 echo 'turning on accounting'
235 if [ ! -e /var/account/acct ]; then
236 touch /var/account/acct
238 accton /var/account/acct
241 # Make shared lib searching a little faster. Leave /usr/lib first if you
242 # add your own entries or you may come to grief.
243 if [ -x /sbin/ldconfig ]; then
244 if [ X"`/usr/bin/objformat`" = X"elf" ]; then
246 for i in $ldconfig_paths; do
251 echo 'setting ELF ldconfig path:' ${_LDC}
252 ldconfig -elf ${_LDC}
255 # Default the a.out ldconfig path, in case the system's
256 # /etc/rc.conf hasn't been updated.
257 : ${ldconfig_paths_aout=${ldconfig_paths}}
259 for i in $ldconfig_paths_aout; do
264 echo 'setting a.out ldconfig path:' ${_LDC}
265 ldconfig -aout ${_LDC}
268 # Now start up miscellaneous daemons that don't belong anywhere else
270 echo -n starting standard daemons:
271 if [ "X${inetd_enable}" != X"NO" ]; then
272 echo -n ' inetd'; inetd ${inetd_flags}
275 if [ "X${cron_enable}" != X"NO" ]; then
276 echo -n ' cron'; cron
279 if [ "X${lpd_enable}" = X"YES" ]; then
280 echo -n ' printer'; lpd ${lpd_flags}
283 if [ "X${sendmail_enable}" = X"YES" -a -r /etc/sendmail.cf ]; then
284 echo -n ' sendmail'; /usr/sbin/sendmail ${sendmail_flags}
289 # configure implementation specific stuff
291 if [ -f /etc/rc.${arch} ]; then
295 # Recover vi editor files.
296 vibackup=`echo /var/tmp/vi.recover/vi.*`
297 if [ "$vibackup" != '/var/tmp/vi.recover/vi.*' ]; then
298 echo 'Recovering vi editor sessions'
299 for i in $vibackup; do
300 # Only test files that are readable.
301 if test ! -r $i; then
305 # Unmodified nvi editor backup files either have the
306 # execute bit set or are zero length. Delete them.
307 if test -x $i -o ! -s $i; then
312 # It is possible to get incomplete recovery files, if the editor
313 # crashes at the right time.
314 virecovery=`echo /var/tmp/vi.recover/recover.*`
315 if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
316 for i in $virecovery; do
317 # Only test files that are readable.
318 if test ! -r $i; then
322 # Delete any recovery files that are zero length,
323 # corrupted, or that have no corresponding backup file.
324 # Else send mail to the user.
325 recfile=`awk '/^X-vi-recover-path:/{print $2}' < $i`
326 if test -n "$recfile" -a -s "$recfile"; then
335 # make a bounds file for msgs(1) if there isn't one already
336 if [ ! -f /var/msgs/bounds ]; then
337 echo 0 > /var/msgs/bounds
340 # for each valid dir in $local_startup, search for init scripts matching *.sh
341 if [ "X${local_startup}" != X"NO" ]; then
342 echo -n 'Local package initialization:'
343 for dir in ${local_startup}; do
344 [ -d ${dir} ] && for script in ${dir}/*.sh; do
345 [ -x ${script} ] && \
346 (trap 'exit 1' 2 ; ${script} start ; echo -n)
352 # Run rc.devfs if present to customify devfs
353 [ -f /etc/rc.devfs ] && sh /etc/rc.devfs
355 # Do traditional (but rather obsolete) rc.local file if it exists.
356 [ -f /etc/rc.local ] && sh /etc/rc.local
358 # Raise kernel security level. This should be done only after `fsck' has
359 # repaired local file systems if you want the securelevel to be greater than 1.
360 if [ "X${kern_securelevel_enable}" = X"YES" -a "${kern_securelevel}" -ge 0 ];
362 echo 'Raising kernel security level'
363 sysctl -w kern.securelevel=${kern_securelevel}