rc revision 3036
1180740Sdes#!/bin/sh 2239849Sdes# $Id: rc,v 1.30 1994/09/23 07:16:16 rgrimes Exp $ 3180740Sdes# From: @(#)rc 5.27 (Berkeley) 6/5/91 4225825Sdes 5180740Sdes# System startup script run by init on autoboot 6180740Sdes# or after single-user. 7180740Sdes# Output and error are redirected to console by init, 8225825Sdes# and the console is the controlling terminal. 9180740Sdes 10225825Sdesstty status '^T' 11225825Sdes 12225825Sdes# Set shell to ignore SIGINT (2), but not children; 13225825Sdes# shell catches SIGQUIT (3) and returns to single user after fsck. 14180740Sdestrap : 2 15180740Sdestrap : 3 # shouldn't be needed 16225825Sdes 17225825SdesHOME=/; export HOME 18225825SdesPATH=/sbin:/bin:/usr/sbin:/usr/bin 19180740Sdesexport PATH 20180740Sdes 21180740Sdesif [ $1x = autobootx ] 22225825Sdesthen 23180740Sdes echo Automatic reboot in progress... 24180740Sdes fsck -p 25225825Sdes case $? in 26180740Sdes 0) 27180740Sdes ;; 28180740Sdes 2) 29180740Sdes exit 1 30225825Sdes ;; 31225825Sdes 4) 32225825Sdes reboot 33225825Sdes echo "reboot failed... help!" 34225825Sdes exit 1 35180740Sdes ;; 36180740Sdes 8) 37180740Sdes echo "Automatic file system check failed... help!" 38180740Sdes exit 1 39225825Sdes ;; 40225825Sdes 12) 41225825Sdes echo "Reboot interrupted" 42225825Sdes exit 1 43225825Sdes ;; 44225825Sdes 130) 45225825Sdes # interrupt before catcher installed 46225825Sdes exit 1 47225825Sdes ;; 48225825Sdes *) 49225825Sdes echo "Unknown error in reboot" 50225825Sdes exit 1 51225825Sdes ;; 52225825Sdes esac 53225825Sdeselse 54225825Sdes echo Skipping disk checks ... 55225825Sdesfi 56225825Sdes 57225825Sdestrap "echo 'Reboot interrupted'; exit 1" 3 58225825Sdes 59180740Sdesswapon -a 60225825Sdes 61225825Sdes# root must be read/write both for NFS diskless and for VFS LKMs before 62225825Sdes# proceeding any further. 63225825Sdesmount -u -o rw / 64225825Sdes 65225825Sdesumount -a >/dev/null 2>&1 66225825Sdesmount -a -t nonfs 67225825Sdes 68225825Sdes# If the machine runs wall CMOS clock (compatible with MSDOS), 69225825Sdes# activate following line by creating empty file /etc/wall_cmos_clock 70225825Sdes# If this file not exist, following line does nothing (assumed 71225825Sdes# the machine runs UTC CMOS clock). See adjkerntz(8) for details. 72180740Sdesadjkerntz -i 73225825Sdes 74225825Sdes# configure serial devices 75180740Sdesif [ -f /etc/rc.serial ] 76180740Sdesthen 77225825Sdes sh /etc/rc.serial 78225825Sdesfi 79225825Sdes 80225825Sdes# set hostname, turn on network 81225825Sdesecho 'starting network' 82225825Sdes. /etc/netstart 83225825Sdes 84180740Sdes# clean up left-over files 85180740Sdesrm -f /etc/nologin 86180740Sdesrm -f /var/spool/lock/* 87180740Sdesrm -f /var/spool/uucp/.Temp/* 88180740Sdes(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; }) 89180740Sdes 90180740Sdesecho -n 'starting system logger' 91180740Sdesrm -f /dev/log 92180740Sdessyslogd 93180740Sdes 94180740Sdes# $timedflags is imported from /etc/netstart; 95225825Sdes# if $timedflags == NO, timed isn't run. 96225825Sdesif [ X${timedflags} != X"NO" ]; then 97180740Sdes echo -n ', time daemon'; timed $timedflags 98180740Sdesfi 99180740Sdesecho '.' 100180740Sdes 101180740Sdes# /var/crash should be a directory or a symbolic link 102180740Sdes# to the crash directory if core dumps are to be saved. 103225825Sdesif [ -d /var/crash ]; then 104225825Sdes echo checking for core dump... 105180740Sdes savecore /var/crash 106180740Sdesfi 107180740Sdes 108180740Sdes# echo -n 'checking quotas:' 109180740Sdes#quotacheck -a 110180740Sdes# echo ' done.' 111180740Sdes#quotaon -a 112180740Sdes 113180740Sdes# build ps databases 114180740Sdeskvm_mkdb /kernel 115225825Sdesdev_mkdb 116225825Sdes 117180740Sdeschmod 666 /dev/tty[pqrs]* 118180740Sdes 119225825Sdes# check the password temp/lock file 120225825Sdesif [ -f /etc/ptmp ] 121225825Sdesthen 122225825Sdes logger -s -p auth.err \ 123225825Sdes 'password file may be incorrect -- /etc/ptmp exists' 124225825Sdesfi 125225825Sdes 126180740Sdes# Recover elvis editor files. 127180740Sdesecho preserving editor files 128180740Sdes(cd /var/tmp && /usr/libexec/elvispreserve "-the system rebooted" elv* && 129180740Sdes rm -f elvis[0-9a-f][0-9a-f][0-9a-f][0-9a-f]* \ 130180740Sdes elvis_[0-9a-f][0-9a-f][0-9a-f][0-9a-f]*) 131180740Sdes 132225825Sdes# Recover vi editor files. 133225825Sdesvirecovery=/var/tmp/vi.recover/recover.* 134225825Sdesif [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then 135225825Sdes echo 'Recovering vi editor sessions' 136180740Sdes for i in $virecovery; do 137180740Sdes sendmail -t < $i 138225825Sdes done 139180740Sdesfi 140180740Sdes 141225825Sdesecho clearing /tmp 142225825Sdes 143225825Sdes# prune quickly with one rm, then use find to clean up /tmp/[lq]* 144225825Sdes# (not needed with mfs /tmp, but doesn't hurt there...) 145225825Sdes(cd /tmp && rm -rf [a-km-pr-zA-Z]* && 146225825Sdes find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;) 147225825Sdes 148180740Sdes# echo 'turning on accounting'; accton /var/account/acct 149225825Sdes 150225825Sdesecho -n standard daemons: 151225825Sdesecho -n ' cron'; cron 152225825Sdesecho '.' 153225825Sdes 154225825Sdesecho -n starting network daemons: 155180740Sdes 156225825Sdes# Portmapper should always be run, to provide RPC services for inetd. 157225825Sdesif [ -x /usr/sbin/portmap ]; then 158225825Sdes echo -n ' portmap'; portmap 159225825Sdesfi 160225825Sdes 161225825Sdes# $gated and $routedflags are imported from /etc/netstart. 162180740Sdes# If $gated == YES, gated is used; otherwise routed. 163180740Sdes# If $routedflags == NO, routed isn't run. 164225825Sdesif [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then 165225825Sdes echo -n ' gated'; gated $gatedflags 166225825Sdeselif [ X"${routedflags}" != X"NO" ]; then 167225825Sdes echo -n ' routed'; routed $routedflags 168225825Sdesfi 169180740Sdes 170180740Sdesif [ X${name_server} = X"YES" -a -r /etc/named.boot ]; then 171225825Sdes echo -n ' named'; named 172180740Sdesfi 173225825Sdes 174225825Sdes# $ntpdate and $xntpdflags are imported from /etc/netstart. 175225825Sdes# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly. 176225825Sdes# If $xntpdflags != NO, start xntpd. 177225825Sdesif [ X"${ntpdate}" != X"NO" ]; then 178225825Sdes echo ' ntpdate'; ntpdate $ntpdate 179225825Sdesfi 180225825Sdes 181180740Sdesif [ X"${xntpdflags}" != X"NO" ]; then 182225825Sdes if [ X"${tickadjflags}" != X"NO" ]; then 183180740Sdes echo 'adjusting kernel for xntpd'; tickadj ${tickadjflags--A} 184225825Sdes fi 185180740Sdes echo 'starting xntpd'; xntpd ${xntpdflags} 186180740Sdesfi 187225825Sdes 188225825Sdesif [ X"${ntpdate}" != X"NO" -o X"${xntpdflags}" != X"NO" ]; then 189180740Sdes echo -n 'starting more network daemons:' 190180740Sdesfi 191180740Sdes 192180740Sdes# $rwhod is imported from /etc/netstart; 193225825Sdes# if $rwhod is set to something other than NO, rwhod is run. 194225825Sdesif [ ${rwhod-NO} != "NO" ]; then 195180740Sdes echo -n ' rwhod'; rwhod 196180740Sdesfi 197225825Sdes 198225825Sdesecho -n ' printer'; lpd 199225825Sdes 200225825Sdesif [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then 201225825Sdes echo -n ' mountd'; mountd 202225825Sdes echo -n ' nfsd'; nfsd -u -t 4 203225825Sdesfi 204225825Sdes 205225825Sdesif grep nfs /etc/fstab > /dev/null ; then 206180740Sdes echo -n ' nfsiod'; nfsiod -n 4 207180740Sdesfi 208225825Sdes 209180740Sdes# $sendmail_flags is imported from /etc/netstart; 210225825Sdes# if $sendmail_flags is something other than NO, sendmail is run. 211225825Sdesif [ X"${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then 212225825Sdes echo -n ' sendmail'; sendmail ${sendmail_flags} 213225825Sdesfi 214180740Sdes 215180740Sdesecho -n ' inetd'; inetd 216180740Sdesecho '.' 217225825Sdes 218225825Sdesmount -a -t nfs >/dev/null 2>&1 & # XXX shouldn't need background 219225825Sdes 220225825Sdes# if [ -x /usr/libexec/xtend ]; then 221225825Sdes# echo -n ' xtend'; /usr/libexec/xtend 222225825Sdes# fi 223225825Sdes 224225825Sdes# Make shared lib searching a little faster. Leave /usr/lib first if you 225225825Sdes# add your own entries or you may come to grief. 226225825Sdesif [ -x /sbin/ldconfig ]; then 227225825Sdes _LDC=/usr/lib 228225825Sdes if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi 229225825Sdes if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi 230225825Sdes if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi 231225825Sdes if [ -d /usr/gnu/lib ]; then _LDC="${_LDC} /usr/gnu/lib" ; fi 232225825Sdes echo 'setting ldconfig path:' ${_LDC} 233180740Sdes ldconfig ${_LDC} 234180740Sdesfi 235225825Sdes 236225825Sdessh /etc/rc.local 237225825Sdes 238225825Sdesdate 239225825Sdes 240225825Sdesexit 0 241225825Sdes