NetBSD/etc/rc.d/bootconf.sh

82 lines
1.3 KiB
Bash
Raw Normal View History

2000-03-10 14:53:23 +03:00
#!/bin/sh
#
# $NetBSD: bootconf.sh,v 1.5 2002/03/25 03:22:10 wiz Exp $
2000-03-10 14:53:23 +03:00
#
# PROVIDE: bootconf
# REQUIRE: mountcritlocal
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.}"
2000-03-10 14:53:23 +03:00
else
default=current
fi
if [ "$default" = "current" ]; then
def=`ls -ld /etc/etc.current 2>&1`
default="${def##*-> etc.}"
fi
2000-03-10 14:53:23 +03:00
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
2000-03-10 14:53:23 +03:00
done
echo
master=$$
_DUMMY=/etc/passwd
conf=${_DUMMY}
while [ ! -d /etc/etc.$conf/. ]; do
trap "conf=$default; echo; echo Using default of $conf" ALRM
2000-03-10 14:53:23 +03:00
echo -n "Which configuration [$default] ? "
(sleep 30 && kill -ALRM $master) >/dev/null 2>&1 &
read conf
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
case $conf in
current|default)
;;
*)
rm -f /etc/etc.current
ln -s /etc/etc.$conf /etc/etc.current
;;
esac
2000-03-10 14:53:23 +03:00
if [ -f /etc/rc.conf ] ; then
. /etc/rc.conf
fi
}
case "$1" in
*start)
bootconf_start
;;
esac