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

Contents of /trunk/net-setup

Parent Directory Parent Directory | Revision Log Revision Log


Revision 42 - (show annotations) (download)
Thu Feb 24 23:01:52 2005 UTC (9 years, 5 months ago) by wolf31o2
File size: 4002 byte(s)
I think this resolves a bug in net-setup where the wireless config isn't always used.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20