rc revision 1.61
1# $NetBSD: rc,v 1.61 1996/10/03 07:11:35 mrg 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 ] 22then 23 ccdconfig -C 24fi 25 26if [ -e /fastboot ] 27then 28 echo "Fast boot: skipping disk checks." 29elif [ $1x = autobootx ] 30then 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 66swapon -a 67 68umount -a >/dev/null 2>&1 69mount -a -t nonfs 70rm -f /fastboot # XXX (root now writeable) 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# set hostname, turn on network 77echo 'starting network' 78. /etc/netstart 79 80mount /usr >/dev/null 2>&1 81mount /var >/dev/null 2>&1 82 83# clean up left-over files 84rm -f /etc/nologin 85rm -f /var/spool/lock/LCK.* 86rm -f /var/spool/uucp/STST/* 87(cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; }) 88 89echo -n 'starting system logger' 90rm -f /dev/log 91syslogd 92 93# $timed_flags is imported from /etc/netstart; 94# if $timed_flags == NO, timed isn't run. 95if [ "X${timed_flags}" != X"NO" ]; then 96 echo -n ', time daemon'; timed $timed_flags 97fi 98echo '.' 99 100# /var/crash should be a directory or a symbolic link 101# to the crash directory if core dumps are to be saved. 102if [ -d /var/crash ]; then 103 echo checking for core dump... 104 savecore /var/crash 105fi 106 107 echo -n 'checking quotas:' 108quotacheck -a 109 echo ' done.' 110quotaon -a 111 112# build ps databases 113echo 'building databases...' 114kvm_mkdb /netbsd 115dev_mkdb 116 117chmod 666 /dev/tty[pqrs]* 118 119# check the password temp/lock file 120if [ -f /etc/ptmp ] 121then 122 logger -s -p auth.err \ 123 'password file may be incorrect -- /etc/ptmp exists' 124fi 125 126virecovery=/var/tmp/vi.recover/recover.* 127if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then 128 echo preserving editor files 129 for i in $virecovery; do 130 sendmail -t < $i 131 done 132fi 133 134echo clearing /tmp 135 136# prune quickly with one rm, then use find to clean up /tmp/[lq]* 137# (not needed with mfs /tmp, but doesn't hurt there...) 138(cd /tmp && rm -rf [a-km-pr-zA-Z]* && 139 find . ! -name . ! -name lost+found ! -name quota.user \ 140 ! -name quota.group -exec rm -rf -- {} \; -type d -prune) 141 142if [ -f /var/account/acct ]; then 143 echo 'turning on accounting'; accton /var/account/acct 144fi 145 146echo -n standard daemons: 147echo -n ' update'; update 148echo -n ' cron'; cron 149echo '.' 150 151echo -n starting network daemons: 152 153# $gated and $routed_flags are imported from /etc/netstart. 154# If $gated == YES, gated is used; otherwise routed. 155# If $routed_flags == NO, routed isn't run. 156if [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then 157 echo -n ' gated'; gated $gated_flags 158elif [ "X${routed_flags}" != X"NO" ]; then 159 echo -n ' routed'; routed $routed_flags 160fi 161 162# $mrouted_flags is imported from /etc/netstart; 163# If $mrouted_flags == NO, then mrouted isn't run. 164if [ "X${mrouted_flags}" != X"NO" ]; then 165 echo -n ' mrouted'; mrouted $mrouted_flags 166fi 167 168# $named_flags is imported from /etc/netstart; 169# if $named_flags != NO, named is run. 170if [ "X${named_flags}" != X"NO" ]; then 171 echo -n ' named'; named $named_flags 172fi 173 174# $dhcpd_flags is imported from /etc/netstart; 175# if $dhcpd_flags != NO, dhcpd is run. 176if [ "X${dhcpd_flags}" != X"NO" -a -r /etc/dhcpd.conf ]; then 177 echo -n ' dhcpd'; dhcpd $dhcpd_flags 178fi 179 180# $rwhod is imported from /etc/netstart; 181# if $rwhod == YES, rwhod is run. 182if [ X${rwhod} = X"YES" ]; then 183 echo -n ' rwhod'; rwhod 184fi 185 186echo -n ' printer'; lpd 187 188# $sendmail_flags is imported from /etc/netstart; 189# If $sendmail_flags == NO or /etc/sendmail.cf doesn't exist, then 190# sendmail isn't run. We call sendmail with a full path so that 191# SIGHUP works. 192if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then 193 echo -n ' sendmail'; /usr/sbin/sendmail ${sendmail_flags} 194fi 195 196echo -n ' inetd'; inetd 197 198# $rarpd_flags is imported from /etc/netstart; 199# If $rarpd_flags == NO or /etc/ethers doesn't exist, then 200# rarpd isn't run. 201if [ "X${rarpd_flags}" != X"NO" -a -r /etc/ethers ]; then 202 echo -n ' rarpd'; rarpd ${rarpd_flags} 203fi 204 205# $rbootd_flags is imported from /etc/netstart; 206# If $rbootd_flags == NO or /etc/rbootd.conf doesn't exist, then 207# rbootd isn't run. 208if [ "X${rbootd_flags}" != X"NO" -a -r /etc/rbootd.conf ]; then 209 echo -n ' rbootd'; rbootd ${rbootd_flags} 210fi 211 212echo '.' 213 214echo -n 'starting rpc daemons:' 215echo -n ' portmap'; portmap 216 217# $bootparamd_flags is imported from /etc/netstart; 218# If $bootparamd_flags == NO or /etc/bootparams doesn't exist, then 219# bootparamd isn't run. 220if [ "X${bootparamd_flags}" != X"NO" -a -r /etc/bootparams ]; then 221 echo -n ' rpc.bootparamd'; rpc.bootparamd ${bootparamd_flags} 222fi 223 224if [ "X${ypserv_flags}" != X"NO" ]; then 225 echo -n ' ypserv'; ypserv ${ypserv_flags} 226fi 227 228if [ "X${yppasswdd_flags}" != X"NO" ]; then 229 echo -n ' rpc.yppasswdd'; rpc.yppasswdd ${yppasswdd_flags} 230fi 231 232if [ "X${ypbind_flags}" != X"NO" ]; then 233 echo -n ' ypbind'; ypbind ${ypbind_flags} 234fi 235 236# $nfs_server is imported from /etc/netstart; 237# if $nfs_server == YES, the machine is setup for being an nfs server 238if [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then 239 rm -f /var/db/mountdtab 240 echo -n > /var/db/mountdtab 241 echo -n ' mountd'; mountd 242 echo -n ' nfsd'; nfsd -tun 4 243fi 244 245# $nfs_client is imported from /etc/netstart; 246# if $nfs_client == YES, the machine is setup for being an nfs client 247if [ X${nfs_client} = X"YES" ]; then 248 echo -n ' nfsiod'; nfsiod -n 4 249fi 250 251if [ X${amd} = X"YES" -a -d ${amd_dir} -a -r ${amd_master} ]; then 252 echo -n ' amd' 253 amd -l syslog -x error,noinfo,nostats -p \ 254 -a ${amd_dir} `cat ${amd_master}` > /var/run/amd.pid 255fi 256 257echo '.' 258mount -a -t nfs 259 260. /etc/rc.local 261 262date 263exit 0 264