/[livecd-tools]/trunk/net-setup
Gentoo

Contents of /trunk/net-setup

Parent Directory Parent Directory | Revision Log Revision Log


Revision 47 - (show annotations) (download)
Wed Apr 13 13:19:58 2005 UTC (9 years, 6 months ago) by wolf31o2
File size: 4174 byte(s)
Fixing broken dhcpcd hostnames.

1 # Copyright 1999-2005 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo/src/livecd-tools/net-setup,v 1.15 2005/04/13 13:19:58 wolf31o2 Exp $
4
5 #!/bin/bash
6
7 if [ `whoami` != "root" ]; then
8 echo "net-setup: must be root to continue"
9 exit 1
10 fi
11
12 if [ -z ${1} ]; then
13 echo "net-setup: please specify a network interface"
14 exit 1
15 fi
16
17 iface=${1}
18
19 [ ! -d /tmp/setup.opts ] && mkdir /tmp/setup.opts
20 cd /tmp/setup.opts
21
22 config_wireless() {
23 cd /tmp/setup.opts
24 dialog --title "SSID" --inputbox "Please enter your SSID, or leave blank for selecting the nearest open network" 20 50 2> ${iface}.SSID
25 SSID=`cat ${iface}.SSID`
26 if [ -n "${SSID}" ]; then
27 dialog --title "WEP (Part 1)" --menu "Does your network use encryption?" 20 60 7 1 "Yes" 2 "No" 2> ${iface}.WEP
28 WEP=`cat ${iface}.WEP`
29 case ${WEP} in
30 1)
31 dialog --title "WEP (Part 2)" --menu "Are you entering your WEP key in HEX or ASCII?" 20 60 7 1 "HEX" 2 "ASCII" 2> ${iface}.WEPTYPE
32 WEP_TYPE=`cat ${iface}.WEPTYPE`
33 case ${WEP_TYPE} in
34 1)
35 dialog --title "WEP (Part 3)" --inputbox "Please enter your WEP key in the form of XXXX-XXXX-XX for 64-bit or XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XX for 128-bit" 20 50 2> ${iface}.WEPKEY
36 WEP_KEY=`cat ${iface}.WEPKEY`
37 if [ -n "${WEP_KEY}" -a -x /usr/sbin/iwconfig ]; then
38 /usr/sbin/iwconfig ${iface} essid \"${SSID}\"
39 /usr/sbin/iwconfig ${iface} key "${WEP_KEY}"
40 fi
41 ;;
42 2)
43 dialog --title "WEP (Part 3)" --inputbox "Please enter your WEP key in ASCII form. This should be 5 or 13 characters for either 64-bit or 128-bit encryption, repectively" 20 50 2> ${iface}.WEPKEY
44 WEP_KEY=`cat ${iface}.WEPKEY`
45 if [ -n "${WEP_KEY}" -a -x /usr/sbin/iwconfig ]; then
46 /usr/sbin/iwconfig ${iface} essid \"${SSID}\"
47 /usr/sbin/iwconfig ${iface} key "s:${WEP_KEY}"
48 fi
49 ;;
50 esac
51 ;;
52 2)
53 /usr/sbin/iwconfig ${iface} essid \"${SSID}\"
54 /usr/sbin/iwconfig ${iface} key off
55 ;;
56 esac
57 fi
58 }
59
60 config_ip() {
61 cd /tmp/setup.opts
62 dialog --title "TCP/IP setup" --menu "You can use DHCP to automatically configure a network interface or you can specify an IP and related settings manually. Choose one option:" 20 60 7 1 "Use DHCP to auto-detect my network settings" 2 "Specify an IP address manually" 2> ${iface}.DHCP
63 DHCP=`cat ${iface}.DHCP`
64 case ${DHCP} in
65 1)
66 /sbin/dhcpcd -t 10 -h $(hostname) ${iface} &
67 ;;
68 2)
69 dialog --title "IP address" --inputbox "Please enter an IP address for ${iface}:" 20 50 "192.168.1.1" 2> ${iface}.IP
70 IP=`cat ${iface}.IP`
71 BC_TEMP="`echo $IP|cut -d . -f 1`.`echo $IP|cut -d . -f 2`.`echo $IP|cut -d . -f 3`.255"
72 dialog --title "Broadcast address" --inputbox "Please enter a Broadcast address for ${iface}:" 20 50 "${BC_TEMP}" 2> ${iface}.BC
73 BROADCAST=`cat ${iface}.BC`
74 dialog --title "Network mask" --inputbox "Please enter a Network Mask for ${iface}:" 20 50 "255.255.255.0" 2> ${iface}.NM
75 NETMASK=`cat ${iface}.NM`
76 dialog --title "Gateway" --inputbox "Please enter a Gateway for ${iface} (hit enter for none:)" 20 50 2> ${iface}.GW
77 GATEWAY=`cat ${iface}.GW`
78 dialog --title "DNS server" --inputbox "Please enter a name server to use (hit enter for none:)" 20 50 2> ${iface}.DNS
79 DNS=`cat ${iface}.DNS`
80 /sbin/ifconfig ${iface} ${IP} broadcast ${BROADCAST} netmask ${NETMASK}
81 if [ -n "${GATEWAY}" ]; then
82 /sbin/route add default gw ${GATEWAY} dev ${iface} netmask 0.0.0.0 metric 1
83 fi
84 if [ -n "${DNS}" ]; then
85 echo "nameserver ${DNS}" > /etc/resolv.conf
86 else
87 : > /etc/resolv.conf
88 fi
89 ;;
90 esac
91 }
92
93 dialog --title "Network setup" --menu "This script is designed to setup both wired and wireless network settings. All questions below apply to the ${iface} interface only. Choose one option:" 20 60 7 1 "My network is wireless" 2 "My network is wired" 2> ${iface}.WIRED_WIRELESS
94 WIRED_WIRELESS=`cat ${iface}.WIRED_WIRELESS`
95 case ${WIRED_WIRELESS} in
96 1)
97 config_wireless
98 config_ip
99 ;;
100 2)
101 config_ip
102 ;;
103 *)
104 exit 0
105 ;;
106 esac
107
108
109 echo "Type \"ifconfig\" to make sure the interface was configured correctly."
110
111 # vim: ts=4

Properties

Name Value
svn:eol-style native
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20