* Add this nice filesystem testing tool that I've recently
[dragonfly.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: src/etc/rc.d/bootconf.sh,v 1.4 2002/10/12 10:31:31 schweikh Exp $
5 # $DragonFly: src/etc/rc.d/Attic/bootconf.sh,v 1.1 2003/07/24 06:35:37 dillon Exp $
6 #
7
8 # PROVIDE: bootconf
9 # REQUIRE: mountcritlocal
10
11 bootconf_start()
12 {
13                 # Refer to newbtconf(8) for more information
14                 #
15
16         if [ ! -e /etc/etc.current ]; then
17                 return 0
18         fi
19         if [ -L /etc/etc.default ]; then
20                 def=`ls -ld /etc/etc.default 2>&1`
21                 default="${def##*-> etc.}"
22         else
23                 default=current
24         fi
25         if [ "$default" = "current" ]; then
26                 def=`ls -ld /etc/etc.current 2>&1`
27                 default="${def##*-> etc.}"
28         fi
29
30         spc=""
31         for i in /etc/etc.*; do
32                 name="${i##/etc/etc.}"
33                 case $name in
34                 current|default|\*)
35                         continue
36                         ;;
37                 *)
38                         if [ "$name" = "$default" ]; then
39                                 echo -n "${spc}[${name}]"
40                         else
41                                 echo -n "${spc}${name}"
42                         fi
43                         spc=" "
44                         ;;
45                 esac
46         done
47         echo
48         master=$$
49         _DUMMY=/etc/passwd
50         conf=${_DUMMY}
51         while [ ! -d /etc/etc.$conf/. ]; do
52                 trap "conf=$default; echo; echo Using default of $conf" ALRM
53                 echo -n "Which configuration [$default] ? "
54                 (sleep 30 && kill -ALRM $master) >/dev/null 2>&1 &
55                 read conf
56                 trap : ALRM
57                 if [ -z $conf ]; then
58                         conf=$default
59                 fi
60                 if [ ! -d /etc/etc.$conf/. ]; then
61                         conf=${_DUMMY}
62                 fi
63         done
64
65         case  $conf in
66         current|default)
67                 ;;
68         *)
69                 rm -f /etc/etc.current
70                 ln -s /etc/etc.$conf /etc/etc.current
71                 ;;
72         esac
73
74         if [ -f /etc/rc.conf ]; then
75                 . /etc/rc.conf
76         fi
77 }
78
79 case "$1" in
80 *start)
81         bootconf_start
82         ;;
83 esac