rc revision 1.84
1# $NetBSD: rc,v 1.84 1997/07/15 11:19:20 veego Exp $ 2# originally 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 16export HOME=/ 17export PATH=/sbin:/bin:/usr/sbin:/usr/bin 18 19# Configure ccd devices. 20if [ -f /etc/ccd.conf ]; then 21 ccdconfig -C 22fi 23 24# Add all block-type swap devices; these might be necessary 25# during disk checks. 26swapctl -A -t blk 27 28if [ -e /fastboot ]; then 29 echo "Fast boot: skipping disk checks." 30elif [ "$1" = autoboot ]; then 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 66umount -a >/dev/null 2>&1 67mount / 68rm -f /fastboot # XXX (root now writeable) 69 70if [ -f /etc/rc.conf ]; then 71 . /etc/rc.conf 72fi 73 74# set flags on ttys. (do early, in case they use tty for SLIP in netstart) 75echo 'setting tty flags' 76ttyflags -a 77 78# load kernel modules specified in /etc/lkm.conf if the /usr filesystem 79# is already present with "/" or can be mounted now 80if [ "$lkm_init" != NO ] && [ -f /etc/rc.lkm ]; then 81 mount /usr >/dev/null 2>&1 82 if [ -x /usr/bin/ld ]; then 83 lkmstage=BEFORENET 84 . /etc/rc.lkm 85 fi 86fi 87 88# set hostname, turn on network 89echo 'starting network' 90sh /etc/netstart 91if [ $? -ne 0 ]; then 92 exit 1 93fi 94 95mount /usr >/dev/null 2>&1 96mount /var >/dev/null 2>&1 97 98# "Critical" file systems are now mounted. Go ahead and swap 99# to files now, since they will be residing in the critical file 100# systems (or, at least, better). 101swapctl -A -t noblk 102 103# clean up left-over files 104rm -f /etc/nologin 105rm -f /var/spool/lock/LCK.* 106rm -f /var/spool/uucp/STST/* 107(cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; }) 108 109# start the system logger first, so that all messages from daemons 110# are logged, then start savecore to get a dump on low memory systems 111# and then start the name server. 112 113if [ "$syslogd_flags" != NO ]; then 114 if [ "$syslogd_flags" = DEFAULT ]; then 115 syslogd_flags="" 116 fi 117 echo 'starting system logger' 118 rm -f /dev/log 119 syslogd $syslogd_flags 120fi 121 122# /var/crash should be a directory or a symbolic link 123# to the crash directory if core dumps are to be saved. 124if [ "$savecore_flags" != NO ] && [ -d /var/crash ]; then 125 if [ "$savecore_flags" = DEFAULT ]; then 126 savecore_flags="" 127 fi 128 echo checking for core dump... 129 savecore $savecore_flags /var/crash 130fi 131 132if [ "$named_flags" != NO ]; then 133 if [ "$named_flags" = DEFAULT ]; then 134 named_flags="" 135 fi 136 echo 'starting name server'; named $named_flags 137fi 138 139# now start the rpc servers, for YP server/client. 140echo -n 'starting rpc daemons:' 141 142# note that portmap is generally required for all other rpc services. 143if [ "$portmap" != NO ]; then 144 echo -n ' portmap'; portmap 145fi 146 147if [ "$ypserv_flags" != NO ]; then 148 if [ "$ypserv_flags" = DEFAULT ]; then 149 ypserv_flags="-d" 150 fi 151 echo -n ' ypserv'; ypserv $ypserv_flags 152fi 153 154if [ "$ypbind_flags" != NO ]; then 155 if [ "$ypbind_flags" = DEFAULT ]; then 156 ypbind_flags="" 157 fi 158 echo -n ' ypbind'; ypbind $ypbind_flags 159fi 160 161if [ "$yppasswdd_flags" != NO ]; then 162 if [ "$yppasswdd_flags" = DEFAULT ]; then 163 yppasswdd_flags="" 164 fi 165 echo -n ' rpc.yppasswdd'; rpc.yppasswdd $yppasswdd_flags 166fi 167 168if [ "$bootparamd_flags" != NO ] && [ -r /etc/bootparams ]; then 169 if [ "$bootparamd_flags" = DEFAULT ]; then 170 bootparamd_flags="" 171 fi 172 echo -n ' rpc.bootparamd'; rpc.bootparamd $bootparamd_flags 173fi 174 175echo '.' 176 177# load kernel modules specified in /etc/lkm.conf 178if [ "$lkm_init" != NO ] && [ -f /etc/rc.lkm ]; then 179 lkmstage=BEFOREMOUNT 180 . /etc/rc.lkm 181fi 182 183mount -a 184 185# now start the rpc servers, for NFS server/client. 186echo -n 'starting nfs-rpc daemons:' 187 188nfs_locking=NO 189 190if [ "$nfs_server" = YES ] && [ -r /etc/exports ]; then 191 if [ "$mountd_flags" = DEFAULT ]; then 192 mountd_flags="" 193 fi 194 rm -f /var/db/mountdtab 195 echo -n > /var/db/mountdtab 196 echo -n ' mountd'; mountd $mountd_flags 197 if [ "$nfsd_flags" = DEFAULT ]; then 198 nfsd_flags="-tun 4" 199 fi 200 echo -n ' nfsd'; nfsd $nfsd_flags 201 nfs_locking=MAYBE 202fi 203 204if [ "$nfs_client" = YES ]; then 205 if [ "$nfsiod_flags" = DEFAULT ]; then 206 nfsiod_flags="-n 4" 207 fi 208 echo -n ' nfsiod'; nfsiod $nfsiod_flags 209 nfs_locking=MAYBE 210fi 211 212if [ "$nfs_locking" != NO ]; then 213 if [ "$statd_flags" != NO ]; then 214 if [ "$statd_flags" = DEFAULT ]; then 215 statd_flags="" 216 fi 217 echo -n ' rpc.statd'; rpc.statd $statd_flags 218 fi 219 220 if [ "$lockd_flags" != NO ]; then 221 if [ "$lockd_flags" = DEFAULT ]; then 222 lockd_flags="" 223 fi 224 echo -n ' rpc.lockd'; rpc.lockd $lockd_flags 225 fi 226fi 227 228if [ "$amd_flags" != NO ] && [ -d "$amd_dir" -a -r "$amd_master" ]; then 229 if [ "$amd_flags" = DEFAULT ]; then 230 amd_flags="-l syslog -x error,noinfo,nostats" 231 fi 232 echo -n ' amd' 233 amd $amd_flags -p -a $amd_dir `cat $amd_master` > /var/run/amd.pid 234fi 235 236echo '.' 237 238if [ -f /sbin/ldconfig ]; then 239 echo 'creating runtime link editor directory cache.' 240 if [ -f /etc/ld.so.conf ]; then 241 ldconfig `cat /etc/ld.so.conf` 242 else 243 ldconfig 244 fi 245fi 246 247# load kernel modules specified in /etc/lkm.conf 248if [ "$lkm_init" != NO ] && [ -f /etc/rc.lkm ]; then 249 lkmstage=AFTERMOUNT 250 . /etc/rc.lkm 251fi 252 253 echo -n 'checking quotas:' 254quotacheck -a 255 echo ' done.' 256quotaon -a 257 258# build ps databases 259echo 'building databases...' 260kvm_mkdb /netbsd 261dev_mkdb 262 263chmod 666 /dev/tty[pqrs]* 264 265# check the password temp/lock file 266if [ -f /etc/ptmp ] 267then 268 logger -s -p auth.err \ 269 'password file may be incorrect -- /etc/ptmp exists' 270fi 271 272virecovery=/var/tmp/vi.recover/recover.* 273if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then 274 echo preserving editor files 275 for i in $virecovery; do 276 sendmail -t < $i 277 done 278fi 279 280echo clearing /tmp 281 282# Prune quickly with one rm, then use find to clean up /tmp/[lq]* (this 283# is not needed with mfs /tmp, but doesn't hurt anything). 284(cd /tmp && rm -rf [a-km-pr-zA-Z]* && 285 find . ! -name . ! -name lost+found ! -name quota.user \ 286 ! -name quota.group -exec rm -rf -- {} \; -type d -prune) 287 288# Update kernel info in /etc/motd 289# Must be done *before* interactive logins are possible to prevent 290# possible race conditions. 291if [ "$update_motd" != NO ]; then 292 echo 'updating motd.' 293 if [ ! -f /etc/motd ]; then 294 install -c -o root -g wheel -m 664 /dev/null /etc/motd 295 fi 296 T=/tmp/_motd 297 rm -f $T 298 sysctl -n kern.version | sed 1q > $T 299 echo "" >> $T 300 sed '1,/^$/d' < /etc/motd >> $T 301 cmp -s $T /etc/motd || cp $T /etc/motd 302 rm -f $T 303fi 304 305if [ -f /var/account/acct ]; then 306 echo 'turning on accounting'; accton /var/account/acct 307fi 308 309echo -n standard daemons: 310if [ "$update_flags" != NO ]; then 311 if [ "$update_flags" = DEFAULT ]; then 312 update_flags="30" 313 fi 314 echo -n ' update'; update $update_flags 315fi 316echo -n ' cron'; cron 317echo '.' 318 319# now start all the other daemons 320echo -n starting network daemons: 321 322if [ "$gated_flags" != NO ] && [ -r /etc/gated.conf ]; then 323 if [ "$gated_flags" = DEFAULT ]; then 324 gated_flags="" 325 fi 326 echo -n ' gated'; gated $gated_flags 327elif [ "$routed_flags" != NO ]; then 328 if [ "$routed_flags" = DEFAULT ]; then 329 routed_flags="-q" 330 fi 331 echo -n ' routed'; routed $routed_flags 332fi 333 334if [ "$mrouted_flags" != NO ]; then 335 if [ "$mrouted_flags" = DEFAULT ]; then 336 mrouted_flags="" 337 fi 338 echo -n ' mrouted'; mrouted $mrouted_flags 339fi 340 341if [ "$timed_flags" != NO ]; then 342 if [ "$timed_flags" = DEFAULT ]; then 343 timed_flags="" 344 fi 345 echo -n ' timed'; timed $timed_flags 346fi 347 348if [ "$ntpdate_hosts" != NO ]; then 349 if [ "$ntpdate_hosts" = DEFAULT ]; then 350 ntpdate_hosts=`awk '/^server/ {print $2}' </etc/ntp.conf` 351 fi 352 353 if [ -n "$ntpdate_hosts" ]; then 354 echo -n 'ntpdate:' 355 ntpdate -b $ntpdate_hosts 356 fi 357fi 358 359if [ "$xntpd_flags" != NO ]; then 360 if [ "$xntpd_flags" = DEFAULT ]; then 361 xntpd_flags="-p /var/run/xntpd.pid" 362 fi 363 echo -n ' xntpd'; xntpd $xntpd_flags 364fi 365 366if [ "$dhcpd_flags" != NO ] && [ -r /etc/dhcpd.conf ]; then 367 if [ "$dhcpd_flags" = DEFAULT ]; then 368 dhcpd_flags="" 369 fi 370 echo -n ' dhcpd'; dhcpd $dhcpd_flags 371fi 372 373if [ "$rwhod" = YES ]; then 374 echo -n ' rwhod'; rwhod 375fi 376 377if [ "$lpd_flags" != NO ]; then 378 if [ "$lpd_flags" = DEFAULT ]; then 379 lpd_flags="" 380 fi 381 echo -n ' printer'; lpd $lpd_flags 382fi 383 384# We call sendmail with a full path so that SIGHUP works. 385if [ "$sendmail_flags" != NO ] && [ -r /etc/sendmail.cf ]; then 386 if [ "$sendmail_flags" = DEFAULT ]; then 387 sendmail_flags="-bd -q30m" 388 fi 389 echo -n ' sendmail'; /usr/sbin/sendmail $sendmail_flags 390fi 391 392if [ "$rarpd_flags" != NO ] && [ -r /etc/ethers ]; then 393 if [ "$rarpd_flags" = DEFAULT ]; then 394 rarpd_flags="-a" 395 fi 396 echo -n ' rarpd'; rarpd $rarpd_flags 397fi 398 399if [ "$rbootd_flags" != NO ] && [ -r /etc/rbootd.conf ]; then 400 if [ "$rbootd_flags" = DEFAULT ]; then 401 rbootd_flags="" 402 fi 403 echo -n ' rbootd'; rbootd $rbootd_flags 404fi 405 406if [ "$mopd_flags" != NO ]; then 407 if [ "$mopd_flags" = DEFAULT ]; then 408 mopd_flags="-a" 409 fi 410 echo -n ' mopd'; mopd $mopd_flags 411fi 412 413if [ "$inetd_flags" != NO ] && [ -r /etc/inetd.conf ]; then 414 if [ "$inetd_flags" = DEFAULT ]; then 415 inetd_flags="" 416 fi 417 echo -n ' inetd'; inetd $inetd_flags 418fi 419 420echo '.' 421 422# Kerberos runs ONLY on the Kerberos server machine 423if [ "$kerberos_server" = YES ]; then 424 echo -n 'starting kerberos daemons:' 425 echo -n ' kerberos'; kerberos >> /var/log/kerberos.log & 426 echo -n ' kadmind'; kadmind -n >> /var/log/kadmind.log & 427 echo '.' 428fi 429 430. /etc/rc.local 431 432date 433exit 0 434