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