3 # Configure.sh Generates interactively a config.h from config.in
5 # net-tools A collection of programs that form the base set of the
6 # NET-3 Networking Distribution for the LINUX operating
9 # Usage: Install.sh [--nobackup] [--test]
11 # Version: Install.sh 1.65 (1996-01-12)
13 # Authors: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
14 # Johannes Grosen, <grosen@argv.cs.ndsu.nodak.edu>
15 # Copyright 1988-1993 MicroWalt Corporation
18 # {1.65} Bernd eckes Eckenfels <net-tools@lina.inka.de>
19 # some layout cleanups, slattach/plipconfig removed.
20 # --test for testinstallations added.
22 # This program is free software; you can redistribute it
23 # and/or modify it under the terms of the GNU General
24 # Public License as published by the Free Software
25 # Foundation; either version 2 of the License, or (at
26 # your option) any later version.
29 # Make sure we're really running bash.
31 # I would really have preferred to write this script in a language with
32 # better string handling, but alas, bash is the only scripting language
33 # that I can be reasonable sure everybody has on their Linux machine.
37 MAKECONFIG=config.make
40 [ -z "$BASH" ] && { echo "Configure requires bash" 1>&2; exit 1; }
44 ######################################################
45 Notice: ifconfig and route are now installed into /bin
46 ######################################################
50 # Disable filename globbing once and for all.
51 # Enable function cacheing.
54 # set up reading of config file
55 if [ "$#" != "1" ] || [ ! -f "$1" ]; then
56 echo "usage: $0 configfile" 1>&2
63 # readln reads a line into $ans.
65 # readln prompt default
70 IFS='@' read ans || exit 1
71 [ -z "$ans" ] && ans=$2
74 # bool processes a boolean argument
80 # Slimier hack to get bash to rescan a line.
83 while [ "$ans" != "y" -a "$ans" != "n" ]
85 readln "$1 ($2) [$3] " "$3"
87 if [ "$ans" = "y" ]; then
88 echo "#define $2 1" >>${CONFIG}
89 echo "$2=1" >>${MAKECONFIG}
91 echo "#define $2 0" >>${CONFIG}
92 echo "# $2=0" >> ${MAKECONFIG}
94 raw_input_line="bool '$1' $2 $ans"
98 # int processes an integer argument
104 # Slimier hack to get bash to rescan a line.
107 while [ $[$ans+0] != "$ans" ];
109 readln "$1 ($2) [$3] " "$3"
111 echo "#define $2 ($ans)" >>${CONFIG}
112 raw_input_line="int '$1' $2 $ans"
117 # Make sure we start out with a clean slate.
126 while IFS='@' eval read raw_input_line ${config_fd_redir}
128 # Slimy hack to get bash to rescan a line.
129 read cmd rest <<-END_OF_COMMAND
133 if [ "$cmd" = "*" ]; then
134 if [ "$branch" = "t" ]; then
135 echo "$raw_input_line"
136 # echo "# $rest" >>$CONFIG
137 if [ "$prevcmd" != "*" ]; then
139 echo "/* $rest" >>${CONFIG}
141 echo " * $rest" >>${CONFIG}
146 [ "$prevcmd" = "*" ] && echo " */" >>${CONFIG}
149 =) [ "$branch" = "t" ] && echo "$rest" >>${CONFIG};;
150 :) [ "$branch" = "t" ] && echo "$raw_input_line" ;;
151 int) [ "$branch" = "t" ] && int "$rest" ;;
152 bool) [ "$branch" = "t" ] && bool "$rest" ;;
153 exec) [ "$branch" = "t" ] && ( sh -c "$rest" ) ;;
154 if) stack="$branch $stack"
155 if [ "$branch" = "t" ] && eval "$rest"; then
160 else) if [ "$branch" = "t" ]; then
163 read branch rest <<-END_OF_STACK
167 fi) [ -z "$stack" ] && echo "Error! Extra fi." 1>&2
168 read branch stack <<-END_OF_STACK
174 echo "$raw_input_line" >>config.new
176 [ "$prevcmd" = "*" ] && echo " */" >>${CONFIG}
178 [ -z "$stack" ] || echo "Error! Unterminated if." 1>&2
180 mv config.new config.status