rc revision 1.68
1# $NetBSD: rc,v 1.68 1997/03/10 09:34:59 mycroft 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 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 [ -s /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' 83. /etc/netstart 84 85mount /usr >/dev/null 2>&1 86mount /var >/dev/null 2>&1 87 88# clean up left-over files 89rm -f /etc/nologin 90rm -f /var/spool/lock/LCK.* 91rm -f /var/spool/uucp/STST/* 92(cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; }) 93 94# start the system logger first, so that all messages 95# from daemons are logged, and the name server next. 96 97if [ "$syslogd_flags" != NO ]; then 98 if [ "$syslogd_flags" = DEFAULT ]; then 99 syslogd_flags="" 100 fi 101 echo 'starting system logger' 102 rm -f /dev/log 103 syslogd $syslogd_flags 104fi 105 106if [ "$named_flags" != NO ]; then 107 if [ "$named_flags" = DEFAULT ]; then 108 named_flags="" 109 fi 110 echo 'starting name server'; named $named_flags 111fi 112 113# now start the rpc servers, for YP server/client, NFS. 114echo -n 'starting rpc daemons:' 115 116# note that portmap is generally required for all other rpc services. 117if [ "$portmap" != NO ]; then 118 echo -n ' portmap'; portmap 119fi 120 121if [ "$ypserv_flags" != NO ]; then 122 if [ "$ypserv_flags" = DEFAULT ]; then 123 ypserv_flags="-d" 124 fi 125 echo -n ' ypserv'; ypserv $ypserv_flags 126fi 127 128if [ "$ypbind_flags" != NO ]; then 129 if [ "$ypbind_flags" = DEFAULT ]; then 130 ypbind_flags="" 131 fi 132 echo -n ' ypbind'; ypbind $ypbind_flags 133fi 134 135if [ "$yppasswdd_flags" != NO ]; then 136 if [ "$yppasswdd_flags" = DEFAULT ]; then 137 yppasswdd_flags="" 138 fi 139 echo -n ' rpc.yppasswdd'; rpc.yppasswdd $yppasswdd_flags 140fi 141 142if [ "$bootparamd_flags" != NO ] && [ -r /etc/bootparams ]; then 143 if [ "$bootparamd_flags" = DEFAULT ]; then 144 bootparamd_flags="" 145 fi 146 echo -n ' rpc.bootparamd'; rpc.bootparamd $bootparamd_flags 147fi 148 149nfs_locking=NO 150 151if [ "$nfs_server" = YES ] && [ -r /etc/exports ]; then 152 if [ "$nfsd_flags" = DEFAULT ]; then 153 nfsd_flags="-tun 4" 154 fi 155 rm -f /var/db/mountdtab 156 echo -n > /var/db/mountdtab 157 echo -n ' mountd'; mountd $mountd_flags 158 echo -n ' nfsd'; nfsd $nfsd_flags 159 nfs_locking=MAYBE 160fi 161 162if [ "$nfs_client" = YES ]; then 163 if [ "$nfsiod_flags" = DEFAULT ]; then 164 nfsiod_flags="-n 4" 165 fi 166 echo -n ' nfsiod'; nfsiod $nfsiod_flags 167 nfs_locking=MAYBE 168fi 169 170if [ "$nfs_locking" != NO ]; then 171 if [ "$statd_flags" != NO ]; then 172 if [ "$statd_flags" = DEFAULT ]; then 173 statd_flags="" 174 fi 175 echo ' statd'; rpc.statd $statd_flags 176 fi 177 178 if [ "$lockd_flags" != NO ]; then 179 if [ "$lockd_flags" = DEFAULT ]; then 180 lockd_flags="" 181 fi 182 echo ' lockd'; rpc.lockd $lockd_flags 183 fi 184fi 185 186if [ "$amd_flags" != NO ] && [ -d "$amd_dir" -a -r "$amd_master" ]; then 187 if [ "$amd_flags" = DEFAULT ]; then 188 amd_flags="-l syslog -x error,noinfo,nostats" 189 fi 190 echo -n ' amd' 191 amd $amd_flags -p -a $amd_dir `cat $amd_master` > /var/run/amd.pid 192fi 193 194echo '.' 195mount -a -t nfs 196 197if [ -f /sbin/ldconfig ]; then 198 echo 'creating runtime link editor directory cache.' 199 if [ -s /etc/ld.so.conf ]; then 200 ldconfig `cat /etc/ld.so.conf` 201 else 202 ldconfig 203 fi 204fi 205 206# /var/crash should be a directory or a symbolic link 207# to the crash directory if core dumps are to be saved. 208if [ "$savecore_flags" != NO ] && [ -d /var/crash ]; then 209 if [ "$savecore_flags" = DEFAULT ]; then 210 savecore_flags="" 211 fi 212 echo checking for core dump... 213 savecore $savecore_flags /var/crash 214fi 215 216 echo -n 'checking quotas:' 217quotacheck -a 218 echo ' done.' 219quotaon -a 220 221# build ps databases 222echo 'building databases...' 223kvm_mkdb /netbsd 224dev_mkdb 225 226chmod 666 /dev/tty[pqrs]* 227 228# check the password temp/lock file 229if [ -f /etc/ptmp ] 230then 231 logger -s -p auth.err \ 232 'password file may be incorrect -- /etc/ptmp exists' 233fi 234 235virecovery=/var/tmp/vi.recover/recover.* 236if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then 237 echo preserving editor files 238 for i in $virecovery; do 239 sendmail -t < $i 240 done 241fi 242 243echo clearing /tmp 244 245# Prune quickly with one rm, then use find to clean up /tmp/[lq]* (this 246# is not needed with mfs /tmp, but doesn't hurt anything). 247(cd /tmp && rm -rf [a-km-pr-zA-Z]* && 248 find . ! -name . ! -name lost+found ! -name quota.user \ 249 ! -name quota.group -exec rm -rf -- {} \; -type d -prune) 250 251if [ -f /var/account/acct ]; then 252 echo 'turning on accounting'; accton /var/account/acct 253fi 254 255echo -n standard daemons: 256echo -n ' update'; update 257echo -n ' cron'; cron 258echo '.' 259 260# now start all the other daemons 261echo -n starting network daemons: 262 263if [ "$gated_flags" != NO ] && [ -r /etc/gated.conf ]; then 264 if [ "$gated_flags" = DEFAULT ]; then 265 gated_flags="" 266 fi 267 echo -n ' gated'; gated $gated_flags 268elif [ "$routed_flags" != NO ]; then 269 if [ "$routed_flags" = DEFAULT ]; then 270 routed_flags="-q" 271 fi 272 echo -n ' routed'; routed $routed_flags 273fi 274 275if [ "$mrouted_flags" != NO ]; then 276 if [ "$mrouted_flags" = DEFAULT ]; then 277 mrouted_flags="" 278 fi 279 echo -n ' mrouted'; mrouted $mrouted_flags 280fi 281 282if [ "$timed_flags" != NO ]; then 283 if [ "$timed_flags" = DEFAULT ]; then 284 timed_flags="" 285 fi 286 echo -n ' timed'; timed $timed_flags 287fi 288 289if [ "$xntpd_flags" != NO ]; then 290 if [ "$xntpd_flags" = DEFAULT ]; then 291 xntpd_flags="" 292 fi 293 echo -n ' xntpd'; xntpd $xntpd_flags 294fi 295 296if [ "$dhcpd_flags" != NO ] && [ -r /etc/dhcpd.conf ]; then 297 if [ "$dhcpd_flags" = DEFAULT ]; then 298 dhcpd_flags="" 299 fi 300 echo -n ' dhcpd'; dhcpd $dhcpd_flags 301fi 302 303if [ "$rwhod" = YES ]; then 304 echo -n ' rwhod'; rwhod 305fi 306 307if [ "$lpd_flags" != NO ]; then 308 if [ "$lpd_flags" = DEFAULT ]; then 309 lpd_flags="" 310 fi 311 echo -n ' printer'; lpd $lpd_flags 312fi 313 314# We call sendmail with a full path so that SIGHUP works. 315if [ "$sendmail_flags" != NO ] && [ -r /etc/sendmail.cf ]; then 316 if [ "$sendmail_flags" = DEFAULT ]; then 317 sendmail_flags="-bd -q30m" 318 fi 319 echo -n ' sendmail'; /usr/sbin/sendmail $sendmail_flags 320fi 321 322if [ "$rarpd_flags" != NO ] && [ -r /etc/ethers ]; then 323 if [ "$rarpd_flags" = DEFAULT ]; then 324 rarpd_flags="-a" 325 fi 326 echo -n ' rarpd'; rarpd $rarpd_flags 327fi 328 329if [ "$rbootd_flags" != NO ] && [ -r /etc/rbootd.conf ]; then 330 if [ "$rbootd_flags" = DEFAULT ]; then 331 rbootd_flags="" 332 fi 333 echo -n ' rbootd'; rbootd $rbootd_flags 334fi 335 336if [ "$inetd_flags" != NO ] && [ -r /etc/inetd.conf ]; then 337 if [ "$inetd_flags" = DEFAULT ]; then 338 inetd_flags="" 339 fi 340 echo -n ' inetd'; inetd $inetd_flags 341fi 342 343echo '.' 344 345. /etc/rc.local 346 347date 348exit 0 349