2 # $Id: rc,v 1.131 1997/06/25 11:48:47 pst 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."
100 # Keep a copy of the boot messages around
101 dmesg > /var/run/dmesg.boot
103 # Add additional swapfile, if configured.
104 if [ "x$swapfile" != "xNO" -a -w "$swapfile" -a -b /dev/vn0b ]; then
105 echo "Adding $swapfile as additional swap."
106 vnconfig /dev/vn0b $swapfile && swapon /dev/vn0b
109 # configure serial devices
110 if [ -f /etc/rc.serial ]; then
114 # start up PC-card configuration
115 if [ -f /etc/rc.pccard ]; then
119 # start up the initial network configuration.
120 if [ -f /etc/rc.network ]; then
121 . /etc/rc.network # We only need to do this once.
125 mount -a -t nfs >/dev/null 2>&1
127 # Whack the pty perms back into shape.
128 chmod 666 /dev/tty[pqrsPQRS]*
130 # clean up left-over files
132 rm -f /var/spool/lock/*
133 rm -rf /var/spool/uucp/.Temp/*
134 (cd /var/run && { cp /dev/null utmp; chmod 644 utmp; })
136 # enable dumpdev so that savecore can see it
137 if [ "X${dumpdev}" != X"NO" -a -e ${dumpdev} ]; then
141 # /var/crash should be a directory or a symbolic link
142 # to the crash directory if core dumps are to be saved.
143 if [ "X${savecore_enable}" = X"YES" -a -d /var/crash ]; then
144 echo -n checking for core dump...
148 # snapshot any kernel -c changes back to disk
149 echo 'recording kernel -c changes'
152 echo -n 'additional daemons:'
153 # start system logging and name service (named needs to start before syslogd
154 # if you don't have a /etc/resolv.conf)
156 if [ "X${syslogd_enable}" = X"YES" ]; then
157 # Transitional symlink (for the next couple of years :) until all
158 # binaries had a chance to move towards /var/run/log.
159 if [ ! -h /dev/log ] ; then
160 # might complain for r/o root f/s
161 ln -sf /var/run/log /dev/log
165 echo -n ' syslogd'; syslogd ${syslogd_flags}
168 if [ "X${tickadj_enable}" = X"YES" ]; then
169 echo -n ' tickadj'; tickadj ${tickadj_flags--Aq}
173 if [ -n "$network_pass1_done" ]; then
177 # Check the quotas (must be after ypbind if using NIS)
178 if [ "X${check_quotas}" = X"YES" ]; then
179 echo -n 'checking quotas:'
185 if [ -n "$network_pass2_done" ]; then
194 # check the password temp/lock file
197 logger -s -p auth.err \
198 "password file may be incorrect -- /etc/ptmp exists"
201 if [ "X${accounting_enable}" = X"YES" -a -d /var/account ]; then
202 echo 'turning on accounting'
203 if [ ! -e /var/account/acct ]; then
204 touch /var/account/acct
206 accton /var/account/acct
209 # Make shared lib searching a little faster. Leave /usr/lib first if you
210 # add your own entries or you may come to grief.
212 if [ -d /usr/lib/compat ]; then _LDC="${_LDC} /usr/lib/compat" ; fi
213 if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi
214 if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi
215 echo 'setting ldconfig path:' ${_LDC}
218 # Now start up miscellaneous daemons that don't belong anywhere else
220 echo -n starting standard daemons:
221 if [ "X${inetd_enable}" = X"YES" ]; then
222 echo -n ' inetd'; inetd ${inetd_flags}
225 if [ "X${cron_enable}" = X"YES" ]; then
226 echo -n ' cron'; cron
229 if [ "X${lpd_enable}" = X"YES" ]; then
230 echo -n ' printer'; lpd ${lpd_flags}
233 if [ "X${sendmail_enable}" = X"YES" -a -r /etc/sendmail.cf ]; then
234 echo -n ' sendmail'; /usr/sbin/sendmail ${sendmail_flags}
239 # configure implementation specific stuff
241 if [ -f /etc/rc.${arch} ]; then
245 # Recover vi editor files.
246 vibackup=`echo /var/tmp/vi.recover/vi.*`
247 if [ "$vibackup" != '/var/tmp/vi.recover/vi.*' ]; then
248 echo 'Recovering vi editor sessions'
249 for i in $vibackup; do
250 # Only test files that are readable.
251 if test ! -r $i; then
255 # Unmodified nvi editor backup files either have the
256 # execute bit set or are zero length. Delete them.
257 if test -x $i -o ! -s $i; then
262 # It is possible to get incomplete recovery files, if the editor
263 # crashes at the right time.
264 virecovery=`echo /var/tmp/vi.recover/recover.*`
265 if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
266 for i in $virecovery; do
267 # Only test files that are readable.
268 if test ! -r $i; then
272 # Delete any recovery files that are zero length,
273 # corrupted, or that have no corresponding backup file.
274 # Else send mail to the user.
275 recfile=`awk '/^X-vi-recover-path:/{print $2}' < $i`
276 if test -n "$recfile" -a -s "$recfile"; then
285 # for each valid dir in $local_startup, search for init scripts matching *.sh
286 if [ "X${local_startup}" != X"NO" ]; then
287 echo -n 'Local package initialization:'
288 for dir in ${local_startup}; do
289 [ -d ${dir} ] && for script in ${dir}/*.sh; do
290 [ -x ${script} ] && ${script} start
296 # Do traditional (but rather obsolete) rc.local file if it exists.
297 [ -f /etc/rc.local ] && sh /etc/rc.local