rc revision 14624
1709Swollman#!/bin/sh 214624Snate# $Id: rc,v 1.86 1996/03/12 15:39:24 nate 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 118460Sjkh# this file, but rather in /etc/sysconfig. 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 2237SrgrimesPATH=/sbin:/bin:/usr/sbin:/usr/bin 2337Srgrimesexport PATH 2437Srgrimes 253843Sdgswapon -a 263843Sdg 272164Sdgif [ $1x = autobootx ] 2837Srgrimesthen 2937Srgrimes echo Automatic reboot in progress... 3037Srgrimes fsck -p 3137Srgrimes case $? in 3237Srgrimes 0) 3337Srgrimes ;; 3437Srgrimes 2) 3537Srgrimes exit 1 3637Srgrimes ;; 3737Srgrimes 4) 3837Srgrimes reboot 3937Srgrimes echo "reboot failed... help!" 4037Srgrimes exit 1 4137Srgrimes ;; 4237Srgrimes 8) 4337Srgrimes echo "Automatic file system check failed... help!" 4437Srgrimes exit 1 4537Srgrimes ;; 4637Srgrimes 12) 4737Srgrimes echo "Reboot interrupted" 4837Srgrimes exit 1 4937Srgrimes ;; 5037Srgrimes 130) 5137Srgrimes # interrupt before catcher installed 5237Srgrimes exit 1 5337Srgrimes ;; 5437Srgrimes *) 5537Srgrimes echo "Unknown error in reboot" 5637Srgrimes exit 1 5737Srgrimes ;; 5837Srgrimes esac 592164Sdgelse 602164Sdg echo Skipping disk checks ... 6137Srgrimesfi 6237Srgrimes 6337Srgrimestrap "echo 'Reboot interrupted'; exit 1" 3 6437Srgrimes 653036Sdg# root must be read/write both for NFS diskless and for VFS LKMs before 663036Sdg# proceeding any further. 673036Sdgmount -u -o rw / 688530Sdgif [ $? != 0 ]; then 698530Sdg echo "Filesystem mount failed, startup aborted" 708530Sdg exit 1 718530Sdgfi 721692Sphk 7337Srgrimesumount -a >/dev/null 2>&1 748530Sdg 7537Srgrimesmount -a -t nonfs 768530Sdgif [ $? != 0 ]; then 778530Sdg echo "Filesystem mount failed, startup aborted" 788530Sdg exit 1 798530Sdgfi 8037Srgrimes 81872Sache# If the machine runs wall CMOS clock (compatible with MSDOS), 82872Sache# activate following line by creating empty file /etc/wall_cmos_clock 83872Sache# If this file not exist, following line does nothing (assumed 84872Sache# the machine runs UTC CMOS clock). See adjkerntz(8) for details. 854091Sacheadjkerntz -i 86872Sache 877219Sjkh# If there is a global system configuration file, suck it in. 887219Sjkhif [ -f /etc/sysconfig ]; then 897219Sjkh . /etc/sysconfig 907219Sjkhfi 917219Sjkh 921675Sache# configure serial devices 937219Sjkhif [ -f /etc/rc.serial ]; then 947293Sjkh . /etc/rc.serial 951675Sachefi 961675Sache 9714596Snate# start up PC-card configuration 9814624Snateif [ -f /etc/rc.pccard ]; then 9914624Snate . /etc/rc.pccard 10014596Snatefi 10114596Snate 1027487Srgrimes# start up the network 1037460Sjkhif [ -f /etc/netstart ]; then 1047750Srgrimes sh /etc/netstart 1057460Sjkhfi 1067460Sjkh 1078540Srgrimesmount -a -t nfs >/dev/null 2>&1 1087487Srgrimes 1097487Srgrimes# Whack the pty perms back into shape. 1107487Srgrimeschmod 666 /dev/tty[pqrs]* 1117487Srgrimes 1127487Srgrimes# clean up left-over files 1137487Srgrimesrm -f /etc/nologin 1147487Srgrimesrm -f /var/spool/lock/* 1157761Sacherm -rf /var/spool/uucp/.Temp/* 1167487Srgrimesrm -f /dev/log 1177487Srgrimes(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; }) 1187487Srgrimes 1197487Srgrimesecho clearing /tmp 1207487Srgrimes 1217487Srgrimes# prune quickly with one rm, then use find to clean up /tmp/[lq]* 1227487Srgrimes# (not needed with mfs /tmp, but doesn't hurt there...) 1237487Srgrimes(cd /tmp && rm -rf [a-km-pr-zA-Z]* && 1247487Srgrimes find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;) 1257487Srgrimes 1269305Sbde# enable dumpdev so that savecore can see it 1279305Sbdeif [ "X${dumpdev}" != X"NO" ]; then 1289305Sbde dumpon ${dumpdev} 1299305Sbdefi 1309305Sbde 1317487Srgrimes# /var/crash should be a directory or a symbolic link 1327487Srgrimes# to the crash directory if core dumps are to be saved. 1337487Srgrimesif [ "X${savecore}" = X"YES" -a -d /var/crash ]; then 1347487Srgrimes echo -n checking for core dump... 1357487Srgrimes savecore /var/crash 1367487Srgrimesfi 1377487Srgrimes 1387487Srgrimes# snapshot any kernel -c changes back to disk 1397487Srgrimesecho 'recording kernel -c changes' 1407487Srgrimes/sbin/dset -q 1417487Srgrimes 1427487Srgrimes# Check the quotas 1437487Srgrimesif [ "X${check_quotas}" = X"YES" ]; then 1447487Srgrimes echo 'checking quotas:' 1457487Srgrimes quotacheck -a 1467487Srgrimes echo ' done.' 1477487Srgrimes quotaon -a 1487487Srgrimesfi 1497487Srgrimes 1507487Srgrimes# start system logging and name service (named needs to start before syslogd 1517487Srgrimes# if you don't have a /etc/resolv.conf) 1527259Sjkh# 1537487Srgrimesecho -n starting system daemons: 1547487Srgrimes 1557708Srgrimesecho ' syslogd.'; syslogd 1567487Srgrimes 1577487Srgrimesecho -n starting network daemons: 1587487Srgrimes 1597487Srgrimes# $namedflags is imported from /etc/sysconfig 1607487Srgrimesif [ "X${namedflags}" != "XNO" ]; then 1617708Srgrimes echo -n ' named'; named $namedflags 162857Sdgfi 16337Srgrimes 1647487Srgrimes# $ntpdate and $xntpdflags are imported from /etc/sysconfig. 1657487Srgrimes# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly. 1667487Srgrimes# If $xntpdflags != NO, start xntpd. 1677487Srgrimesif [ "X${ntpdate}" != X"NO" -o "X${xntpdflags}" != X"NO" ]; then 1687487Srgrimes if [ "X${tickadjflags}" != X"NO" ]; then 1697487Srgrimes echo -n ' tickadj'; tickadj ${tickadjflags--Aq} 1707487Srgrimes fi 171958Sache 1727487Srgrimes if [ "X${ntpdate}" != X"NO" ]; then 1737487Srgrimes echo -n ' ntpdate'; ntpdate ${ntpdate} >/dev/null 2>&1 1747487Srgrimes fi 1757487Srgrimes 1767487Srgrimes if [ "X${xntpdflags}" != X"NO" ]; then 1777487Srgrimes echo -n ' xntpd'; xntpd ${xntpdflags} 1787487Srgrimes fi 1791186Srgrimesfi 1801186Srgrimes 1817487Srgrimes# $timedflags is imported from /etc/sysconfig; 1827487Srgrimes# if $timedflags == NO, timed isn't run. 1837487Srgrimesif [ "X${timedflags}" != X"NO" ]; then 1847487Srgrimes echo -n ' timed'; timed $timedflags 1857487Srgrimesfi 1867219Sjkh 1877487Srgrimes# Portmapper should always be run, to provide RPC services for inetd. 1887487Srgrimesif [ -x /usr/sbin/portmap ]; then 1897487Srgrimes echo -n ' portmap'; portmap 1907487Srgrimesfi 1917238Sache 1927487Srgrimes# Start ypserv if we're an NIS server. 1937487Srgrimes# Run yppasswdd only on the NIS master server 1947487Srgrimesif [ "X${nis_serverflags}" != X"NO" ]; then 1957708Srgrimes echo -n ' ypserv'; ypserv ${nis_serverflags} 1967238Sache 1977487Srgrimes if [ "X${yppasswddflags}" != X"NO" ]; then 19814202Sadam echo -n ' yppasswdd'; rpc.yppasswdd ${yppasswddflags} 1997487Srgrimes fi 2007487Srgrimesfi 2017238Sache 2027487Srgrimes# Start ypbind if we're an NIS client 2037487Srgrimesif [ "X${nis_clientflags}" != X"NO" ]; then 2047708Srgrimes echo -n ' ypbind'; ypbind ${nis_clientflags} 2059593Swollman if [ "X${nis_ypsetflags}" != X"NO" ]; then 2069593Swollman echo -n ' ypset'; ypset ${nis_ypsetflags} 2079593Swollman fi 2087219Sjkhfi 2097219Sjkh 2107487Srgrimes# $rwhod is imported from /etc/sysconfig; 2117487Srgrimes# if $rwhod is set to YES, rwhod is run. 2127487Srgrimesif [ "X${rwhod}" = X"YES" ]; then 2137487Srgrimes echo -n ' rwhod'; rwhod 2147238Sachefi 2157238Sache 2167487Srgrimesif [ "X${nfs_server}" = X"YES" -a -r /etc/exports ]; then 21710716Sjkh echo -n ' mountd' 21813071Sjkh if [ "X${weak_mountd_authentication}" = X"YES" ]; then 21910716Sjkh mountd -n 22010716Sjkh else 22110716Sjkh mountd 22210716Sjkh fi 2237487Srgrimes echo -n ' nfsd'; nfsd -u -t 4 2247477Sachefi 2257477Sache 2267487Srgrimesif [ "X${nfs_client}" = X"YES" ]; then 2277487Srgrimes echo -n ' nfsiod'; nfsiod -n 4 2287487Srgrimesfi 2297238Sache 2307487Srgrimesif [ "X${amdflags}" != X"NO" ]; then 23113455Sgraichen echo -n ' amd' 23213996Sjkh amd ${amdflags} > /var/run/amd.pid 2337238Sachefi 2347238Sache 2357487Srgrimes# Kerberos runs ONLY on the Kerberos server machine 2367487Srgrimesif [ "X${kerberos_server}" = X"YES" ]; then 2377487Srgrimes echo -n ' kerberos'; kerberos >> /var/log/kerberos.log & 2387487Srgrimes echo -n ' kadmind'; \ 23912053Spst (sleep 20; kadmind -n >/dev/null 2>&1 &) & 2407238Sachefi 2417238Sache 24213701Sgpalmer# IP multicast routing daemon 24313701Sgpalmerif [ "X${mrouted}" != X"NO" -a -x /usr/sbin/mrouted ]; then 24413701Sgpalmer echo -n ' mrouted'; mrouted ${mrouted} 24513701Sgpalmerfi 24613701Sgpalmer 2477487Srgrimesecho -n ' inetd'; inetd 2487487Srgrimesecho '.' 2497487Srgrimes 2507487Srgrimes# build ps databases 2517487Srgrimeskvm_mkdb 2527487Srgrimesdev_mkdb 2537487Srgrimes 2547487Srgrimes# check the password temp/lock file 2557487Srgrimesif [ -f /etc/ptmp ] 2567487Srgrimesthen 2577487Srgrimes logger -s -p auth.err \ 2587487Srgrimes "password file may be incorrect -- /etc/ptmp exists" 2597238Sachefi 2607238Sache 2617487Srgrimes# Recover vi editor files. 26211920Sachevirecovery=`echo /var/tmp/vi.recover/recover.*` 26311899Spstif [ "$virecovery" != '/var/tmp/vi.recover/recover.*' ]; then 2647487Srgrimes echo 'Recovering vi editor sessions' 2657487Srgrimes for i in $virecovery; do 2667487Srgrimes sendmail -t < $i 2677487Srgrimes done 2687238Sachefi 2697238Sache 2707487Srgrimesif [ "X${accounting}" = X"YES" -a -d /var/account ]; then 27111992Sache echo 'turning on accounting' 27211992Sache if [ ! -e /var/account/acct ]; then 27311992Sache touch /var/account/acct 27411992Sache fi 27511992Sache accton /var/account/acct 2767238Sachefi 2777238Sache 2787487Srgrimes# Now start up miscellaneous daemons that don't belong anywhere else 2797487Srgrimes# 2807487Srgrimesecho -n standard daemons: 2817487Srgrimesecho -n ' cron'; cron 2827238Sache 28313659Sgpalmerif [ "X${lpd}" != X"NO" -a -x /usr/sbin/lpd ]; then 28413659Sgpalmer echo -n ' printer'; lpd 28513659Sgpalmerfi 28613659Sgpalmer 2877487Srgrimes# $sendmail_flags is imported from /etc/sysconfig; 2887487Srgrimes# if $sendmail_flags is something other than NO, sendmail is run. 2897487Srgrimesif [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then 29012699Sache echo -n ' sendmail'; /usr/sbin/sendmail ${sendmail_flags} 2917238Sachefi 2927238Sache 2937487Srgrimesecho '.' 2947238Sache 2957487Srgrimes# Make shared lib searching a little faster. Leave /usr/lib first if you 2967487Srgrimes# add your own entries or you may come to grief. 2977487Srgrimesif [ -x /sbin/ldconfig ]; then 2987487Srgrimes _LDC=/usr/lib 2997487Srgrimes if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi 3007487Srgrimes if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi 3017487Srgrimes if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi 3027487Srgrimes echo 'setting ldconfig path:' ${_LDC} 3037487Srgrimes ldconfig ${_LDC} 3047296Sjkhfi 3057296Sjkh 3067487Srgrimes# configure implementation specific stuff 3077487Srgrimesarch=`uname -m` 30810895Sjkhif [ -f /etc/rc.${arch} ]; then 30910895Sjkh . /etc/rc.${arch} 3107487Srgrimesfi 3117487Srgrimes 31213071Sjkh# for each valid dir in $local_startup, search for init scripts matching *.sh 31313071Sjkhif [ "X${local_startup}" != X"NO" ]; then 31413071Sjkh for dir in ${local_startup}; do 31513071Sjkh [ -d ${dir} ] && for script in ${dir}/*.sh; do 31613071Sjkh [ -x ${script} ] && ${script} start 31713071Sjkh done 31810873Sjkh done 3197259Sjkhfi 32037Srgrimes 32110873Sjkh# Do traditional (but rather obsolete) rc.local file if it exists. 32210898Sjkh[ -f /etc/rc.local ] && sh /etc/rc.local 32310873Sjkh 32437Srgrimesdate 32537Srgrimesexit 0 326