rc revision 1.66
1# $NetBSD: rc,v 1.66 1997/03/10 06:32:37 scottr 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$nfs_server" = XYES -a -r /etc/exports -o "X$nfs_client" = XYES ]; then 150 if [ "X$statd_flags" != XNO ]; then 151 echo ' statd'; rpc.statd $statd_flags 152 fi 153 154 if [ "X$lockd_flags" != XNO ]; then 155 echo ' lockd'; rpc.lockd $lockd_flags 156 fi 157fi 158 159if [ "X$amd" = XYES -a -d "$amd_dir" -a -r "$amd_master" ]; then 160 echo -n ' amd' 161 amd $amd_flags -p -a $amd_dir `cat $amd_master` > /var/run/amd.pid 162fi 163 164echo '.' 165mount -a -t nfs 166 167if [ -f /sbin/ldconfig ]; then 168 echo 'creating runtime link editor directory cache.' 169 if [ -s /etc/ld.so.conf ]; then 170 ldconfig `cat /etc/ld.so.conf` 171 else 172 ldconfig 173 fi 174fi 175 176# /var/crash should be a directory or a symbolic link 177# to the crash directory if core dumps are to be saved. 178if [ X"$savecore_flags" != XNO -a -d /var/crash ]; then 179 echo checking for core dump... 180 savecore $savecore_flags /var/crash 181fi 182 183 echo -n 'checking quotas:' 184quotacheck -a 185 echo ' done.' 186quotaon -a 187 188# build ps databases 189echo 'building databases...' 190kvm_mkdb /netbsd 191dev_mkdb 192 193chmod 666 /dev/tty[pqrs]* 194 195# check the password temp/lock file 196if [ -f /etc/ptmp ] 197then 198 logger -s -p auth.err \ 199 'password file may be incorrect -- /etc/ptmp exists' 200fi 201 202virecovery=/var/tmp/vi.recover/recover.* 203if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then 204 echo preserving editor files 205 for i in $virecovery; do 206 sendmail -t < $i 207 done 208fi 209 210echo clearing /tmp 211 212# Prune quickly with one rm, then use find to clean up /tmp/[lq]* (this 213# is not needed with mfs /tmp, but doesn't hurt anything). 214(cd /tmp && rm -rf [a-km-pr-zA-Z]* && 215 find . ! -name . ! -name lost+found ! -name quota.user \ 216 ! -name quota.group -exec rm -rf -- {} \; -type d -prune) 217 218if [ -f /var/account/acct ]; then 219 echo 'turning on accounting'; accton /var/account/acct 220fi 221 222echo -n standard daemons: 223echo -n ' update'; update 224echo -n ' cron'; cron 225echo '.' 226 227# now start all the other daemons 228echo -n starting network daemons: 229 230if [ X$gated_flags != XNO -a -r /etc/gated.conf ]; then 231 echo -n ' gated'; gated $gated_flags 232elif [ "X$routed_flags" != XNO ]; then 233 echo -n ' routed'; routed $routed_flags 234fi 235 236if [ "X$mrouted_flags" != XNO ]; then 237 echo -n ' mrouted'; mrouted $mrouted_flags 238fi 239 240if [ "X$timed_flags" != XNO ]; then 241 echo -n ' time daemon'; timed $timed_flags 242fi 243 244if [ "X$xntpd_flags" != XNO ]; then 245 echo -n ' ntp daemon'; xntpd $xntpd_flags 246fi 247 248if [ "X$dhcpd_flags" != XNO -a -r /etc/dhcpd.conf ]; then 249 echo -n ' dhcpd'; dhcpd $dhcpd_flags 250fi 251 252if [ X$rwhod = XYES ]; then 253 echo -n ' rwhod'; rwhod 254fi 255 256if [ "X$lpd_flags" != XNO ]; then 257 echo -n ' printer'; lpd $lpd_flags 258fi 259 260# We call sendmail with a full path so that SIGHUP works. 261if [ "X$sendmail_flags" != XNO -a -r /etc/sendmail.cf ]; then 262 echo -n ' sendmail'; /usr/sbin/sendmail $sendmail_flags 263fi 264 265if [ "X$rarpd_flags" != XNO -a -r /etc/ethers ]; then 266 echo -n ' rarpd'; rarpd $rarpd_flags 267fi 268 269if [ "X$rbootd_flags" != XNO -a -r /etc/rbootd.conf ]; then 270 echo -n ' rbootd'; rbootd $rbootd_flags 271fi 272 273if [ "X$inetd_flags" != XNO -a -r /etc/inetd.conf ]; then 274 echo -n ' inetd'; inetd $inetd_flags 275fi 276 277echo '.' 278 279. /etc/rc.local 280 281date 282exit 0 283