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