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