phunix/etc/rc.d/bootconf.sh
David van Moolenbroek 325ce30bcc Initial import of NetBSD rc system
IMPORTANT: this change has a docs/UPDATING entry!

This patch performs an initial import of the infrastructure and a
subset of the NetBSD set of rc startup and shutdown scripts.  The
"initial" refers to the fact that this is not yet a full switch to the
NetBSD rc system: the MINIX ramdisk rc script, which (typically) runs
as the first thing, is kept as is.  After mounting the root file
system, the ramdisk rc script will start the NetBSD rc infrastructure
by invoking /etc/rc, however.  The regular MINIX startup-and-shutdown
script has been moved from /etc/rc to /etc/rc.minix, and is now
invoked as part of the NetBSD rc infrastructure through a bridge rc
script /etc/rc.d/minixrc.  /etc/rc.minix invokes /usr/etc/rc as before.

Switching over the ramdisk to the NetBSD system and decomposing the
MINIX rc.minix script into smaller components are left to future work.
Also, the current pkgsrc etc/rc.d auto-start functionality is left as
is, even though it should be removed (see the etc/usr/rc comment).

Change-Id: Ia96cae7c426e94b85c67978dc1307dacc4b09fc5
2017-02-23 14:08:39 +00:00

88 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
#
# $NetBSD: bootconf.sh,v 1.15 2012/12/31 23:21:27 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
sync
;;
esac
if [ -f /etc/rc.conf ] ; then
. /etc/rc.conf
fi
}
load_rc_config $name
run_rc_command "$1"