3 # netconf 0.1 - Configure network
8 LOCALRC
=/usr
/etc
/rc.
local
9 INETCONF
=/etc
/inet.conf
12 HOSTNAME
=/etc
/hostname.
file
21 cd="no" # running from cd?
41 # Provide some sane defaults
42 hostname_default
=`uname -n`
43 test -z "$hostname_default" && hostname_default
="Minix"
45 netmask_default
="255.255.255.0"
53 netconf [-q] [-p <prefix>] [-e <num>] [-a]
54 netconf [-H <name> -i <ip> -n <mask> -g <gw> -d <prim dns> [-s <sec dns>]]
57 -q Limit generated output
58 -p Path prefix for configuration files (e.g., during install -p mnt is used as files are mounted on /mnt).
60 -a Use DHCP (-H, -i, -n, -g, -d, and -s flags are discarded)
67 -h Shows this help file
68 -c Shows a list of ethernet cards supported
70 By default netconf starts in Interactive mode. By providing parameters on the
71 command line, some questions can be omitted.
84 lspci |
grep > /dev
/null
"^$1" && card_avail
=1
87 if [ $card_avail -gt 0 ]
90 eth_default
=$card_number
94 printf "%2d. %s %s\n" "$card_number" "$card_mark" "$card_name"
99 card
0 "No Ethernet card (no networking)"
100 card
1 "Intel Pro/100" "8086:103D" "8086:1064" "8086:1229" "8086:2449"
101 card
2 "3Com 501 or 3Com 509 based card"
102 card
3 "Realtek 8139 based card (also emulated by KVM)" \
103 "10EC:8139" "02AC:1012" "1065:8139" "1113:1211" "1186:1300" \
104 "1186:1340" "11DB:1234" "1259:A117" "1259:A11E" "126C:1211" \
105 "13D1:AB06" "1432:9130" "14EA:AB06" "14EA:AB07" "1500:1360" \
106 "1743:8139" "4033:1360"
107 card
4 "Realtek 8169 based card" \
108 "10EC:8129" "10EC:8167" "10EC:8169" "1186:4300" "1259:C107" \
109 "1385:8169" "16EC:0116" "1737:1032"
110 card
5 "Realtek 8029 based card (also emulated by Qemu)" "10EC:8029"
111 card
6 "NE2000, 3com 503 or WD based card (also emulated by Bochs)"
112 card
7 "AMD LANCE (also emulated by VMWare and VirtualBox)" "1022:2000"
113 card
8 "Intel PRO/1000 Gigabit" "8086:100E" "8086:107C" "8086:10CD"
114 card
9 "Attansic/Atheros L2 FastEthernet" "1969:2048"
115 card
10 "DEC Tulip 21140A in VirtualPC" "1011:0009"
116 card
11 "Different Ethernet card (no networking)"
121 echo -e "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b ! $1"
128 # Ask user about networking
129 echo "MINIX 3 currently supports the following Ethernet cards. PCI cards detected"
130 echo "by MINIX are marked with *. Please choose: "
135 while [ "$step1" != ok
]; do
136 echo -n "Ethernet card? [$eth_default] "; read eth
137 test -z $eth && eth
=$eth_default
140 test -n "$driver" && step1
="ok"
149 2) driver
=dpeth
; driverargs
="#dpeth_arg='DPETH0=port:irq:memory'";
150 test "$v" = 1 && echo ""
151 test "$v" = 1 && echo "Note: After installing, edit $LOCALRC to the right configuration."
153 4) driver
=rtl8169
; ;;
154 3) driver
=rtl8139
; ;;
155 5) driver
=dp8390
; driverargs
="dp8390_arg='DPETH0=pci'"; ;;
156 6) driver
=dp8390
; driverargs
="dp8390_arg='DPETH0=240:9'";
157 test "$v" = 1 && echo ""
158 test "$v" = 1 && echo "Note: After installing, edit $LOCALRC to the right configuration."
159 test "$v" = 1 && echo " chose option 4, the defaults for emulation by Bochs have been set."
161 7) driver
="lance"; ;;
162 8) driver
="e1000"; ;;
164 10) driver
="dec21140A"; ;;
165 11) driver
="psip0"; ;;
166 *) warn
"choose a number"
173 echo "Configure network using DHCP or manually?"
175 echo "1. Automatically using DHCP"
179 while [ "$step2" != ok
]
181 echo -n "Configure method? [1] "; read config
182 test -z $config && config
=1
185 1) step2
="ok"; dhcp
="yes" ; ;;
186 2) step2
="ok"; manual
="do"; ;;
187 *) warn
"choose a number"
191 # Use manual parameters?
192 if [ -n "$manual" ]; then
193 # Query user for settings
195 if [ -z $hostname_prev ]; then
196 hostname_prev
=$hostname_default
198 echo -n "Hostname [$hostname_prev]: "
200 if [ ! -z $hostname ]; then
201 hostname_prev
=$hostname
203 hostname
=$hostname_prev
207 if [ -z $ip_prev ]; then
210 echo -n "IP address [$ip_prev]: "
212 if [ ! -z $ip ]; then
219 if [ -z $netmask_prev ]; then
220 netmask_prev
=$netmask_default
222 echo -n "Netmask [$netmask_prev]: "
224 if [ ! -z $netmask ]; then
225 netmask_prev
=$netmask
227 netmask
=$netmask_prev
230 # Gateway (no gateway is fine for local networking)
235 echo -n "Primary DNS Server [$dns1_prev]: "
237 test -z "$dns1" && test -n "$dns1_prev" && dns1
=$dns1_prev
238 if [ ! -z "$dns1" ]; then
241 echo -n "Secondary DNS Server [$dns2_prev]: "
243 if [ ! -z $dns2 ]; then
247 # If no primary DNS, then also no secondary DNS
254 while getopts ":qe:p:aH:i:n:g:d:s:hc" arg
; do
258 test "$ethernet" -ge 0 -a "$ethernet" -le 7 2>/dev
/null || usage
261 p
) prefix
=$OPTARG; ;;
263 H
) hostname
=$OPTARG; manual_opts
=`expr $manual_opts '+' 1`;;
264 i
) ip
=$OPTARG; manual_opts
=`expr $manual_opts '+' 1`;;
265 n
) netmask
=$OPTARG; manual_opts
=`expr $manual_opts '+' 1`;;
266 g
) gateway
=$OPTARG; manual_opts
=`expr $manual_opts '+' 1`;;
270 c
) echo -e "The following cards are supported by Minix:\n";
273 \?) echo "Unknown option -$OPTARG"; usage
;;
274 :) echo "Missing required argument for -$OPTARG"; usage
;;
279 # Verify parameter count
280 if [ "$dhcp" != "yes" ] ; then
281 if [ $manual_opts -gt 0 ] ; then
282 test $manual_opts -eq 4 -a -n "$dns1" || usage
287 if [ -n "$prefix" ] ; then
288 LOCALRC
=$prefix$LOCALRC
289 INETCONF
=$prefix$INETCONF
292 HOSTNAME
=$prefix$HOSTNAME
293 if [ ! -f $INETCONF ]; then
294 echo -e "It seems the supplied prefix (\`$prefix') is invalid."
299 if [ "$USER" != root
] ; then
300 test "$v" = 1 && echo "Please run netconf as root."
304 # Are we running from CD?
305 if [ -f "$USRKBFILE" ] ; then
306 cd="yes" # We are running from CD
309 # Do we know what ethernet card to use?
310 test -z "$ethernet" && do_step1
312 # If no parameters are supplied and we're not using DHCP, query for settings
313 test $manual_opts -eq 0 -a "$dhcp" = "no" && do_step2
316 # Do not make backups if we're running from CD
317 test "$cd" != "yes" && test -f $INETCONF && mv $INETCONF "$INETCONF~" &&
318 test "$v" = 1 && echo "Backed up $INETCONF to $INETCONF~"
319 test "$cd" != "yes" && test -f $LOCALRC && mv $LOCALRC "$LOCALRC~" &&
320 test "$v" = 1 && echo "Backed up $LOCALRC to $LOCALRC~"
322 echo "eth0 $driver 0 { default; } ;" > $INETCONF
323 echo "$driverargs" > $LOCALRC
327 # Backup config file if it exists and we're not running from CD
328 test "$cd" != "yes" && test -f $RCNET && mv $RCNET "$RCNET~" &&
329 test "$v" = 1 && echo "Backed up $RCNET to $RCNET~"
330 test "$cd" != "yes" && test -f $HOSTS && mv $HOSTS "$HOSTS~" &&
331 test "$v" = 1 && echo "Backed up $HOSTS to $HOSTS~"
333 # Store manual config
334 echo "ifconfig -I /dev/ip0 -n $netmask -h $ip" > $RCNET
335 test ! -z $gateway && echo "add_route -g $gateway" >> $RCNET
336 echo "daemonize nonamed -L" >> $RCNET
337 test ! -z $dns1 && echo -e "$ip\t%nameserver\t#$hostname" > $HOSTS
338 test ! -z $dns1 && echo -e "$dns1\t%nameserver\t#DNS 1" >> $HOSTS
339 test ! -z $dns2 && echo -e "$dns2\t%nameserver\t#DNS 2" >> $HOSTS
340 echo -e "\n$ip\t$hostname" >> $HOSTS
341 echo $hostname > $HOSTNAME
343 test "$cd" != "yes" && test -f "$RCNET" && mv "$RCNET" "$RCNET~" &&
344 test "$v" = 1 && echo "Moved $RCNET to $RCNET~ to use default settings"
345 test "$cd" != "yes" && test -f $HOSTS && mv $HOSTS "$HOSTS~" &&
346 test "$v" = 1 && echo "Backed up $HOSTS to $HOSTS~"
347 test -f "$HOSTS~" && grep -v "%nameserver" "$HOSTS~" > $HOSTS
350 test "$cd" != "yes" && test "$v" = 1 && echo "
351 You might have to reboot for the changes to take effect."