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