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