2000-03-10 14:53:23 +03:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2013-01-01 03:21:27 +04:00
|
|
|
# $NetBSD: bootconf.sh,v 1.15 2012/12/31 23:21:27 christos Exp $
|
2000-03-10 14:53:23 +03:00
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: bootconf
|
|
|
|
# REQUIRE: mountcritlocal
|
2009-09-11 22:17:43 +04:00
|
|
|
# KEYWORD: interactive
|
2000-03-10 14:53:23 +03:00
|
|
|
|
2009-09-05 20:24:03 +04:00
|
|
|
$_rc_subr_loaded . /etc/rc.subr
|
|
|
|
|
|
|
|
name="bootconf"
|
|
|
|
start_cmd="bootconf_start"
|
|
|
|
stop_cmd=":"
|
|
|
|
|
2000-03-10 14:53:23 +03:00
|
|
|
bootconf_start()
|
|
|
|
{
|
|
|
|
# Refer to newbtconf(8) for more information
|
|
|
|
#
|
|
|
|
|
|
|
|
if [ ! -e /etc/etc.current ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
if [ -h /etc/etc.default ]; then
|
2004-10-11 19:00:51 +04:00
|
|
|
def=$(ls -ld /etc/etc.default 2>&1)
|
2002-12-05 19:52:58 +03:00
|
|
|
default="${def##*-> *etc.}"
|
2000-03-10 14:53:23 +03:00
|
|
|
else
|
|
|
|
default=current
|
|
|
|
fi
|
2002-03-24 18:08:58 +03:00
|
|
|
if [ "$default" = "current" ]; then
|
2004-10-11 19:00:51 +04:00
|
|
|
def=$(ls -ld /etc/etc.current 2>&1)
|
2002-12-05 19:52:58 +03:00
|
|
|
default="${def##*-> *etc.}"
|
2002-03-24 18:08:58 +03:00
|
|
|
fi
|
|
|
|
|
2000-03-10 14:53:23 +03:00
|
|
|
spc=""
|
2002-03-24 18:08:58 +03:00
|
|
|
for i in /etc/etc.*; do
|
2000-10-09 09:30:17 +04:00
|
|
|
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
|
2000-03-10 14:53:23 +03:00
|
|
|
done
|
|
|
|
echo
|
|
|
|
_DUMMY=/etc/passwd
|
|
|
|
conf=${_DUMMY}
|
|
|
|
while [ ! -d /etc/etc.$conf/. ]; do
|
2003-04-03 15:25:10 +04:00
|
|
|
trap "conf=$default; echo; echo Using default of $default" ALRM
|
2000-03-10 14:53:23 +03:00
|
|
|
echo -n "Which configuration [$default] ? "
|
2010-11-01 17:42:08 +03:00
|
|
|
(sleep 30 && kill -ALRM $RC_PID) >/dev/null 2>&1 &
|
2000-03-10 14:53:23 +03:00
|
|
|
read conf
|
2002-03-24 18:08:58 +03:00
|
|
|
trap : ALRM
|
2000-03-10 14:53:23 +03:00
|
|
|
if [ -z $conf ] ; then
|
|
|
|
conf=$default
|
|
|
|
fi
|
|
|
|
if [ ! -d /etc/etc.$conf/. ]; then
|
|
|
|
conf=${_DUMMY}
|
|
|
|
fi
|
|
|
|
done
|
2002-03-24 18:08:58 +03:00
|
|
|
|
2009-09-12 21:40:01 +04:00
|
|
|
print_rc_metadata "note:Using configuration \"${conf}\""
|
2009-09-11 22:17:43 +04:00
|
|
|
|
2002-03-25 06:22:10 +03:00
|
|
|
case $conf in
|
2002-03-24 18:08:58 +03:00
|
|
|
current|default)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
rm -f /etc/etc.current
|
2006-04-24 03:26:26 +04:00
|
|
|
ln -s etc.$conf /etc/etc.current
|
2013-01-01 03:21:27 +04:00
|
|
|
sync
|
2002-03-24 18:08:58 +03:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2000-03-10 14:53:23 +03:00
|
|
|
if [ -f /etc/rc.conf ] ; then
|
|
|
|
. /etc/rc.conf
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2009-09-05 20:24:03 +04:00
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|