forked from NetBSD/src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootconf.sh
executable file
·87 lines (77 loc) · 1.49 KB
/
bootconf.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/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"