rc revision 1.65
1# $NetBSD: rc,v 1.65 1997/02/15 10:02:25 mikel Exp $ 2# from: @(#)rc 8.2 (Berkeley) 3/17/94 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 ]; then 22 ccdconfig -C 23fi 24 25if [ -e /fastboot ]; then 26 echo "Fast boot: skipping disk checks." 27elif [ $1x = autobootx ]; then 28 echo "Automatic boot in progress: starting file system checks." 29 fsck -p 30 case $? in 31 0) 32 ;; 33 2) 34 exit 1 35 ;; 36 4) 37 echo "Rebooting..." 38 reboot 39 echo "Reboot failed; help!" 40 exit 1 41 ;; 42 8) 43 echo "Automatic file system check failed; help!" 44 exit 1 45 ;; 46 12) 47 echo "Boot interrupted." 48 exit 1 49 ;; 50 130) 51 # interrupt before catcher installed 52 exit 1 53 ;; 54 *) 55 echo "Unknown error; help!" 56 exit 1 57 ;; 58 esac 59fi 60 61trap "echo 'Boot interrupted.'; exit 1" 3 62 63swapon -a 64 65umount -a >/dev/null 2>&1 66mount -a -t nonfs 67rm -f /fastboot # XXX (root now writeable) 68 69if [ -s /etc/rc.conf ]; then 70 . /etc/rc.conf 71fi 72 73# set flags on ttys. (do early, in case they use tty for SLIP in netstart) 74echo 'setting tty flags' 75ttyflags -a 76 77# load any kernel modules specified in /etc/lkm.conf 78if [ X"$lkm_init" != XNO -a -f /etc/rc.lkm ]; then 79 . /etc/rc.lkm 80fi 81 82# set hostname, turn on network 83echo 'starting network' 84. /etc/netstart 85 86mount /usr >/dev/null 2>&1 87mount /var >/dev/null 2>&1 88 89# clean up left-over files 90rm -f /etc/nologin 91rm -f /var/spool/lock/LCK.* 92rm -f /var/spool/uucp/STST/* 93(cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; }) 94 95# start the system logger first, so that all messages 96# from daemons are logged, and the name server next. 97 98if [ "X$syslogd_flags" != XNO ]; then 99 echo 'starting system logger' 100 rm -f /dev/log 101 syslogd $syslogd_flags 102fi 103 104if [ "X$named_flags" != XNO ]; then 105 echo 'starting name server'; named $named_flags 106fi 107 108# now start the rpc servers, for YP server/client, NFS. 109echo -n 'starting rpc daemons:' 110 111# note that portmap is generally required for all other rpc services. 112if [ "X$portmap" != XNO ]; then 113 echo -n ' portmap'; portmap 114fi 115 116if [ "X$ypserv_flags" != XNO ]; then 117 echo -n ' ypserv'; ypserv $ypserv_flags 118fi 119 120if [ "X$ypbind_flags" != XNO ]; then 121 echo -n ' ypbind'; ypbind $ypbind_flags 122fi 123 124if [ "X$yppasswdd_flags" != XNO ]; then 125 echo -n ' rpc.yppasswdd'; rpc.yppasswdd $yppasswdd_flags 126fi 127 128if [ "X$bootparamd_flags" != XNO -a -r /etc/bootparams ]; then 129 echo -n ' rpc.bootparamd'; rpc.bootparamd $bootparamd_flags 130fi 131 132if [ "X$nfs_server" = XYES -a -r /etc/exports ]; then 133 if [ "X$nfsd_flags" = X ]; then 134 nfsd_flags="-tun 4" 135 fi 136 rm -f /var/db/mountdtab 137 echo -n > /var/db/mountdtab 138 echo -n ' mountd'; mountd $mountd_flags 139 echo -n ' nfsd'; nfsd $nfsd_flags 140fi 141 142if [ "X$nfs_client" = XYES ]; then 143 if [ "X$nfsiod_flags" = X ]; then 144 nfsiod_flags="-n 4" 145 fi 146 echo -n ' nfsiod'; nfsiod $nfsiod_flags 147fi 148 149if [ "X$amd" = XYES -a -d "$amd_dir" -a -r "$amd_master" ]; then 150 echo -n ' amd' 151 amd $amd_flags -p -a $amd_dir `cat $amd_master` > /var/run/amd.pid 152fi 153 154echo '.' 155mount -a -t nfs 156 157if [ -f /sbin/ldconfig ]; then 158 echo 'creating runtime link editor directory cache.' 159 if [ -s /etc/ld.so.conf ]; then 160 ldconfig `cat /etc/ld.so.conf` 161 else 162 ldconfig 163 fi 164fi 165 166# /var/crash should be a directory or a symbolic link 167# to the crash directory if core dumps are to be saved. 168if [ X"$savecore_flags" != XNO -a -d /var/crash ]; then 169 echo checking for core dump... 170 savecore $savecore_flags /var/crash 171fi 172 173 echo -n 'checking quotas:' 174quotacheck -a 175 echo ' done.' 176quotaon -a 177 178# build ps databases 179echo 'building databases...' 180kvm_mkdb /netbsd 181dev_mkdb 182 183chmod 666 /dev/tty[pqrs]* 184 185# check the password temp/lock file 186if [ -f /etc/ptmp ] 187then 188 logger -s -p auth.err \ 189 'password file may be incorrect -- /etc/ptmp exists' 190fi 191 192virecovery=/var/tmp/vi.recover/recover.* 193if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then 194 echo preserving editor files 195 for i in $virecovery; do 196 sendmail -t < $i 197 done 198fi 199 200echo clearing /tmp 201 202# Prune quickly with one rm, then use find to clean up /tmp/[lq]* (this 203# is not needed with mfs /tmp, but doesn't hurt anything). 204(cd /tmp && rm -rf [a-km-pr-zA-Z]* && 205 find . ! -name . ! -name lost+found ! -name quota.user \ 206 ! -name quota.group -exec rm -rf -- {} \; -type d -prune) 207 208if [ -f /var/account/acct ]; then 209 echo 'turning on accounting'; accton /var/account/acct 210fi 211 212echo -n standard daemons: 213echo -n ' update'; update 214echo -n ' cron'; cron 215echo '.' 216 217# now start all the other daemons 218echo -n starting network daemons: 219 220if [ X$gated_flags != XNO -a -r /etc/gated.conf ]; then 221 echo -n ' gated'; gated $gated_flags 222elif [ "X$routed_flags" != XNO ]; then 223 echo -n ' routed'; routed $routed_flags 224fi 225 226if [ "X$mrouted_flags" != XNO ]; then 227 echo -n ' mrouted'; mrouted $mrouted_flags 228fi 229 230if [ "X$timed_flags" != XNO ]; then 231 echo -n ' time daemon'; timed $timed_flags 232fi 233 234if [ "X$xntpd_flags" != XNO ]; then 235 echo -n ' ntp daemon'; xntpd $xntpd_flags 236fi 237 238if [ "X$dhcpd_flags" != XNO -a -r /etc/dhcpd.conf ]; then 239 echo -n ' dhcpd'; dhcpd $dhcpd_flags 240fi 241 242if [ X$rwhod = XYES ]; then 243 echo -n ' rwhod'; rwhod 244fi 245 246if [ "X$lpd_flags" != XNO ]; then 247 echo -n ' printer'; lpd $lpd_flags 248fi 249 250# We call sendmail with a full path so that SIGHUP works. 251if [ "X$sendmail_flags" != XNO -a -r /etc/sendmail.cf ]; then 252 echo -n ' sendmail'; /usr/sbin/sendmail $sendmail_flags 253fi 254 255if [ "X$rarpd_flags" != XNO -a -r /etc/ethers ]; then 256 echo -n ' rarpd'; rarpd $rarpd_flags 257fi 258 259if [ "X$rbootd_flags" != XNO -a -r /etc/rbootd.conf ]; then 260 echo -n ' rbootd'; rbootd $rbootd_flags 261fi 262 263if [ "X$inetd_flags" != XNO -a -r /etc/inetd.conf ]; then 264 echo -n ' inetd'; inetd $inetd_flags 265fi 266 267echo '.' 268 269. /etc/rc.local 270 271date 272exit 0 273