rc revision 25469
1709Swollman#!/bin/sh 225469Sandreas# $Id: rc,v 1.120 1997/05/04 12:50:33 andreas Exp $ 3709Swollman# From: @(#)rc 5.27 (Berkeley) 6/5/91 437Srgrimes 537Srgrimes# System startup script run by init on autoboot 637Srgrimes# or after single-user. 737Srgrimes# Output and error are redirected to console by init, 837Srgrimes# and the console is the controlling terminal. 937Srgrimes 108460Sjkh# Note that almost all the user-configurable behavior is no longer in 1125184Sjkh# this file, but rather in /etc/rc.conf. Please check this file 128460Sjkh# first before contemplating any changes here. 138460Sjkh 1437Srgrimesstty status '^T' 1537Srgrimes 1637Srgrimes# Set shell to ignore SIGINT (2), but not children; 1737Srgrimes# shell catches SIGQUIT (3) and returns to single user after fsck. 1837Srgrimestrap : 2 1937Srgrimestrap : 3 # shouldn't be needed 2037Srgrimes 2137SrgrimesHOME=/; export HOME 2220684SjoergPATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin 2337Srgrimesexport PATH 2437Srgrimes 2515568Sasami# Configure ccd devices. 2625184Sjkhif [ -f /etc/ccd.conf ]; then 2715568Sasami ccdconfig -C 2815568Sasamifi 2915568Sasami 303843Sdgswapon -a 313843Sdg 3225184Sjkhif [ $1x = autobootx ]; then 3337Srgrimes echo Automatic reboot in progress... 3437Srgrimes fsck -p 3537Srgrimes case $? in 3637Srgrimes 0) 3737Srgrimes ;; 3837Srgrimes 2) 3937Srgrimes exit 1 4037Srgrimes ;; 4137Srgrimes 4) 4237Srgrimes reboot 4337Srgrimes echo "reboot failed... help!" 4437Srgrimes exit 1 4537Srgrimes ;; 4637Srgrimes 8) 4737Srgrimes echo "Automatic file system check failed... help!" 4837Srgrimes exit 1 4937Srgrimes ;; 5037Srgrimes 12) 5137Srgrimes echo "Reboot interrupted" 5237Srgrimes exit 1 5337Srgrimes ;; 5437Srgrimes 130) 5537Srgrimes # interrupt before catcher installed 5637Srgrimes exit 1 5737Srgrimes ;; 5837Srgrimes *) 5937Srgrimes echo "Unknown error in reboot" 6037Srgrimes exit 1 6137Srgrimes ;; 6237Srgrimes esac 632164Sdgelse 642164Sdg echo Skipping disk checks ... 6537Srgrimesfi 6637Srgrimes 6737Srgrimestrap "echo 'Reboot interrupted'; exit 1" 3 6837Srgrimes 693036Sdg# root must be read/write both for NFS diskless and for VFS LKMs before 703036Sdg# proceeding any further. 713036Sdgmount -u -o rw / 728530Sdgif [ $? != 0 ]; then 738530Sdg echo "Filesystem mount failed, startup aborted" 748530Sdg exit 1 758530Sdgfi 761692Sphk 7737Srgrimesumount -a >/dev/null 2>&1 788530Sdg 7937Srgrimesmount -a -t nonfs 808530Sdgif [ $? != 0 ]; then 818530Sdg echo "Filesystem mount failed, startup aborted" 828530Sdg exit 1 838530Sdgfi 8437Srgrimes 8525184Sjkh# If there is a global system configuration file, suck it in. 8625184Sjkhif [ -f /etc/rc.conf ]; then 8725184Sjkh . /etc/rc.conf 8825184Sjkhfi 8925184Sjkh 9025184Sjkh# If old file exists, whine until they fix it. 9125184Sjkhif [ -f /etc/sysconfig ]; then 9225184Sjkh echo "Warning: /etc/sysconfig has been replaced by /etc/rc.conf." 9325184Sjkh echo "You should switch to /etc/rc.conf ASAP to eliminate this warning." 9425184Sjkhfi 9525184Sjkh 964091Sacheadjkerntz -i 97872Sache 9821197Sphk# Keep a copy of the boot messages around 9925184Sjkhdmesg > /var/run/dmesg.boot 10021197Sphk 1017219Sjkh 10217767Sjkh# Add additional swapfile, if configured. 10319363Sjoergif [ "x$swapfile" != "xNO" -a -w "$swapfile" -a -b /dev/vn0b ]; then 10417767Sjkh echo "Adding $swapfile as additional swap." 10525184Sjkh vnconfig /dev/vn0b $swapfile && swapon /dev/vn0b 10617767Sjkhfi 10717767Sjkh 1081675Sache# configure serial devices 1097219Sjkhif [ -f /etc/rc.serial ]; then 1107293Sjkh . /etc/rc.serial 1111675Sachefi 1121675Sache 11314596Snate# start up PC-card configuration 11414624Snateif [ -f /etc/rc.pccard ]; then 11514624Snate . /etc/rc.pccard 11614596Snatefi 11714596Snate 11825184Sjkh# start up the initial network configuration. 11925184Sjkhif [ -f /etc/rc.network ]; then 12025184Sjkh . /etc/rc.network # We only need to do this once. 12125184Sjkh network_pass1 1227460Sjkhfi 1237460Sjkh 1248540Srgrimesmount -a -t nfs >/dev/null 2>&1 1257487Srgrimes 1267487Srgrimes# Whack the pty perms back into shape. 12720828Sjoergchmod 666 /dev/tty[pqrsPQRS]* 1287487Srgrimes 1297487Srgrimes# clean up left-over files 1307487Srgrimesrm -f /etc/nologin 1317487Srgrimesrm -f /var/spool/lock/* 1327761Sacherm -rf /var/spool/uucp/.Temp/* 13315684Sjkh(cd /var/run && { cp /dev/null utmp; chmod 644 utmp; }) 1347487Srgrimes 1359305Sbde# enable dumpdev so that savecore can see it 13625412Sjkhif [ "X${dumpdev}" != X"NO" -a -e ${dumpdev} ]; then 1379305Sbde dumpon ${dumpdev} 1389305Sbdefi 1399305Sbde 1407487Srgrimes# /var/crash should be a directory or a symbolic link 1417487Srgrimes# to the crash directory if core dumps are to be saved. 14225412Sjkhif [ "X${savecore_enable}" = X"YES" -a -d /var/crash ]; then 1437487Srgrimes echo -n checking for core dump... 1447487Srgrimes savecore /var/crash 1457487Srgrimesfi 1467487Srgrimes 1477487Srgrimes# snapshot any kernel -c changes back to disk 1487487Srgrimesecho 'recording kernel -c changes' 14925339Sjkhdset -q 1507487Srgrimes 15125339Sjkhecho -n 'additional daemons:' 1527487Srgrimes# start system logging and name service (named needs to start before syslogd 1537487Srgrimes# if you don't have a /etc/resolv.conf) 1547259Sjkh# 15525412Sjkhif [ "X${syslogd_enable}" = X"YES" ]; then 15624463Spst # Transitional symlink (for the next couple of years :) until all 15724463Spst # binaries had a chance to move towards /var/run/log. 15824463Spst if [ ! -h /dev/log ] ; then 15924463Spst # might complain for r/o root f/s 16024463Spst ln -sf /var/run/log /dev/log 16124463Spst fi 16224463Spst 16324463Spst rm -f /var/run/log 16425339Sjkh echo -n ' syslogd'; syslogd ${syslogd_flags} 16519226Sjoergfi 1667487Srgrimes 16725339Sjkhif [ "X${tickadj_enable}" = X"YES" ]; then 16825412Sjkh echo -n ' tickadj'; tickadj ${tickadj_flags--Aq} 16925339Sjkhfi 17025339Sjkhecho '.' 17125339Sjkh 17225184Sjkhif [ -n "$network_pass1_done" ]; then 17325184Sjkh network_pass2 174857Sdgfi 17537Srgrimes 17618812Speter# Check the quotas (must be after ypbind if using NIS) 17718812Speterif [ "X${check_quotas}" = X"YES" ]; then 17818812Speter echo -n 'checking quotas:' 17918812Speter quotacheck -a 18018812Speter echo ' done.' 18118812Speter quotaon -a 1827238Sachefi 1837238Sache 18425184Sjkhif [ -n "$network_pass2_done" ]; then 18525184Sjkh network_pass3 1867477Sachefi 1877477Sache 1887238Sache 1897487Srgrimes# build ps databases 1907487Srgrimeskvm_mkdb 1917487Srgrimesdev_mkdb 1927487Srgrimes 1937487Srgrimes# check the password temp/lock file 1947487Srgrimesif [ -f /etc/ptmp ] 1957487Srgrimesthen 1967487Srgrimes logger -s -p auth.err \ 1977487Srgrimes "password file may be incorrect -- /etc/ptmp exists" 1987238Sachefi 1997238Sache 20025184Sjkhif [ "X${accounting_enable}" = X"YES" -a -d /var/account ]; then 20111992Sache echo 'turning on accounting' 20211992Sache if [ ! -e /var/account/acct ]; then 20325412Sjkh touch /var/account/acct 20411992Sache fi 20511992Sache accton /var/account/acct 2067238Sachefi 2077238Sache 2087487Srgrimes# Make shared lib searching a little faster. Leave /usr/lib first if you 2097487Srgrimes# add your own entries or you may come to grief. 21025184Sjkh_LDC=/usr/lib 21125184Sjkhif [ -d /usr/lib/compat ]; then _LDC="${_LDC} /usr/lib/compat" ; fi 21225184Sjkhif [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi 21325184Sjkhif [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi 21425184Sjkhecho 'setting ldconfig path:' ${_LDC} 21525184Sjkhldconfig ${_LDC} 2167296Sjkh 21717210Spst# Now start up miscellaneous daemons that don't belong anywhere else 21817210Spst# 21925339Sjkhecho -n starting standard daemons: 22018812Speterecho -n ' inetd'; inetd 22117210Spstecho -n ' cron'; cron 22217210Spst 22325184Sjkhif [ "X${lpd_enable}" = X"YES" ]; then 22417210Spst echo -n ' printer'; lpd 22517210Spstfi 22617210Spst 22725184Sjkhif [ "X${sendmail_enable}" = X"YES" -a -r /etc/sendmail.cf ]; then 22825184Sjkh echo -n ' sendmail'; sendmail ${sendmail_flags} 22917161Spstfi 23017161Spst 23117161Spstecho '.' 23217161Spst 2337487Srgrimes# configure implementation specific stuff 2347487Srgrimesarch=`uname -m` 23525469Sandreasif [ -f /etc/rc.${arch} ]; then 23625469Sandreas . /etc/rc.${arch} 23725469Sandreasfi 2387487Srgrimes 23916671Spst# Recover vi editor files. 24019314Spetervibackup=`echo /var/tmp/vi.recover/vi.*` 24119314Speterif [ "$vibackup" != '/var/tmp/vi.recover/vi.*' ]; then 24216671Spst echo 'Recovering vi editor sessions' 24319314Speter for i in $vibackup; do 24419314Speter # Only test files that are readable. 24519314Speter if test ! -r $i; then 24619314Speter continue 24719314Speter fi 24819314Speter 24919314Speter # Unmodified nvi editor backup files either have the 25019314Speter # execute bit set or are zero length. Delete them. 25119314Speter if test -x $i -o ! -s $i; then 25219314Speter rm -f $i 25319314Speter fi 25416671Spst done 25519314Speter 25619314Speter # It is possible to get incomplete recovery files, if the editor 25719314Speter # crashes at the right time. 25819314Speter virecovery=`echo /var/tmp/vi.recover/recover.*` 25919314Speter if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then 26019314Speter for i in $virecovery; do 26119314Speter # Only test files that are readable. 26219314Speter if test ! -r $i; then 26319314Speter continue 26419314Speter fi 26519314Speter 26619314Speter # Delete any recovery files that are zero length, 26719314Speter # corrupted, or that have no corresponding backup file. 26819314Speter # Else send mail to the user. 26919314Speter recfile=`awk '/^X-vi-recover-path:/{print $2}' < $i` 27019314Speter if test -n "$recfile" -a -s "$recfile"; then 27119314Speter sendmail -t < $i 27219314Speter else 27319314Speter rm -f $i 27419314Speter fi 27519314Speter done 27619314Speter fi 27716671Spstfi 27816671Spst 27913071Sjkh# for each valid dir in $local_startup, search for init scripts matching *.sh 28013071Sjkhif [ "X${local_startup}" != X"NO" ]; then 28116391Sjkh echo -n 'Local package startup:' 28213071Sjkh for dir in ${local_startup}; do 28313071Sjkh [ -d ${dir} ] && for script in ${dir}/*.sh; do 28413071Sjkh [ -x ${script} ] && ${script} start 28513071Sjkh done 28610873Sjkh done 28716391Sjkh echo . 2887259Sjkhfi 28937Srgrimes 29010873Sjkh# Do traditional (but rather obsolete) rc.local file if it exists. 29110898Sjkh[ -f /etc/rc.local ] && sh /etc/rc.local 29210873Sjkh 29337Srgrimesdate 29437Srgrimesexit 0 295