rc revision 1.69
183194Sasmodai# $NetBSD: rc,v 1.69 1997/03/10 10:15:11 mycroft Exp $ 283194Sasmodai# from: @(#)rc 8.2 (Berkeley) 3/17/94 383194Sasmodai 483194Sasmodai# System startup script run by init on autoboot 583194Sasmodai# or after single-user. 683194Sasmodai# Output and error are redirected to console by init, 783194Sasmodai# and the console is the controlling terminal. 883194Sasmodai 983194Sasmodaistty status '^T' 1083194Sasmodai 1183194Sasmodai# Set shell to ignore SIGINT (2), but not children; 1283194Sasmodai# shell catches SIGQUIT (3) and returns to single user after fsck. 1383194Sasmodaitrap : 2 1483194Sasmodaitrap : 3 # shouldn't be needed 1583194Sasmodai 1683194Sasmodaiexport HOME=/ 1783194Sasmodaiexport PATH=/sbin:/bin:/usr/sbin:/usr/bin 1883194Sasmodai 1983194Sasmodai# Configure ccd devices. 2083194Sasmodaiif [ -f /etc/ccd.conf ]; then 2183194Sasmodai ccdconfig -C 2283194Sasmodaifi 2383194Sasmodai 2483194Sasmodaiif [ -e /fastboot ]; then 2583194Sasmodai echo "Fast boot: skipping disk checks." 2683194Sasmodaielif [ "$1" = autoboot ]; then 27237573Sissyl0 echo "Automatic boot in progress: starting file system checks." 2883194Sasmodai fsck -p 2983194Sasmodai case $? in 3083194Sasmodai 0) 3183194Sasmodai ;; 3283194Sasmodai 2) 3383194Sasmodai exit 1 3483194Sasmodai ;; 3583194Sasmodai 4) 3683203Sasmodai echo "Rebooting..." 3783194Sasmodai reboot 38103668Smike echo "Reboot failed; help!" 39237573Sissyl0 exit 1 40237573Sissyl0 ;; 4183194Sasmodai 8) 4283194Sasmodai echo "Automatic file system check failed; help!" 4383194Sasmodai exit 1 4483194Sasmodai ;; 4583194Sasmodai 12) 4683203Sasmodai echo "Boot interrupted." 4783194Sasmodai exit 1 4883194Sasmodai ;; 4983194Sasmodai 130) 5083194Sasmodai # interrupt before catcher installed 51104945Stjr exit 1 52237573Sissyl0 ;; 53237573Sissyl0 *) 54237573Sissyl0 echo "Unknown error; help!" 55237573Sissyl0 exit 1 56237591Sjoel ;; 57237573Sissyl0 esac 58104945Stjrfi 59104945Stjr 60107387Srutrap "echo 'Boot interrupted.'; exit 1" 3 61104945Stjr 62104945Stjrswapon -a 63104945Stjr 64104945Stjrumount -a >/dev/null 2>&1 65104945Stjrmount -a -t nonfs 66104945Stjrrm -f /fastboot # XXX (root now writeable) 67104945Stjr 68104945Stjrif [ -s /etc/rc.conf ]; then 69104945Stjr . /etc/rc.conf 70104945Stjrfi 71104945Stjr 72104945Stjr# set flags on ttys. (do early, in case they use tty for SLIP in netstart) 73104945Stjrecho 'setting tty flags' 74104945Stjrttyflags -a 75104945Stjr 76104945Stjr# load any kernel modules specified in /etc/lkm.conf 77104945Stjrif [ "$lkm_init" != NO ] && [ -f /etc/rc.lkm ]; then 78104945Stjr . /etc/rc.lkm 79104945Stjrfi 80104945Stjr 81104945Stjr# set hostname, turn on network 82104945Stjrecho 'starting network' 83104945Stjr. /etc/netstart 84104945Stjr 85104945Stjrmount /usr >/dev/null 2>&1 86107387Srumount /var >/dev/null 2>&1 87104945Stjr 88107387Sru# clean up left-over files 89104945Stjrrm -f /etc/nologin 90104945Stjrrm -f /var/spool/lock/LCK.* 91104945Stjrrm -f /var/spool/uucp/STST/* 92104945Stjr(cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; }) 93104945Stjr 94104945Stjr# start the system logger first, so that all messages 95104945Stjr# from daemons are logged, and the name server next. 96104945Stjr 97104945Stjrif [ "$syslogd_flags" != NO ]; then 98104945Stjr if [ "$syslogd_flags" = DEFAULT ]; then 99104945Stjr syslogd_flags="" 100104945Stjr fi 101104945Stjr echo 'starting system logger' 102104945Stjr rm -f /dev/log 103104945Stjr syslogd $syslogd_flags 104104945Stjrfi 105104945Stjr 106104945Stjrif [ "$named_flags" != NO ]; then 107104945Stjr if [ "$named_flags" = DEFAULT ]; then 108104945Stjr named_flags="" 109104945Stjr fi 110104945Stjr echo 'starting name server'; named $named_flags 111104945Stjrfi 112104945Stjr 113104945Stjr# now start the rpc servers, for YP server/client, NFS. 114104945Stjrecho -n 'starting rpc daemons:' 115104945Stjr 116104945Stjr# note that portmap is generally required for all other rpc services. 117104945Stjrif [ "$portmap" != NO ]; then 118104945Stjr echo -n ' portmap'; portmap 119104945Stjrfi 120104945Stjr 121104945Stjrif [ "$ypserv_flags" != NO ]; then 122104945Stjr if [ "$ypserv_flags" = DEFAULT ]; then 123104945Stjr ypserv_flags="-d" 12483194Sasmodai fi 12583203Sasmodai echo -n ' ypserv'; ypserv $ypserv_flags 126235286Sgjbfi 12783194Sasmodai 12883194Sasmodaiif [ "$ypbind_flags" != NO ]; then 12983203Sasmodai if [ "$ypbind_flags" = DEFAULT ]; then 13083194Sasmodai ypbind_flags="" 13183194Sasmodai fi 13283203Sasmodai echo -n ' ypbind'; ypbind $ypbind_flags 133235286Sgjbfi 13483203Sasmodai 135107387Sruif [ "$yppasswdd_flags" != NO ]; then 13683194Sasmodai if [ "$yppasswdd_flags" = DEFAULT ]; then 13783194Sasmodai yppasswdd_flags="" 13883194Sasmodai fi 13983194Sasmodai echo -n ' rpc.yppasswdd'; rpc.yppasswdd $yppasswdd_flags 140237573Sissyl0fi 141237573Sissyl0 142237573Sissyl0if [ "$bootparamd_flags" != NO ] && [ -r /etc/bootparams ]; then 143237573Sissyl0 if [ "$bootparamd_flags" = DEFAULT ]; then 144237573Sissyl0 bootparamd_flags="" 14583194Sasmodai fi 14683194Sasmodai echo -n ' rpc.bootparamd'; rpc.bootparamd $bootparamd_flags 14783203Sasmodaifi 14883194Sasmodai 14983194Sasmodainfs_locking=NO 15083194Sasmodai 15183194Sasmodaiif [ "$nfs_server" = YES ] && [ -r /etc/exports ]; then 152104945Stjr if [ "$mountd_flags" = DEFAULT ]; then 153104945Stjr mountd_flags="" 154104945Stjr fi 155104945Stjr rm -f /var/db/mountdtab 15683194Sasmodai echo -n > /var/db/mountdtab 15783194Sasmodai echo -n ' mountd'; mountd $mountd_flags 15883194Sasmodai if [ "$nfsd_flags" = DEFAULT ]; then 15983194Sasmodai nfsd_flags="-tun 4" 16083194Sasmodai fi 16183194Sasmodai echo -n ' nfsd'; nfsd $nfsd_flags 16283194Sasmodai nfs_locking=MAYBE 16383194Sasmodaifi 164104945Stjr 165237573Sissyl0if [ "$nfs_client" = YES ]; then 166237573Sissyl0 if [ "$nfsiod_flags" = DEFAULT ]; then 167237573Sissyl0 nfsiod_flags="-n 4" 168237573Sissyl0 fi 16983194Sasmodai echo -n ' nfsiod'; nfsiod $nfsiod_flags 17084298Sru nfs_locking=MAYBE 17183194Sasmodaifi 17283203Sasmodai 17383194Sasmodaiif [ "$nfs_locking" != NO ]; then 17483194Sasmodai if [ "$statd_flags" != NO ]; then 17583194Sasmodai if [ "$statd_flags" = DEFAULT ]; then 17683194Sasmodai statd_flags="" 17783194Sasmodai fi 17883194Sasmodai echo -n ' statd'; rpc.statd $statd_flags 179108776Stjr fi 180108776Stjr 181108776Stjr if [ "$lockd_flags" != NO ]; then 182108776Stjr if [ "$lockd_flags" = DEFAULT ]; then 183108776Stjr lockd_flags="" 184108776Stjr fi 185 echo -n ' lockd'; rpc.lockd $lockd_flags 186 fi 187fi 188 189if [ "$amd_flags" != NO ] && [ -d "$amd_dir" -a -r "$amd_master" ]; then 190 if [ "$amd_flags" = DEFAULT ]; then 191 amd_flags="-l syslog -x error,noinfo,nostats" 192 fi 193 echo -n ' amd' 194 amd $amd_flags -p -a $amd_dir `cat $amd_master` > /var/run/amd.pid 195fi 196 197echo '.' 198mount -a -t nfs 199 200if [ -f /sbin/ldconfig ]; then 201 echo 'creating runtime link editor directory cache.' 202 if [ -s /etc/ld.so.conf ]; then 203 ldconfig `cat /etc/ld.so.conf` 204 else 205 ldconfig 206 fi 207fi 208 209# /var/crash should be a directory or a symbolic link 210# to the crash directory if core dumps are to be saved. 211if [ "$savecore_flags" != NO ] && [ -d /var/crash ]; then 212 if [ "$savecore_flags" = DEFAULT ]; then 213 savecore_flags="" 214 fi 215 echo checking for core dump... 216 savecore $savecore_flags /var/crash 217fi 218 219 echo -n 'checking quotas:' 220quotacheck -a 221 echo ' done.' 222quotaon -a 223 224# build ps databases 225echo 'building databases...' 226kvm_mkdb /netbsd 227dev_mkdb 228 229chmod 666 /dev/tty[pqrs]* 230 231# check the password temp/lock file 232if [ -f /etc/ptmp ] 233then 234 logger -s -p auth.err \ 235 'password file may be incorrect -- /etc/ptmp exists' 236fi 237 238virecovery=/var/tmp/vi.recover/recover.* 239if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then 240 echo preserving editor files 241 for i in $virecovery; do 242 sendmail -t < $i 243 done 244fi 245 246echo clearing /tmp 247 248# Prune quickly with one rm, then use find to clean up /tmp/[lq]* (this 249# is not needed with mfs /tmp, but doesn't hurt anything). 250(cd /tmp && rm -rf [a-km-pr-zA-Z]* && 251 find . ! -name . ! -name lost+found ! -name quota.user \ 252 ! -name quota.group -exec rm -rf -- {} \; -type d -prune) 253 254if [ -f /var/account/acct ]; then 255 echo 'turning on accounting'; accton /var/account/acct 256fi 257 258echo -n standard daemons: 259echo -n ' update'; update 260echo -n ' cron'; cron 261echo '.' 262 263# now start all the other daemons 264echo -n starting network daemons: 265 266if [ "$gated_flags" != NO ] && [ -r /etc/gated.conf ]; then 267 if [ "$gated_flags" = DEFAULT ]; then 268 gated_flags="" 269 fi 270 echo -n ' gated'; gated $gated_flags 271elif [ "$routed_flags" != NO ]; then 272 if [ "$routed_flags" = DEFAULT ]; then 273 routed_flags="-q" 274 fi 275 echo -n ' routed'; routed $routed_flags 276fi 277 278if [ "$mrouted_flags" != NO ]; then 279 if [ "$mrouted_flags" = DEFAULT ]; then 280 mrouted_flags="" 281 fi 282 echo -n ' mrouted'; mrouted $mrouted_flags 283fi 284 285if [ "$timed_flags" != NO ]; then 286 if [ "$timed_flags" = DEFAULT ]; then 287 timed_flags="" 288 fi 289 echo -n ' timed'; timed $timed_flags 290fi 291 292if [ "$xntpd_flags" != NO ]; then 293 if [ "$xntpd_flags" = DEFAULT ]; then 294 xntpd_flags="" 295 fi 296 echo -n ' xntpd'; xntpd $xntpd_flags 297fi 298 299if [ "$dhcpd_flags" != NO ] && [ -r /etc/dhcpd.conf ]; then 300 if [ "$dhcpd_flags" = DEFAULT ]; then 301 dhcpd_flags="" 302 fi 303 echo -n ' dhcpd'; dhcpd $dhcpd_flags 304fi 305 306if [ "$rwhod" = YES ]; then 307 echo -n ' rwhod'; rwhod 308fi 309 310if [ "$lpd_flags" != NO ]; then 311 if [ "$lpd_flags" = DEFAULT ]; then 312 lpd_flags="" 313 fi 314 echo -n ' printer'; lpd $lpd_flags 315fi 316 317# We call sendmail with a full path so that SIGHUP works. 318if [ "$sendmail_flags" != NO ] && [ -r /etc/sendmail.cf ]; then 319 if [ "$sendmail_flags" = DEFAULT ]; then 320 sendmail_flags="-bd -q30m" 321 fi 322 echo -n ' sendmail'; /usr/sbin/sendmail $sendmail_flags 323fi 324 325if [ "$rarpd_flags" != NO ] && [ -r /etc/ethers ]; then 326 if [ "$rarpd_flags" = DEFAULT ]; then 327 rarpd_flags="-a" 328 fi 329 echo -n ' rarpd'; rarpd $rarpd_flags 330fi 331 332if [ "$rbootd_flags" != NO ] && [ -r /etc/rbootd.conf ]; then 333 if [ "$rbootd_flags" = DEFAULT ]; then 334 rbootd_flags="" 335 fi 336 echo -n ' rbootd'; rbootd $rbootd_flags 337fi 338 339if [ "$inetd_flags" != NO ] && [ -r /etc/inetd.conf ]; then 340 if [ "$inetd_flags" = DEFAULT ]; then 341 inetd_flags="" 342 fi 343 echo -n ' inetd'; inetd $inetd_flags 344fi 345 346echo '.' 347 348. /etc/rc.local 349 350date 351exit 0 352