rc revision 4049
11556Srgrimes#!/bin/sh 21556Srgrimes# $Id: rc,v 1.36 1994/10/30 04:33:57 ache Exp $ 31556Srgrimes# From: @(#)rc 5.27 (Berkeley) 6/5/91 41556Srgrimes 51556Srgrimes# System startup script run by init on autoboot 61556Srgrimes# or after single-user. 71556Srgrimes# Output and error are redirected to console by init, 81556Srgrimes# and the console is the controlling terminal. 91556Srgrimes 101556Srgrimesstty status '^T' 111556Srgrimes 121556Srgrimes# Set shell to ignore SIGINT (2), but not children; 131556Srgrimes# shell catches SIGQUIT (3) and returns to single user after fsck. 141556Srgrimestrap : 2 151556Srgrimestrap : 3 # shouldn't be needed 161556Srgrimes 171556SrgrimesHOME=/; export HOME 181556SrgrimesPATH=/sbin:/bin:/usr/sbin:/usr/bin 191556Srgrimesexport PATH 201556Srgrimes 211556Srgrimesswapon -a 221556Srgrimes 231556Srgrimesif [ $1x = autobootx ] 241556Srgrimesthen 251556Srgrimes echo Automatic reboot in progress... 261556Srgrimes fsck -p 271556Srgrimes case $? in 281556Srgrimes 0) 291556Srgrimes ;; 301556Srgrimes 2) 311556Srgrimes exit 1 321556Srgrimes ;; 331556Srgrimes 4) 341556Srgrimes reboot 351556Srgrimes echo "reboot failed... help!" 361556Srgrimes exit 1 371556Srgrimes ;; 3836150Scharnier 8) 3936150Scharnier echo "Automatic file system check failed... help!" 4036150Scharnier exit 1 4136150Scharnier ;; 4238950Scracauer 12) 431556Srgrimes echo "Reboot interrupted" 441556Srgrimes exit 1 4517987Speter ;; 4617987Speter 130) 4717987Speter # interrupt before catcher installed 4817987Speter exit 1 491556Srgrimes ;; 501556Srgrimes *) 511556Srgrimes echo "Unknown error in reboot" 521556Srgrimes exit 1 531556Srgrimes ;; 5417987Speter esac 551556Srgrimeselse 561556Srgrimes echo Skipping disk checks ... 571556Srgrimesfi 581556Srgrimes 591556Srgrimestrap "echo 'Reboot interrupted'; exit 1" 3 601556Srgrimes 611556Srgrimes# root must be read/write both for NFS diskless and for VFS LKMs before 621556Srgrimes# proceeding any further. 631556Srgrimesmount -u -o rw / 641556Srgrimes 651556Srgrimesumount -a >/dev/null 2>&1 661556Srgrimesmount -a -t nonfs 671556Srgrimes 681556Srgrimes# This stuff needed for proper daemons tuning, comsat f.e. 691556Srgrimes# See profile and csh.login also. 701556Srgrimes# Uncomment next line if you want to setup your 8-bit locale at program 711556Srgrimes# startup automatically 721556Srgrimes# ENABLE_STARTUP_LOCALE=; export ENABLE_STARTUP_LOCALE 731556Srgrimes# Uncomment next line to activate russian locale 741556Srgrimes# LANG=ru_SU.KOI8-R; export LANG 751556Srgrimes 761556Srgrimes# If the machine runs wall CMOS clock (compatible with MSDOS), 7717987Speter# activate following line by creating empty file /etc/wall_cmos_clock 7838521Scracauer# If this file not exist, following line does nothing (assumed 7938536Scracauer# the machine runs UTC CMOS clock). See adjkerntz(8) for details. 8038950Scracaueradjkerntz 8138521Scracauer 8238521Scracauer# configure serial devices 8320902Ssteveif [ -f /etc/rc.serial ] 841556Srgrimesthen 8517987Speter sh /etc/rc.serial 8617987Speterfi 8720902Ssteve 881556Srgrimes# set hostname, turn on network 8920902Ssteveecho 'starting network' 9020902Ssteve. /etc/netstart 9120902Ssteve 9220902Ssteve# clean up left-over files 9320902Ssteverm -f /etc/nologin 9420902Ssteverm -f /var/spool/lock/* 9520902Ssteverm -f /var/spool/uucp/.Temp/* 9620902Ssteve(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; }) 9720902Ssteve 9820902Ssteveecho -n 'starting system logger' 9920902Ssteverm -f /dev/log 10020902Sstevesyslogd 10120902Ssteve 10220902Ssteve# $timedflags is imported from /etc/netstart; 10320902Ssteve# if $timedflags == NO, timed isn't run. 10420902Ssteveif [ X${timedflags} != X"NO" ]; then 10520902Ssteve echo -n ', time daemon'; timed $timedflags 10620902Sstevefi 10720902Ssteveecho '.' 10820902Ssteve 10920902Ssteve# /var/crash should be a directory or a symbolic link 11020902Ssteve# to the crash directory if core dumps are to be saved. 11120902Ssteveif [ -d /var/crash ]; then 11220902Ssteve echo checking for core dump... 11320902Ssteve savecore /var/crash 11420902Sstevefi 11520902Ssteve 11620902Ssteve# echo -n 'checking quotas:' 11720902Ssteve#quotacheck -a 11820902Ssteve# echo ' done.' 11920902Ssteve#quotaon -a 12020902Ssteve 12120902Ssteve# build ps databases 12220902Sstevekvm_mkdb 12320902Sstevedev_mkdb 12420902Ssteve 12520902Sstevechmod 666 /dev/tty[pqrs]* 12620902Ssteve 12720902Ssteve# check the password temp/lock file 12820902Ssteveif [ -f /etc/ptmp ] 12920902Sstevethen 13020902Ssteve logger -s -p auth.err \ 13120902Ssteve 'password file may be incorrect -- /etc/ptmp exists' 13220902Sstevefi 13320902Ssteve 13420902Ssteve# Recover vi editor files. 1351556Srgrimesvirecovery=/var/tmp/vi.recover/recover.* 1361556Srgrimesif [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then 13717987Speter echo 'Recovering vi editor sessions' 13817987Speter for i in $virecovery; do 13917987Speter sendmail -t < $i 14020425Ssteve done 14117987Speterfi 1421556Srgrimes 1431556Srgrimesecho clearing /tmp 1441556Srgrimes 1451556Srgrimes# prune quickly with one rm, then use find to clean up /tmp/[lq]* 14620902Ssteve# (not needed with mfs /tmp, but doesn't hurt there...) 1471556Srgrimes(cd /tmp && rm -rf [a-km-pr-zA-Z]* && 14820902Ssteve find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;) 14920902Ssteve 1501556Srgrimes# echo 'turning on accounting'; accton /var/account/acct 1511556Srgrimes 1521556Srgrimesecho -n standard daemons: 15320902Ssteveecho -n ' cron'; cron 15420902Ssteveecho '.' 15520902Ssteve 15620902Ssteveecho -n starting network daemons: 15720902Ssteve 15820902Ssteve# Portmapper should always be run, to provide RPC services for inetd. 15920902Ssteveif [ -x /usr/sbin/portmap ]; then 16020902Ssteve echo -n ' portmap'; portmap 16120902Sstevefi 16220902Ssteve 16320902Ssteve# $gated and $routedflags are imported from /etc/netstart. 16420902Ssteve# If $gated == YES, gated is used; otherwise routed. 16520902Ssteve# If $routedflags == NO, routed isn't run. 16620902Ssteveif [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then 16720902Ssteve echo -n ' gated'; gated $gatedflags 16820902Ssteveelif [ X"${routedflags}" != X"NO" ]; then 16920902Ssteve echo -n ' routed'; routed $routedflags 17020902Sstevefi 17120902Ssteve 1721556Srgrimesif [ X${name_server} = X"YES" -a -r /etc/named.boot ]; then 1731556Srgrimes echo -n ' named'; named 1741556Srgrimesfi 1751556Srgrimes 1761556Srgrimes# $ntpdate and $xntpdflags are imported from /etc/netstart. 1771556Srgrimes# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly. 1781556Srgrimes# If $xntpdflags != NO, start xntpd. 1791556Srgrimesif [ X"${ntpdate}" != X"NO" ]; then 1801556Srgrimes echo ' ntpdate'; ntpdate $ntpdate 18120902Sstevefi 1821556Srgrimes 1831556Srgrimesif [ X"${xntpdflags}" != X"NO" ]; then 1841556Srgrimes if [ X"${tickadjflags}" != X"NO" ]; then 1851556Srgrimes echo 'adjusting kernel for xntpd'; tickadj ${tickadjflags--A} 1861556Srgrimes fi 1871556Srgrimes echo 'starting xntpd'; xntpd ${xntpdflags} 1881556Srgrimesfi 1891556Srgrimes 1901556Srgrimesif [ X"${ntpdate}" != X"NO" -o X"${xntpdflags}" != X"NO" ]; then 19120902Ssteve echo -n 'starting more network daemons:' 19220902Sstevefi 19338950Scracauer 1941556Srgrimes# $rwhod is imported from /etc/netstart; 19520902Ssteve# if $rwhod is set to something other than NO, rwhod is run. 1961556Srgrimesif [ ${rwhod-NO} != "NO" ]; then 1971556Srgrimes echo -n ' rwhod'; rwhod 1981556Srgrimesfi 1991556Srgrimes 2001556Srgrimesecho -n ' printer'; lpd 2011556Srgrimes 2021556Srgrimesif [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then 2031556Srgrimes echo -n ' mountd'; mountd 2041556Srgrimes echo -n ' nfsd'; nfsd -u -t 4 2051556Srgrimesfi 2061556Srgrimes 2071556Srgrimesif [ X"${nfs_client}" != X"NO" ]; then 2081556Srgrimes echo -n ' nfsiod'; nfsiod -n 4 2091556Srgrimesfi 2101556Srgrimes 2111556Srgrimesif [ X"${amdflags}" != X"NO" ]; then 21231098Sbde echo -n ' amd'; amd ${amdflags} 21320425Sstevefi 21417987Speter 21517987Speter# $sendmail_flags is imported from /etc/netstart; 2161556Srgrimes# if $sendmail_flags is something other than NO, sendmail is run. 21731098Sbdeif [ X"${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then 2181556Srgrimes echo -n ' sendmail'; sendmail ${sendmail_flags} 2191556Srgrimesfi 2201556Srgrimes 2211556Srgrimesecho -n ' inetd'; inetd 2221556Srgrimesecho '.' 2231556Srgrimes 2241556Srgrimesmount -a -t nfs >/dev/null 2>&1 & # XXX shouldn't need background 2251556Srgrimes 22638521Scracauer# if [ -x /usr/libexec/xtend ]; then 2271556Srgrimes# echo -n ' xtend'; /usr/libexec/xtend 2281556Srgrimes# fi 22938521Scracauer 2301556Srgrimes# Make shared lib searching a little faster. Leave /usr/lib first if you 2311556Srgrimes# add your own entries or you may come to grief. 2321556Srgrimesif [ -x /sbin/ldconfig ]; then 2331556Srgrimes _LDC=/usr/lib 2341556Srgrimes if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi 2351556Srgrimes if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi 2361556Srgrimes if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi 2371556Srgrimes if [ -d /usr/gnu/lib ]; then _LDC="${_LDC} /usr/gnu/lib" ; fi 2381556Srgrimes echo 'setting ldconfig path:' ${_LDC} 2391556Srgrimes ldconfig ${_LDC} 24038535Scracauerfi 24138521Scracauer 2421556Srgrimessh /etc/rc.local 24338521Scracauer 2441556Srgrimesdate 2451556Srgrimes 2461556Srgrimesexit 0 2471556Srgrimes