rc revision 10873
11558Srgrimes#!/bin/sh 21558Srgrimes# $Id: rc,v 1.69 1995/09/14 02:44:47 jkh Exp $ 31558Srgrimes# From: @(#)rc 5.27 (Berkeley) 6/5/91 41558Srgrimes 51558Srgrimes# System startup script run by init on autoboot 61558Srgrimes# or after single-user. 71558Srgrimes# Output and error are redirected to console by init, 81558Srgrimes# and the console is the controlling terminal. 91558Srgrimes 101558Srgrimes# Note that almost all the user-configurable behavior is no longer in 111558Srgrimes# this file, but rather in /etc/sysconfig. Please check this file 121558Srgrimes# first before contemplating any changes here. 131558Srgrimes 141558Srgrimesstty status '^T' 151558Srgrimes 161558Srgrimes# Set shell to ignore SIGINT (2), but not children; 171558Srgrimes# shell catches SIGQUIT (3) and returns to single user after fsck. 181558Srgrimestrap : 2 191558Srgrimestrap : 3 # shouldn't be needed 201558Srgrimes 211558SrgrimesHOME=/; export HOME 221558SrgrimesPATH=/sbin:/bin:/usr/sbin:/usr/bin 231558Srgrimesexport PATH 241558Srgrimes 251558Srgrimesswapon -a 261558Srgrimes 271558Srgrimesif [ $1x = autobootx ] 281558Srgrimesthen 291558Srgrimes echo Automatic reboot in progress... 301558Srgrimes fsck -p 311558Srgrimes case $? in 321558Srgrimes 0) 331558Srgrimes ;; 341558Srgrimes 2) 3537906Scharnier exit 1 3623685Speter ;; 3737906Scharnier 4) 3837906Scharnier reboot 3950476Speter echo "reboot failed... help!" 401558Srgrimes exit 1 411558Srgrimes ;; 421558Srgrimes 8) 431558Srgrimes echo "Automatic file system check failed... help!" 441558Srgrimes exit 1 451558Srgrimes ;; 461558Srgrimes 12) 471558Srgrimes echo "Reboot interrupted" 481558Srgrimes exit 1 491558Srgrimes ;; 501558Srgrimes 130) 511558Srgrimes # interrupt before catcher installed 521558Srgrimes exit 1 531558Srgrimes ;; 541558Srgrimes *) 551558Srgrimes echo "Unknown error in reboot" 561558Srgrimes exit 1 571558Srgrimes ;; 581558Srgrimes esac 591558Srgrimeselse 601558Srgrimes echo Skipping disk checks ... 611558Srgrimesfi 621558Srgrimes 631558Srgrimestrap "echo 'Reboot interrupted'; exit 1" 3 641558Srgrimes 651558Srgrimes# root must be read/write both for NFS diskless and for VFS LKMs before 661558Srgrimes# proceeding any further. 671558Srgrimesmount -u -o rw / 681558Srgrimesif [ $? != 0 ]; then 691558Srgrimes echo "Filesystem mount failed, startup aborted" 701558Srgrimes exit 1 711558Srgrimesfi 721558Srgrimes 731558Srgrimesumount -a >/dev/null 2>&1 741558Srgrimes 751558Srgrimesmount -a -t nonfs 761558Srgrimesif [ $? != 0 ]; then 771558Srgrimes echo "Filesystem mount failed, startup aborted" 781558Srgrimes exit 1 791558Srgrimesfi 801558Srgrimes 811558Srgrimes# If the machine runs wall CMOS clock (compatible with MSDOS), 821558Srgrimes# activate following line by creating empty file /etc/wall_cmos_clock 831558Srgrimes# If this file not exist, following line does nothing (assumed 841558Srgrimes# the machine runs UTC CMOS clock). See adjkerntz(8) for details. 851558Srgrimesadjkerntz -i 861558Srgrimes 871558Srgrimes# If there is a global system configuration file, suck it in. 8892806Sobrienif [ -f /etc/sysconfig ]; then 891558Srgrimes . /etc/sysconfig 9023685Speterfi 911558Srgrimes 921558Srgrimes# configure serial devices 931558Srgrimesif [ -f /etc/rc.serial ]; then 941558Srgrimes . /etc/rc.serial 951558Srgrimesfi 961558Srgrimes 971558Srgrimes# start up the network 981558Srgrimesif [ -f /etc/netstart ]; then 991558Srgrimes sh /etc/netstart 1001558Srgrimesfi 1011558Srgrimes 1021558Srgrimesmount -a -t nfs >/dev/null 2>&1 1031558Srgrimes 1041558Srgrimes# Whack the pty perms back into shape. 1051558Srgrimeschmod 666 /dev/tty[pqrs]* 1061558Srgrimes 1071558Srgrimes# clean up left-over files 10823685Speterrm -f /etc/nologin 1091558Srgrimesrm -f /var/spool/lock/* 1101558Srgrimesrm -rf /var/spool/uucp/.Temp/* 1111558Srgrimesrm -f /dev/log 1121558Srgrimes(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; }) 1131558Srgrimes 1141558Srgrimesecho clearing /tmp 1151558Srgrimes 1161558Srgrimes# prune quickly with one rm, then use find to clean up /tmp/[lq]* 1171558Srgrimes# (not needed with mfs /tmp, but doesn't hurt there...) 1181558Srgrimes(cd /tmp && rm -rf [a-km-pr-zA-Z]* && 1191558Srgrimes find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;) 1201558Srgrimes 1211558Srgrimes# enable dumpdev so that savecore can see it 1221558Srgrimesif [ "X${dumpdev}" != X"NO" ]; then 1231558Srgrimes dumpon ${dumpdev} 1241558Srgrimesfi 1251558Srgrimes 1261558Srgrimes# /var/crash should be a directory or a symbolic link 12792806Sobrien# to the crash directory if core dumps are to be saved. 1281558Srgrimesif [ "X${savecore}" = X"YES" -a -d /var/crash ]; then 1291558Srgrimes echo -n checking for core dump... 13023685Speter savecore /var/crash 1311558Srgrimesfi 1321558Srgrimes 1331558Srgrimes# snapshot any kernel -c changes back to disk 1341558Srgrimesecho 'recording kernel -c changes' 1351558Srgrimes/sbin/dset -q 1361558Srgrimes 1371558Srgrimes# Check the quotas 1381558Srgrimesif [ "X${check_quotas}" = X"YES" ]; then 1391558Srgrimes echo 'checking quotas:' 1401558Srgrimes quotacheck -a 1411558Srgrimes echo ' done.' 1421558Srgrimes quotaon -a 1431558Srgrimesfi 1441558Srgrimes 1451558Srgrimes# start system logging and name service (named needs to start before syslogd 1461558Srgrimes# if you don't have a /etc/resolv.conf) 1471558Srgrimes# 1481558Srgrimesecho -n starting system daemons: 1491558Srgrimes 1501558Srgrimesecho ' syslogd.'; syslogd 15192806Sobrien 15292806Sobrienecho -n starting network daemons: 1531558Srgrimes 1541558Srgrimes# $namedflags is imported from /etc/sysconfig 1551558Srgrimesif [ "X${namedflags}" != "XNO" ]; then 1561558Srgrimes echo -n ' named'; named $namedflags 15722482Seivindfi 15822482Seivind 1591558Srgrimes# $ntpdate and $xntpdflags are imported from /etc/sysconfig. 16022482Seivind# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly. 16122482Seivind# If $xntpdflags != NO, start xntpd. 1621558Srgrimesif [ "X${ntpdate}" != X"NO" -o "X${xntpdflags}" != X"NO" ]; then 1631558Srgrimes if [ "X${tickadjflags}" != X"NO" ]; then 1641558Srgrimes echo -n ' tickadj'; tickadj ${tickadjflags--Aq} 1651558Srgrimes fi 1661558Srgrimes 1671558Srgrimes if [ "X${ntpdate}" != X"NO" ]; then 1681558Srgrimes echo -n ' ntpdate'; ntpdate ${ntpdate} >/dev/null 2>&1 1691558Srgrimes fi 1701558Srgrimes 1711558Srgrimes if [ "X${xntpdflags}" != X"NO" ]; then 1721558Srgrimes echo -n ' xntpd'; xntpd ${xntpdflags} 1731558Srgrimes fi 1741558Srgrimesfi 1751558Srgrimes 1761558Srgrimes# $timedflags is imported from /etc/sysconfig; 1771558Srgrimes# if $timedflags == NO, timed isn't run. 1781558Srgrimesif [ "X${timedflags}" != X"NO" ]; then 1791558Srgrimes echo -n ' timed'; timed $timedflags 1801558Srgrimesfi 1811558Srgrimes 1821558Srgrimes# Portmapper should always be run, to provide RPC services for inetd. 1831558Srgrimesif [ -x /usr/sbin/portmap ]; then 18423685Speter echo -n ' portmap'; portmap 1851558Srgrimesfi 1861558Srgrimes 1871558Srgrimes# Start ypserv if we're an NIS server. 1881558Srgrimes# Run yppasswdd only on the NIS master server 1891558Srgrimesif [ "X${nis_serverflags}" != X"NO" ]; then 1901558Srgrimes echo -n ' ypserv'; ypserv ${nis_serverflags} 1911558Srgrimes 1921558Srgrimes if [ "X${yppasswddflags}" != X"NO" ]; then 1931558Srgrimes echo -n ' yppasswdd'; yppasswdd ${yppasswddflags} 1941558Srgrimes fi 1951558Srgrimesfi 1961558Srgrimes 1971558Srgrimes# Start ypbind if we're an NIS client 1981558Srgrimesif [ "X${nis_clientflags}" != X"NO" ]; then 1991558Srgrimes echo -n ' ypbind'; ypbind ${nis_clientflags} 2001558Srgrimes if [ "X${nis_ypsetflags}" != X"NO" ]; then 2011558Srgrimes echo -n ' ypset'; ypset ${nis_ypsetflags} 20292806Sobrien fi 2031558Srgrimesfi 20492806Sobrien 2051558Srgrimes# $rwhod is imported from /etc/sysconfig; 2061558Srgrimes# if $rwhod is set to YES, rwhod is run. 2071558Srgrimesif [ "X${rwhod}" = X"YES" ]; then 2081558Srgrimes echo -n ' rwhod'; rwhod 20923685Speterfi 2101558Srgrimes 2111558Srgrimesif [ "X${nfs_server}" = X"YES" -a -r /etc/exports ]; then 2121558Srgrimes echo -n ' mountd' 2131558Srgrimes if [ "X${pcnfsd}" = X"YES" ]; then 2141558Srgrimes mountd -n 2151558Srgrimes else 2161558Srgrimes mountd 2171558Srgrimes fi 2181558Srgrimes echo -n ' nfsd'; nfsd -u -t 4 2191558Srgrimesfi 22037906Scharnier 2211558Srgrimesif [ "X${nfs_client}" = X"YES" ]; then 2221558Srgrimes echo -n ' nfsiod'; nfsiod -n 4 2231558Srgrimesfi 2241558Srgrimes 2251558Srgrimesif [ "X${amdflags}" != X"NO" ]; then 2261558Srgrimes echo -n ' amd'; amd ${amdflags} 2271558Srgrimesfi 2281558Srgrimes 2291558Srgrimes# These should go elsewhere but netstart is too early and I don't 2301558Srgrimes# want to touch rc.local, so... 2311558Srgrimesif [ "X${pcnfsd}" = X"YES" -a -x /usr/local/libexec/rpc.pcnfsd ]; then 2321558Srgrimes echo -n ' rpc.pcnfsd'; /usr/local/libexec/rpc.pcnfsd & 2331558Srgrimesfi 23492806Sobrien 2351558Srgrimesif [ "X${apache_httpd}" = X"YES" -a -x /usr/local/www/server/httpd ]; then 2361558Srgrimes echo -n ' apache httpd'; /usr/local/www/server/httpd & 2371558Srgrimesfi 2381558Srgrimes 23923685Speter# Kerberos runs ONLY on the Kerberos server machine 2401558Srgrimesif [ "X${kerberos_server}" = X"YES" ]; then 2411558Srgrimes echo -n ' kerberos'; kerberos >> /var/log/kerberos.log & 2421558Srgrimes echo -n ' kadmind'; \ 2431558Srgrimes (sleep 20; /usr/sbin/kadmind -n >/dev/null 2>&1 &) & 2441558Srgrimesfi 2451558Srgrimes 2461558Srgrimesecho -n ' inetd'; inetd 2471558Srgrimesecho '.' 2481558Srgrimes 2491558Srgrimes# build ps databases 2501558Srgrimeskvm_mkdb 2511558Srgrimesdev_mkdb 2521558Srgrimes 2531558Srgrimes# check the password temp/lock file 2541558Srgrimesif [ -f /etc/ptmp ] 2551558Srgrimesthen 25623685Speter logger -s -p auth.err \ 2571558Srgrimes "password file may be incorrect -- /etc/ptmp exists" 2581558Srgrimesfi 2591558Srgrimes 2601558Srgrimes# Recover vi editor files. 2611558Srgrimesvirecovery=/var/tmp/vi.recover/recover.* 2621558Srgrimesif [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then 2631558Srgrimes echo 'Recovering vi editor sessions' 26437906Scharnier for i in $virecovery; do 2651558Srgrimes sendmail -t < $i 2661558Srgrimes done 2671558Srgrimesfi 2681558Srgrimes 2691558Srgrimesif [ "X${accounting}" = X"YES" -a -d /var/account ]; then 2701558Srgrimes echo 'turning on accounting'; accton /var/account/acct 2711558Srgrimesfi 2721558Srgrimes 2731558Srgrimes# Now start up miscellaneous daemons that don't belong anywhere else 2741558Srgrimes# 2751558Srgrimesecho -n standard daemons: 2761558Srgrimesecho -n ' cron'; cron 2771558Srgrimesecho -n ' printer'; lpd 2781558Srgrimes 2791558Srgrimes# $sendmail_flags is imported from /etc/sysconfig; 2801558Srgrimes# if $sendmail_flags is something other than NO, sendmail is run. 28192806Sobrienif [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then 2821558Srgrimes echo -n ' sendmail'; sendmail ${sendmail_flags} 28392806Sobrienfi 2841558Srgrimes 2851558Srgrimesecho '.' 2861558Srgrimes 2871558Srgrimes# Make shared lib searching a little faster. Leave /usr/lib first if you 2881558Srgrimes# add your own entries or you may come to grief. 2891558Srgrimesif [ -x /sbin/ldconfig ]; then 2901558Srgrimes _LDC=/usr/lib 2911558Srgrimes if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi 2921558Srgrimes if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi 2931558Srgrimes if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi 2941558Srgrimes if [ -d /usr/gnu/lib ]; then _LDC="${_LDC} /usr/gnu/lib" ; fi 2951558Srgrimes echo 'setting ldconfig path:' ${_LDC} 2961558Srgrimes ldconfig ${_LDC} 2971558Srgrimesfi 2981558Srgrimes 2991558Srgrimes# configure implementation specific stuff 3001558Srgrimesarch=`uname -m` 3011558Srgrimesif [ -f /etc/rc.$arch ]; then 3021558Srgrimes . /etc/rc.$arch 3031558Srgrimesfi 3041558Srgrimes 3051558Srgrimesif [ -d /etc/rc.local.d ]; then 3061558Srgrimes for script in /etc/rc.local.d/*.sh; do 3071558Srgrimes [ -x $script ] && $script start 3081558Srgrimes done 3091558Srgrimesfi 3101558Srgrimes 3111558Srgrimes# Do traditional (but rather obsolete) rc.local file if it exists. 3121558Srgrimes[ -x /etc/rc.local ] && /etc/rc.local 3131558Srgrimes 3141558Srgrimesdate 3151558Srgrimesexit 0 3161558Srgrimes