]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - etc/rc.d/bootconf.sh
Finishing renaming of cached into nscd. etc/rc.d and usr.sbin/Makefile
[FreeBSD/FreeBSD.git] / etc / rc.d / bootconf.sh
1 #!/bin/sh
2 #
3 # $NetBSD: bootconf.sh,v 1.5 2002/03/25 03:22:10 wiz Exp $
4 # $FreeBSD$
5 #
6
7 # PROVIDE: bootconf
8 # REQUIRE: FILESYSTEMS
9
10 bootconf_start()
11 {
12                 # Refer to newbtconf(8) for more information
13                 #
14
15         if [ ! -e /etc/etc.current ]; then
16                 return 0
17         fi
18         if [ -L /etc/etc.default ]; then
19                 def=`ls -ld /etc/etc.default 2>&1`
20                 default="${def##*-> etc.}"
21         else
22                 default=current
23         fi
24         if [ "$default" = "current" ]; then
25                 def=`ls -ld /etc/etc.current 2>&1`
26                 default="${def##*-> etc.}"
27         fi
28
29         spc=""
30         for i in /etc/etc.*; do
31                 name="${i##/etc/etc.}"
32                 case $name in
33                 current|default|\*)
34                         continue
35                         ;;
36                 *)
37                         if [ "$name" = "$default" ]; then
38                                 echo -n "${spc}[${name}]"
39                         else
40                                 echo -n "${spc}${name}"
41                         fi
42                         spc=" "
43                         ;;
44                 esac
45         done
46         echo
47         master=$$
48         DUMMY=/etc/passwd
49         conf=${DUMMY}
50         while [ ! -d /etc/etc.$conf/. ]; do
51                 trap "conf=$default; echo; echo Using default of $conf" ALRM
52                 echo -n "Which configuration [$default] ? "
53                 (sleep 30 && kill -ALRM $master) >/dev/null 2>&1 &
54                 read conf
55                 trap : ALRM
56                 if [ -z $conf ]; then
57                         conf=$default
58                 fi
59                 if [ ! -d /etc/etc.$conf/. ]; then
60                         conf=${DUMMY}
61                 fi
62         done
63
64         case  $conf in
65         current|default)
66                 ;;
67         *)
68                 rm -f /etc/etc.current
69                 ln -s /etc/etc.$conf /etc/etc.current
70                 ;;
71         esac
72
73         if [ -f /etc/rc.conf ]; then
74                 . /etc/rc.conf
75         fi
76 }
77
78 case "$1" in
79 *start)
80         bootconf_start
81         ;;
82 esac