1*cc247718Skarels# @(#)rc 5.28 (Berkeley) 02/24/92 2b0a74f6eSbostic 3f7313c2cSkarels# System startup script run by init on autoboot 4f7313c2cSkarels# or after single-user. 5f7313c2cSkarels# Output and error are redirected to console by init, 6f7313c2cSkarels# and the console is the controlling terminal. 7f7313c2cSkarels 8a6b497d8Skarelsstty status '^T' 9a6b497d8Skarels 10f7313c2cSkarels# Set shell to ignore SIGINT (2), but not children; 11f7313c2cSkarels# shell catches SIGQUIT (3) and returns to single user after fsck. 12f7313c2cSkarelstrap : 2 13a6b497d8Skarelstrap : 3 # shouldn't be needed 14f7313c2cSkarels 1518430759SbosticHOME=/; export HOME 169d8024f0SkarelsPATH=/sbin:/bin:/usr/sbin:/usr/bin 17b07395eeSbosticexport PATH 1818430759Sbostic 1918430759Sbosticif [ -r /fastboot ] 2018430759Sbosticthen 219fcfa9a4Sbostic echo Fast boot ... skipping disk checks 2218430759Sbosticelif [ $1x = autobootx ] 2318430759Sbosticthen 249fcfa9a4Sbostic echo Automatic reboot in progress... 259fcfa9a4Sbostic fsck -p 2618430759Sbostic case $? in 2718430759Sbostic 0) 2818430759Sbostic ;; 2918430759Sbostic 2) 3018430759Sbostic exit 1 3118430759Sbostic ;; 3218430759Sbostic 4) 33f7313c2cSkarels reboot 349fcfa9a4Sbostic echo "reboot failed... help!" 35fb6f6a15Skarels exit 1 3618430759Sbostic ;; 3718430759Sbostic 8) 389fcfa9a4Sbostic echo "Automatic file system check failed... help!" 3918430759Sbostic exit 1 4018430759Sbostic ;; 4118430759Sbostic 12) 429fcfa9a4Sbostic echo "Reboot interrupted" 4318430759Sbostic exit 1 4418430759Sbostic ;; 45fb6f6a15Skarels 130) 46fb6f6a15Skarels # interrupt before catcher installed 47fb6f6a15Skarels exit 1 48fb6f6a15Skarels ;; 4918430759Sbostic *) 509fcfa9a4Sbostic echo "Unknown error in reboot" 5118430759Sbostic exit 1 5218430759Sbostic ;; 5318430759Sbostic esac 5418430759Sbosticfi 5518430759Sbostic 56f7313c2cSkarelstrap "echo 'Reboot interrupted'; exit 1" 3 57f7313c2cSkarels 589fcfa9a4Sbosticswapon -a 59641647ccSbostic 6068d26ac7Skarelsumount -a >/dev/null 2>&1 619fcfa9a4Sbosticmount -a -t nonfs 62c62cfa9aSkarelsrm -f /fastboot # XXX (root now writeable) 63641647ccSbostic 6418430759Sbostic# set hostname, turn on network 656ab85d47Skarelsecho 'starting network' 6618430759Sbostic. /etc/netstart 6718430759Sbostic 6868d26ac7Skarelsmount -a -t nfs >/dev/null 2>&1 & # XXX shouldn't need background 6947697e4dSkarels 70c62cfa9aSkarels# clean up left-over files 71c62cfa9aSkarelsrm -f /etc/nologin 72c62cfa9aSkarelsrm -f /var/spool/uucp/LCK.* 73c62cfa9aSkarelsrm -f /var/spool/uucp/STST/* 74*cc247718Skarels(cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; }) 75c62cfa9aSkarels 769fcfa9a4Sbosticecho -n 'starting system logger' 7718430759Sbosticrm -f /dev/log 7818430759Sbosticsyslogd 7918430759Sbostic 8047697e4dSkarels# $timedflags is imported from /etc/netstart; 8147697e4dSkarels# if $timedflags == NO, timed isn't run. 8247697e4dSkarelsif [ X${timedflags} != X"NO" ]; then 839fcfa9a4Sbostic echo -n ', time daemon'; timed $timedflags 8447697e4dSkarelsfi 859fcfa9a4Sbosticecho '.' 8647697e4dSkarels 879d8024f0Skarels# /var/crash should be a directory or a symbolic link 889d8024f0Skarels# to the crash directory if core dumps are to be saved. 8918430759Sbosticif [ -d /var/crash ]; then 90a6b497d8Skarels echo checking for core dump... 919fcfa9a4Sbostic savecore /var/crash 9218430759Sbosticfi 9318430759Sbostic 949fcfa9a4Sbostic echo -n 'checking quotas:' 959fcfa9a4Sbosticquotacheck -a 969fcfa9a4Sbostic echo ' done.' 979fcfa9a4Sbosticquotaon -a 98fe7d6e7cSbostic 999f9a3525Sbostic# build ps databases 1009f9a3525Sbostickvm_mkdb /vmunix 10179af7f9cSbosticdev_mkdb 102fe7d6e7cSbostic 103fe7d6e7cSbosticchmod 666 /dev/tty[pqrs]* 104fe7d6e7cSbostic 105fb6f6a15Skarels# check the password temp/lock file 106fb6f6a15Skarelsif [ -f /etc/ptmp ] 107fb6f6a15Skarelsthen 108fb6f6a15Skarels logger -s -p auth.err \ 1099fcfa9a4Sbostic 'password file may be incorrect -- /etc/ptmp exists' 110fb6f6a15Skarelsfi 111fb6f6a15Skarels 1129fcfa9a4Sbosticecho preserving editor files 113c62cfa9aSkarels(cd /var/tmp && /usr/libexec/ex3.7preserve -a && 114c62cfa9aSkarels rm -f Ex[0-9][0-9][0-9][0-9][0-9] Rx[0-9][0-9][0-9][0-9][0-9]) 11547697e4dSkarels 1169fcfa9a4Sbosticecho clearing /tmp 1179fcfa9a4Sbostic 11847697e4dSkarels# prune quickly with one rm, then use find to clean up /tmp/[lq]* 119f7313c2cSkarels# (not needed with mfs /tmp, but doesn't hurt there...) 120c62cfa9aSkarels(cd /tmp && rm -rf [a-km-pr-zA-Z]* && 121e55745c0Skarels find . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;) 12218430759Sbostic 1239fcfa9a4Sbosticecho 'turning on accounting'; accton /var/account/acct 12418430759Sbostic 1259fcfa9a4Sbosticecho -n standard daemons: 1269fcfa9a4Sbosticecho -n ' update'; update 1279fcfa9a4Sbosticecho -n ' cron'; cron 1289fcfa9a4Sbosticecho '.' 1299fcfa9a4Sbostic 1309fcfa9a4Sbosticecho -n starting network daemons: 13118430759Sbostic 132c741f5fcSkarels# $gated and $routedflags are imported from /etc/netstart. 133c741f5fcSkarels# If $gated == YES, gated is used; otherwise routed. 134c741f5fcSkarels# If $routedflags == NO, routed isn't run. 135c741f5fcSkarelsif [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then 136c62cfa9aSkarels echo -n ' gated'; gated $gatedflags 137c741f5fcSkarelselif [ X${routedflags} != X"NO" ]; then 1389fcfa9a4Sbostic echo -n ' routed'; routed $routedflags 13918430759Sbosticfi 14018430759Sbostic 1419fcfa9a4Sbosticecho -n ' named'; named 14218430759Sbostic 14318430759Sbostic# $rwhod is imported from /etc/netstart; 14418430759Sbostic# if $rwhod is set to something other than NO, rwhod is run. 14518430759Sbosticif [ ${rwhod-NO} != "NO" ]; then 1469fcfa9a4Sbostic echo -n ' rwhod'; rwhod 14718430759Sbosticfi 14818430759Sbostic 1499fcfa9a4Sbosticecho -n ' printer'; lpd 1509fcfa9a4Sbostic 15168d26ac7Skarelsecho -n ' portmap'; portmap 1529fcfa9a4Sbosticecho -n ' mountd'; mountd 1539fcfa9a4Sbosticecho -n ' nfsd'; nfsd -u 0,0,4 -t 0,0 1549fcfa9a4Sbosticecho -n ' nfsiod'; nfsiod 4 1559fcfa9a4Sbostic 1569fcfa9a4Sbosticecho -n ' sendmail'; sendmail -bd -q30m 157a6b497d8Skarelsecho -n ' inetd'; inetd 1589fcfa9a4Sbosticecho '.' 15918430759Sbostic 16018430759Sbosticsh /etc/rc.local 16118430759Sbostic 1629fcfa9a4Sbosticdate 16318430759Sbosticexit 0 164