]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - release/netinst.sh
Some fields overflowed. Fix 'em up.
[FreeBSD/FreeBSD.git] / release / netinst.sh
1 #!/stand/sh
2 #
3 # netinst - configure the user's network.
4 #
5 # Written:  November 11th, 1994
6 # Copyright (C) 1994 by Jordan K. Hubbard
7 #
8 # Permission to copy or use this software for any purpose is granted
9 # provided that this message stay intact, and at this location (e.g. no
10 # putting your name on top after doing something trivial like reindenting
11 # it, just to make it look like you wrote it!).
12 #
13 # $Id: netinst.sh,v 1.6 1994/11/18 16:27:54 jkh Exp $
14
15 if [ "$_NETINST_SH_LOADED_" = "yes" ]; then
16         return 0
17 else
18         _NETINST_SH_LOADED_=yes
19 fi
20
21 # Set some useful variables.
22 IFCONFIG=ifconfig
23 ROUTE=route
24 ROUTE_FLAGS="add default"
25
26 # Grab the miscellaneous functions.
27 . /stand/miscfuncs.sh
28
29 network_setup_ether()
30 {
31         dialog $clear --title "Ethernet Interface Name" \
32         --menu "Please select the type of ethernet interface you have:\n\n" \
33          -1 -1 7 \
34         "ed0" "WD80x3, SMC, Novell NE[21]000 or 3C503 generic NIC at 0x280" \
35         "ed1" "Same as above, but at address 0x300 and IRQ 5" \
36         "ep0" "3COM 3C509 at address 0x300 and IRQ 10" \
37         "de0" "DEC PCI ethernet adapter (or compatible)" \
38         "ie0" "AT&T StarLan and EN100 family at 0x360 and IRQ 7" \
39         "is0" "Isolan 4141-0 or Isolink 4110 at 0x280 and IRQ 7" \
40         "ze0" "PCMCIA IBM or National card at 0x300 and IRQ 5" \
41           2> ${TMP}/menu.tmp.$$
42
43         retval=$?
44         interface=`cat ${TMP}/menu.tmp.$$`
45         rm -f ${TMP}/menu.tmp.$$
46         if ! handle_rval $retval; then return 1; fi
47 }
48
49 network_setup_slip()
50 {
51         clear=""
52         default_value=""
53         if ! network_dialog "What is the IP number for the remote host?"; then return 1; fi
54         remote_hostip=$answer
55         interface=sl0
56
57         default_value=$serial_interface
58         if ! network_dialog "What is the name of the serial interface?"; then return 1; fi
59         serial_interface=$answer
60
61         default_value=$serial_speed
62         if ! network_dialog "What speed is the serial interface?"; then return 1; fi
63         serial_speed=$answer
64         clear="--clear"
65
66         if dialog $clear --title "Dial" --yesno "Do you need to dial the phone or otherwise talk to the modem?" -1 -1; then
67                 mkdir -p /var/log
68                 touch -f /var/log/aculog        > /dev/null 2>&1
69                 chmod 666 /var/log/aculog       > /dev/null 2>&1
70                 confirm "You may now dialog with your modem and set up the slip connection.\nBe sure to disable DTR sensitivity (usually with AT&D0) or the modem may\nhang up when you exit 'cu'.  Use ~. to exit cu and continue."
71                 dialog --clear
72                 # Grottyness to deal with a weird crunch bug.
73                 if [ ! -f /stand/cu ]; then ln /stand/tip /stand/cu; fi
74                 /stand/cu -l $serial_interface -s $serial_speed
75                 dialog --clear
76         fi
77 }
78
79 network_setup_plip()
80 {
81         default_value=""
82         if ! network_dialog "What is the IP number for the remote host?"; then return 1; fi
83         remote_hostip=$answer
84         interface=lp0
85 }
86
87 network_setup()
88 {
89         done=0
90         while [ "$interface" = "" ]; do
91                 clear="--clear"
92                 dialog $clear --title "Set up network interface" \
93                 --menu "Please select the type of network connection you have:\n\n" \
94                 -1 -1 3 \
95                 "ether" "A supported ethernet card" \
96                 "SLIP" "A point-to-point SLIP (Serial Line IP) connection" \
97                 "PLIP" "A Parallel-Line IP setup (with standard laplink cable)" \
98                 2> ${TMP}/menu.tmp.$$
99
100                 retval=$?
101                 choice=`cat ${TMP}/menu.tmp.$$`
102                 rm -f ${TMP}/menu.tmp.$$
103                 if ! handle_rval $retval; then return 1; fi
104                 case $choice in
105                 ether)
106                         if ! network_setup_ether; then continue; fi
107                 ;;
108
109                 SLIP)
110                         if ! network_setup_slip; then continue; fi
111                 ;;
112
113                 PLIP)
114                         if ! network_setup_plip; then continue; fi
115                 ;;
116                 esac    
117                 if [ "$interface" = "" ]; then  continue; fi
118
119                 clear=""
120                 default_value=""
121                 if ! network_dialog "What is the fully qualified name of this host?"; then clear="--clear"; return 1; fi
122                 hostname=$answer
123                 echo $hostname > /etc/myname
124                 hostname $hostname
125
126                 default_value=`echo $hostname | sed -e 's/[^.]*\.//'`
127                 if network_dialog "What is the domain name of this host (Internet, not YP/NIS)?"; then
128                         domain=$answer
129                 fi
130
131                 default_value=""
132                 if ! network_dialog "What is the IP address of this host?"; then clear="--clear"; return 1; fi
133                 ipaddr=$answer
134
135                 echo "$ipaddr    $hostname `echo $hostname | sed -e 's/\.$domain//'`" >> /etc/hosts
136
137                 default_value="$netmask"
138                 if network_dialog "Please specify the netmask"; then
139                         if [ "$answer" != "" ]; then
140                                 netmask=$answer
141                         fi
142                 fi
143
144                 default_value=""
145                 if network_dialog "Any extra flags to ifconfig?" ; then
146                         ifconfig_flags=$answer
147                 fi
148                 echo "Progress <$IFCONFIG $interface $ipaddr $remote_hostip netmask $netmask $ifconfig_flags>" >/dev/ttyv1
149                 if ! $IFCONFIG $interface $ipaddr $remote_hostip netmask $netmask $ifconfig_flags > /dev/ttyv1 2>&1 ; then
150                         error "Unable to configure interface $interface"
151                         ipaddr=""; interface=""
152                         continue
153                 fi
154                 if [ "$interface" = "sl0" ]; then
155                         slattach -a -s $serial_speed $serial_interface
156                 fi
157                 echo "$ipaddr $remote_hostip netmask $netmask $ifconfig_flags" > /etc/hostname.$interface
158                 default_value=""
159                 if network_dialog "If you have a default gateway, enter its IP address"; then
160                         if [ "$answer" != "" ]; then
161                                 gateway=$answer
162                                 echo "Progress <$ROUTE $ROUTE_FLAGS $gateway>" > /dev/ttyv1 2>&1
163                                 $ROUTE $ROUTE_FLAGS $gateway > /dev/ttyv1 2>&1
164                                 echo $gateway > /etc/defaultrouter
165                         fi
166                 fi
167
168                 default_value=""
169                 if network_dialog "If you have a name server, enter its IP address"; then
170                         if [ "$answer" != "" ]; then
171                                 nameserver=$answer
172                                 echo "domain $domain" > /etc/resolv.conf
173                                 echo "nameserver $nameserver" >> /etc/resolv.conf
174                         fi
175                 fi
176         done
177         return 0
178 }