xref: /plan9/sys/lib/dist/pc/inst/configether (revision 9a747e4fd48b9f4522c70c07e8f882a15030f964)
1#!/bin/rc
2
3# desc: configure your internet connection via an ethernet card
4
5switch($1) {
6case go
7	echo
8	echo 'Please choose a method for configuring your ethernet connection.'
9	echo
10	echo '	manual - specify IP address, network mask, gateway IP address'
11	echo '	dhcp - use DHCP to automatically configure'
12	echo
13
14	prompt 'Configuration method' manual dhcp
15	ethermethod=$rd
16	gwaddr=xxx
17	ipaddr=xxx
18	ipmask=xxx
19	switch($ethermethod){
20	case dhcp
21		echo
22		echo 'Some ISPs, notably @HOME, require a host name passed with DHCP'
23		echo 'requests.  An example for @HOME would be "cc1018221-a".  If your'
24		echo 'ISP supplied you such a name, enter it.'
25		echo
26		prompt -d none 'host name'; dhcphost=$rd
27		switch($dhcphost){
28		case none
29			dhcphost=();
30		case *
31			dhcphost=(-h $dhcphost)
32		}
33		export dhcphost
34	case manual
35		prompt 'ip address'; ipaddr=$rd
36		prompt 'network mask'; ipmask=$rd
37		prompt 'gateway address'; gwaddr=$rd
38		export ipaddr ipmask gwaddr
39	}
40
41	export ethermethod gwaddr ipaddr ipmask dhcphost
42	exec startether go
43
44case checkdone
45	if(! ~ $ethermethod manual dhcp) {
46		configether=notdone
47		export configether
48	}
49	if(~ $ethermethod manual && ~ 0 $#ipaddr $#ipmask $#gwaddr) {
50		configether=notdone
51		export configether
52	}
53}
54