Home | History | Annotate | Line # | Download | only in rc.d
bootconf.sh revision 1.3
      1 #!/bin/sh
      2 #
      3 # $NetBSD: bootconf.sh,v 1.3 2000/10/09 05:30:17 nisimura Exp $
      4 #
      5 
      6 # PROVIDE: bootconf
      7 # REQUIRE: mountcritlocal
      8 
      9 bootconf_start()
     10 {
     11 		# Refer to newbtconf(8) for more information
     12 		#
     13 
     14 	if [ ! -e /etc/etc.current ]; then
     15 		return 0
     16 	fi
     17 	if [ -h /etc/etc.default ]; then
     18 		def=`ls -ld /etc/etc.default 2>&1`
     19 		default="${def##*-> etc.}"
     20 	else
     21 		default=current
     22 	fi
     23 	spc=""
     24 	for i in /etc/etc.*
     25 	do
     26 		name="${i##/etc/etc.}"
     27 		case $name in
     28 		current|default|\*)
     29 			continue
     30 			;;	
     31 		*)
     32 			if [ "$name" = "$default" ]; then
     33 				echo -n "${spc}[${name}]"
     34 			else
     35 				echo -n "${spc}${name}"
     36 			fi
     37 			spc=" "
     38 			;;
     39 		esac
     40 	done
     41 	echo
     42 	master=$$
     43 	_DUMMY=/etc/passwd
     44 	conf=${_DUMMY}
     45 	while [ ! -d /etc/etc.$conf/. ]; do
     46 		trap "conf=$default; echo; echo Using default of $conf" 14
     47 		echo -n "Which configuration [$default] ? "
     48 		(sleep 30 && kill -ALRM $master) >/dev/null 2>&1 &
     49 		read conf
     50 		trap : 14
     51 		if [ -z $conf ] ; then
     52 			conf=$default
     53 		fi
     54 		if [ ! -d /etc/etc.$conf/. ]; then
     55 			conf=${_DUMMY}
     56 		fi
     57 	done
     58 	rm -f /etc/etc.current
     59 	ln -s /etc/etc.$conf /etc/etc.current
     60 	if [ -f /etc/rc.conf ] ; then
     61 		. /etc/rc.conf
     62 	fi
     63 }
     64 
     65 case "$1" in
     66 *start)
     67 	bootconf_start
     68 	;;
     69 esac
     70