rc revision 1.53
1# from: @(#)rc 8.2 (Berkeley) 3/17/94 2# $Id: rc,v 1.53 1995/09/16 15:29:20 jtc Exp $ 3 4# System startup script run by init on autoboot 5# or after single-user. 6# Output and error are redirected to console by init, 7# and the console is the controlling terminal. 8 9stty status '^T' 10 11# Set shell to ignore SIGINT (2), but not children; 12# shell catches SIGQUIT (3) and returns to single user after fsck. 13trap : 2 14trap : 3 # shouldn't be needed 15 16HOME=/; export HOME 17PATH=/sbin:/bin:/usr/sbin:/usr/bin 18export PATH 19 20# Configure ccd devices. 21if [ -f /etc/ccd.conf ] 22then 23 ccdconfig -C 24fi 25 26if [ -e /fastboot ] 27then 28 echo "Fast boot: skipping disk checks." 29elif [ $1x = autobootx ] 30then 31 echo "Automatic boot in progress: starting file system checks." 32 fsck -p 33 case $? in 34 0) 35 ;; 36 2) 37 exit 1 38 ;; 39 4) 40 echo "Rebooting..." 41 reboot 42 echo "Reboot failed; help!" 43 exit 1 44 ;; 45 8) 46 echo "Automatic file system check failed; help!" 47 exit 1 48 ;; 49 12) 50 echo "Boot interrupted." 51 exit 1 52 ;; 53 130) 54 # interrupt before catcher installed 55 exit 1 56 ;; 57 *) 58 echo "Unknown error; help!" 59 exit 1 60 ;; 61 esac 62fi 63 64trap "echo 'Boot interrupted.'; exit 1" 3 65 66swapon -a 67 68umount -a >/dev/null 2>&1 69mount -a -t nonfs 70rm -f /fastboot # XXX (root now writeable) 71 72# set flags on ttys. (do early, in case they use tty for SLIP in netstart) 73echo 'setting tty flags' 74ttyflags -a 75 76# set hostname, turn on network 77echo 'starting network' 78. /etc/netstart 79 80mount /usr >/dev/null 2>&1 81mount /var >/dev/null 2>&1 82 83# clean up left-over files 84rm -f /etc/nologin 85rm -f /var/spool/lock/LCK.* 86rm -f /var/spool/uucp/STST/* 87(cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; }) 88 89echo -n 'starting rpc daemons:' 90echo -n ' portmap'; portmap 91 92if [ -f /usr/sbin/ypbind -a -d /var/yp ]; then 93 echo -n ' ypbind'; ypbind 94fi 95 96# $nfs_server is imported from /etc/netstart; 97# if $nfs_server == YES, the machine is setup for being an nfs server 98if [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then 99 rm -f /var/db/mountdtab 100 echo -n > /var/db/mountdtab 101 echo -n ' mountd'; mountd 102 echo -n ' nfsd'; nfsd -tun 4 103fi 104 105# $nfs_client is imported from /etc/netstart; 106# if $nfs_client == YES, the machine is setup for being an nfs client 107if [ X${nfs_client} = X"YES" ]; then 108 echo -n ' nfsiod'; nfsiod -n 4 109fi 110 111if [ X${amd} = X"YES" -a -d ${amd_dir} -a -r ${amd_master} ]; then 112 echo -n ' amd' 113 amd -l syslog -x error,noinfo,nostats -p \ 114 -a ${amd_dir} `cat ${amd_master}` > /var/run/amd.pid 115fi 116 117echo '.' 118mount -a -t nfs 119 120echo -n 'starting system logger' 121rm -f /dev/log 122syslogd 123 124# $timed_flags is imported from /etc/netstart; 125# if $timed_flags == NO, timed isn't run. 126if [ "X${timed_flags}" != X"NO" ]; then 127 echo -n ', time daemon'; timed $timed_flags 128fi 129echo '.' 130 131# /var/crash should be a directory or a symbolic link 132# to the crash directory if core dumps are to be saved. 133if [ -d /var/crash ]; then 134 echo checking for core dump... 135 savecore /var/crash 136fi 137 138 echo -n 'checking quotas:' 139quotacheck -a 140 echo ' done.' 141quotaon -a 142 143# build ps databases 144echo 'building databases...' 145kvm_mkdb /netbsd 146dev_mkdb 147 148chmod 666 /dev/tty[pqrs]* 149 150# check the password temp/lock file 151if [ -f /etc/ptmp ] 152then 153 logger -s -p auth.err \ 154 'password file may be incorrect -- /etc/ptmp exists' 155fi 156 157virecovery=/var/tmp/vi.recover/recover.* 158if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then 159 echo preserving editor files 160 for i in $virecovery; do 161 sendmail -t < $i 162 done 163fi 164 165echo clearing /tmp 166 167# prune quickly with one rm, then use find to clean up /tmp/[lq]* 168# (not needed with mfs /tmp, but doesn't hurt there...) 169(cd /tmp && rm -rf [a-km-pr-zA-Z]* && 170 find . ! -name . ! -name lost+found ! -name quota.user \ 171 ! -name quota.group -exec rm -rf -- {} \; -type d -prune) 172 173if [ -f /var/account/acct ]; then 174 echo 'turning on accounting'; accton /var/account/acct 175fi 176 177echo -n standard daemons: 178echo -n ' update'; update 179echo -n ' cron'; cron 180echo '.' 181 182echo -n starting network daemons: 183 184# $gated and $routed_flags are imported from /etc/netstart. 185# If $gated == YES, gated is used; otherwise routed. 186# If $routed_flags == NO, routed isn't run. 187if [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then 188 echo -n ' gated'; gated $gated_flags 189elif [ "X${routed_flags}" != X"NO" ]; then 190 echo -n ' routed'; routed $routed_flags 191fi 192 193# $name_flags is imported from /etc/netstart; 194# if $named_flags != NO, named is run. 195if [ "X${named_flags}" != X"NO" ]; then 196 echo -n ' named'; named $named_flags 197fi 198 199# $rwhod is imported from /etc/netstart; 200# if $rwhod == YES, rwhod is run. 201if [ X${rwhod} = X"YES" ]; then 202 echo -n ' rwhod'; rwhod 203fi 204 205echo -n ' printer'; lpd 206 207# $sendmail_flags is imported from /etc/netstart; 208# If $sendmail_flags == NO or /etc/sendmail.cf doesn't exist, then 209# sendmail isn't run. 210if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then 211 echo -n ' sendmail'; sendmail ${sendmail_flags} 212fi 213 214echo -n ' inetd'; inetd 215 216# $rarpd_flags is imported from /etc/netstart; 217# If $rarpd_flags == NO or /etc/ethers doesn't exist, then 218# rarpd isn't run. 219if [ "X${rarpd_flags}" != X"NO" -a -r /etc/ethers ]; then 220 echo -n ' rarpd'; rarpd ${rarpd_flags} 221fi 222 223# $bootparamd_flags is imported from /etc/netstart; 224# If $bootparamd_flags == NO or /etc/bootparams doesn't exist, then 225# bootparamd isn't run. 226if [ "X${bootparamd_flags}" != X"NO" -a -r /etc/bootparams ]; then 227 echo -n ' rpc.bootparamd'; rpc.bootparamd ${bootparamd_flags} 228fi 229 230# $rbootd_flags is imported from /etc/netstart; 231# If $rbootd_flags == NO or /etc/rbootd.conf doesn't exist, then 232# rbootd isn't run. 233if [ "X${rbootd_flags}" != X"NO" -a -r /etc/rbootd.conf ]; then 234 echo -n ' rbootd'; rbootd ${rbootd_flags} 235fi 236 237echo '.' 238 239. /etc/rc.local 240 241date 242exit 0 243