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

Diff of /trunk/net-setup

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 10 Revision 11
1# Copyright 1999-2004 Gentoo Technologies, Inc. 1# Copyright 1999-2004 Gentoo Technologies, Inc.
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo/src/livecd-tools/net-setup,v 1.4 2004/09/10 01:47:19 wolf31o2 Exp $ 3# $Header: /var/cvsroot/gentoo/src/livecd-tools/net-setup,v 1.5 2004/10/20 11:37:33 wolf31o2 Exp $
4 4
5#!/bin/bash 5#!/bin/bash
6 6
7if [ `whoami` != "root" ]; then 7if [ `whoami` != "root" ]; then
8 echo "net-setup: must be root to continue" 8 echo "net-setup: must be root to continue"
15fi 15fi
16 16
17[ ! -d /tmp/setup.opts ] && mkdir /tmp/setup.opts 17[ ! -d /tmp/setup.opts ] && mkdir /tmp/setup.opts
18cd /tmp/setup.opts 18cd /tmp/setup.opts
19 19
20WIRED_WIRELESS=`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"` 20dialog --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
21WIRED_WIRELESS=`cat ${1}.WIRED`
21case $WIRED_WIRELESS in 22case $WIRED_WIRELESS in
22 1) 23 1)
23 SSID=`dialog --title "SSID" --inputbox "Please enter your SSID, or leave blank for selecting the nearest open network" 20 50` 24 dialog --title "SSID" --inputbox "Please enter your SSID, or leave blank for selecting the nearest open network" 20 50 2> ${1}.SSID
25 SSID=`cat ${1}.SSID`
24 if [ -n "${SSID}" ]; then 26 if [ -n "${SSID}" ]; then
25 WEP_ENABLED=`dialog --title "WEP (Part 1)" --menu "Does your network use encryption?" 20 60 7 1 "Yes" 2 "No"` 27 dialog --title "WEP (Part 1)" --menu "Does your network use encryption?" 20 60 7 1 "Yes" 2 "No" 2> ${1}.WEP
28 WEP=`cat ${1}.WEP`
26 case $WEP_ENABLED in 29 case $WEP in
27 1) 30 1)
28 WEP_TYPE=`dialog --title "WEP (Part 2)" --menu "Are you entering your WEP key in HEX or ASCII?" 20 60 7 1 "HEX" 2 "ASCII"` 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> ${1}.WEPTYPE
32 WEP_TYPE=`cat ${1}.WEPTYPE`
29 case $WEP_TYPE in 33 case $WEP_TYPE in
30 1) 34 1)
31 WEP_KEY=`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` 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> ${1}.WEPKEY
36 WEP_KEY=`cat ${1}.WEPKEY`
32 if [ -n "${WEP_KEY}" -a -x /usr/sbin/iwconfig ]; then 37 if [ -n "${WEP_KEY}" -a -x /usr/sbin/iwconfig ]; then
33 /usr/sbin/iwconfig ${1} essid \""${SSID}"\" 38 /usr/sbin/iwconfig ${1} essid \"${SSID}\"
34 /usr/sbin/iwconfig ${1} key "${WEP_KEY}" 39 /usr/sbin/iwconfig ${1} key "${WEP_KEY}"
40 fi
35 ;; 41 ;;
36 2) 42 2)
37 WEP_KEY=`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` 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> ${1}.WEPKEY
44 WEP_KEY=`cat ${1}.WEPKEY`
38 if [ -n "${WEP_KEY}" -a -x /usr/sbin/iwconfig ]; then 45 if [ -n "${WEP_KEY}" -a -x /usr/sbin/iwconfig ]; then
39 /usr/sbin/iwconfig ${1} essid \""${SSID}"\" 46 /usr/sbin/iwconfig ${1} essid \""${SSID}"\"
40 /usr/sbin/iwconfig ${1} key s:"${WEP_KEY}" 47 /usr/sbin/iwconfig ${1} key s:"${WEP_KEY}"
48 fi
41 ;; 49 ;;
42 esac 50 esac
51 ;;
43 2) 52 2)
53 /usr/sbin/iwconfig ${1} essid \""${SSID}"\"
54 /usr/sbin/iwconfig ${1} key off
44 ;; 55 ;;
45 esac 56 esac
46 fi 57 fi
47 ;; 58 ;;
48 2) 59 2)
49 ;; 60 ;;
50esac 61esac
51 62
52DHCP=`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"` 63dialog --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
64DHCP=`cat ${1}.DHCP`
53case $DHCP in 65case $DHCP in
54 1) 66 1)
55 /sbin/dhcpcd -t 10 ${1} & 67 /sbin/dhcpcd -t 10 ${1} &
56 ;; 68 ;;
57 2) 69 2)
58 IP=`dialog --title "IP address" --inputbox "Please enter an IP address for ${1}:" 20 50 "192.168.1.1"` 70 dialog --title "IP address" --inputbox "Please enter an IP address for ${1}:" 20 50 "192.168.1.1" 2> ${1}.IP
71 IP=`cat ${1}.IP`
59 BC_TEMP="`echo $IP|cut -d . -f 1`.`echo $IP|cut -d . -f 2`.`echo $IP|cut -d . -f 3`.255" 72 BC_TEMP="`echo $IP|cut -d . -f 1`.`echo $IP|cut -d . -f 2`.`echo $IP|cut -d . -f 3`.255"
60 BROADCAST=`dialog --title "Broadcast address" --inputbox "Please enter a Broadcast address for ${1}:" 20 50 "${BC_TEMP}"` 73 dialog --title "Broadcast address" --inputbox "Please enter a Broadcast address for ${1}:" 20 50 "${BC_TEMP}" 2> ${1}.BC
74 BROADCAST=`cat ${1}.BC`
61 NETMASK=`dialog --title "Network mask" --inputbox "Please enter a Network Mask for ${1}:" 20 50 "255.255.255.0"` 75 dialog --title "Network mask" --inputbox "Please enter a Network Mask for ${1}:" 20 50 "255.255.255.0" 2> ${1}.NM
76 NETMASK=`cat ${1}.NM`
62 GATEWAY=`dialog --title "Gateway" --inputbox "Please enter a Gateway for ${1} (hit enter for none:)" 20 50` 77 dialog --title "Gateway" --inputbox "Please enter a Gateway for ${1} (hit enter for none:)" 20 50 2> ${1}.GW
78 GATEWAY=`cat ${1}.GW`
63 DNS=`dialog --title "DNS server" --inputbox "Please enter a name server to use (hit enter for none:)" 20 50` 79 dialog --title "DNS server" --inputbox "Please enter a name server to use (hit enter for none:)" 20 50 2> ${1}.DNS
80 DNS=`cat ${1}.DNS`
64 /sbin/ifconfig ${1} ${IP} broadcast ${BROADCAST} netmask ${NETMASK} 81 /sbin/ifconfig ${1} ${IP} broadcast ${BROADCAST} netmask ${NETMASK}
65 if [ -n "${GATEWAY}" ]; then 82 if [ -n "${GATEWAY}" ]; then
66 /sbin/route add default gw ${GATEWAY} dev $1 netmask 0.0.0.0 metric 1 83 /sbin/route add default gw ${GATEWAY} dev $1 netmask 0.0.0.0 metric 1
67 fi 84 fi
68 if [ -n "${DNS}" ]; then 85 if [ -n "${DNS}" ]; then

Legend:
Removed from v.10  
changed lines
  Added in v.11

  ViewVC Help
Powered by ViewVC 1.1.20