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