[BACK]Return to bootconf.sh CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / etc / rc.d

File: [cvs.NetBSD.org] / src / etc / rc.d / bootconf.sh (download)

Revision 1.14, Mon Nov 1 14:42:08 2010 UTC (13 years, 4 months ago) by christos
Branch: MAIN
CVS Tags: yamt-pagecache-base7, yamt-pagecache-base6, yamt-pagecache-base5, yamt-pagecache-base4, yamt-pagecache-base3, yamt-pagecache-base2, yamt-pagecache-base, netbsd-6-base, netbsd-6-1-RELEASE, netbsd-6-1-RC4, netbsd-6-1-RC3, netbsd-6-1-RC2, netbsd-6-1-RC1, netbsd-6-1-5-RELEASE, netbsd-6-1-4-RELEASE, netbsd-6-1-3-RELEASE, netbsd-6-1-2-RELEASE, netbsd-6-1-1-RELEASE, netbsd-6-1, netbsd-6-0-RELEASE, netbsd-6-0-RC2, netbsd-6-0-RC1, netbsd-6-0-6-RELEASE, netbsd-6-0-5-RELEASE, netbsd-6-0-4-RELEASE, netbsd-6-0-3-RELEASE, netbsd-6-0-2-RELEASE, netbsd-6-0-1-RELEASE, netbsd-6-0, netbsd-6, matt-nb6-plus-nbase, matt-nb6-plus-base, matt-nb6-plus, matt-mips64-premerge-20101231, cherry-xenmp-base, cherry-xenmp, bouyer-quota2-nbase, bouyer-quota2-base, bouyer-quota2
Branch point for: yamt-pagecache, tls-maxphys
Changes since 1.13: +2 -3 lines

From Anon Ymous:
Send the SIGALRM to the correct process when we timeout. See the note
in src/etc/rc regarding RC_PID.

The former code would leave you with a root shell when the prompt
timed out (if the tty is marked secure) while continuing the boot
process in another shell.  This was easily hidden if you started
xdm(1) at boot, while the root shell remains on another tty
(accessible with CTL-ALT-F1).

#!/bin/sh
#
# $NetBSD: bootconf.sh,v 1.14 2010/11/01 14:42:08 christos Exp $
#

# PROVIDE: bootconf
# REQUIRE: mountcritlocal
# KEYWORD: interactive

$_rc_subr_loaded . /etc/rc.subr

name="bootconf"
start_cmd="bootconf_start"
stop_cmd=":"

bootconf_start()
{
		# Refer to newbtconf(8) for more information
		#

	if [ ! -e /etc/etc.current ]; then
		return 0
	fi
	if [ -h /etc/etc.default ]; then
		def=$(ls -ld /etc/etc.default 2>&1)
		default="${def##*-> *etc.}"
	else
		default=current
	fi
	if [ "$default" = "current" ]; then
		def=$(ls -ld /etc/etc.current 2>&1)
		default="${def##*-> *etc.}"
	fi

	spc=""
	for i in /etc/etc.*; do
		name="${i##/etc/etc.}"
		case $name in
		current|default|\*)
			continue
			;;	
		*)
			if [ "$name" = "$default" ]; then
				echo -n "${spc}[${name}]"
			else
				echo -n "${spc}${name}"
			fi
			spc=" "
			;;
		esac
	done
	echo
	_DUMMY=/etc/passwd
	conf=${_DUMMY}
	while [ ! -d /etc/etc.$conf/. ]; do
		trap "conf=$default; echo; echo Using default of $default" ALRM
		echo -n "Which configuration [$default] ? "
		(sleep 30 && kill -ALRM $RC_PID) >/dev/null 2>&1 &
		read conf
		trap : ALRM
		if [ -z $conf ] ; then
			conf=$default
		fi
		if [ ! -d /etc/etc.$conf/. ]; then
			conf=${_DUMMY}
		fi
	done

	print_rc_metadata "note:Using configuration \"${conf}\""

	case  $conf in
	current|default)
		;;
	*)
		rm -f /etc/etc.current
		ln -s etc.$conf /etc/etc.current
		;;
	esac

	if [ -f /etc/rc.conf ] ; then
		. /etc/rc.conf
	fi
}

load_rc_config $name
run_rc_command "$1"