summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Gianelloni <wolf31o2@gentoo.org>2005-05-16 19:26:39 +0000
committerChris Gianelloni <wolf31o2@gentoo.org>2005-05-16 19:26:39 +0000
commit63fa54b63c881712c15ea11cfb1f6a5d4f4b35f0 (patch)
treeb3ad234f8b7d195cff5b160d492b369c2d0fcaba /net-setup
parentAdded before net to depend. (diff)
downloadlivecd-tools-63fa54b63c881712c15ea11cfb1f6a5d4f4b35f0.tar.gz
livecd-tools-63fa54b63c881712c15ea11cfb1f6a5d4f4b35f0.tar.bz2
livecd-tools-63fa54b63c881712c15ea11cfb1f6a5d4f4b35f0.zip
Updated to have the same coding style, moved functions from each script into livecd-functions.sh, and cleaned up function names.
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/livecd-tools/trunk@51 7bf51bff-881f-0410-a643-fba68b97345e
Diffstat (limited to 'net-setup')
-rwxr-xr-xnet-setup102
1 files changed, 18 insertions, 84 deletions
diff --git a/net-setup b/net-setup
index 5c697ee..7a4c2a0 100755
--- a/net-setup
+++ b/net-setup
@@ -1,104 +1,38 @@
+#!/bin/bash
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/livecd-tools/net-setup,v 1.15 2005/04/13 13:19:58 wolf31o2 Exp $
-
-#!/bin/bash
+# $Header: /var/cvsroot/gentoo/src/livecd-tools/net-setup,v 1.16 2005/05/16 19:26:39 wolf31o2 Exp $
-if [ `whoami` != "root" ]; then
- echo "net-setup: must be root to continue"
+if [ -f /sbin/livecd-functions.sh ]
+then
+ source /sbin/livecd-functions.sh
+else
+ echo "ERROR: /sbin/livecd-functions.sh could not be loaded!"
exit 1
fi
-if [ -z ${1} ]; then
- echo "net-setup: please specify a network interface"
+livecd_check_root || exit 1
+
+if [ -z "${1}" ]
+then
+ echo "ERROR: please specify a network interface"
exit 1
+else
+ iface="${1}"
fi
-iface=${1}
-
[ ! -d /tmp/setup.opts ] && mkdir /tmp/setup.opts
cd /tmp/setup.opts
-config_wireless() {
- cd /tmp/setup.opts
- dialog --title "SSID" --inputbox "Please enter your SSID, or leave blank for selecting the nearest open network" 20 50 2> ${iface}.SSID
- SSID=`cat ${iface}.SSID`
- if [ -n "${SSID}" ]; then
- dialog --title "WEP (Part 1)" --menu "Does your network use encryption?" 20 60 7 1 "Yes" 2 "No" 2> ${iface}.WEP
- WEP=`cat ${iface}.WEP`
- case ${WEP} in
- 1)
- 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
- WEP_TYPE=`cat ${iface}.WEPTYPE`
- case ${WEP_TYPE} in
- 1)
- 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
- WEP_KEY=`cat ${iface}.WEPKEY`
- if [ -n "${WEP_KEY}" -a -x /usr/sbin/iwconfig ]; then
- /usr/sbin/iwconfig ${iface} essid \"${SSID}\"
- /usr/sbin/iwconfig ${iface} key "${WEP_KEY}"
- fi
- ;;
- 2)
- 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
- WEP_KEY=`cat ${iface}.WEPKEY`
- if [ -n "${WEP_KEY}" -a -x /usr/sbin/iwconfig ]; then
- /usr/sbin/iwconfig ${iface} essid \"${SSID}\"
- /usr/sbin/iwconfig ${iface} key "s:${WEP_KEY}"
- fi
- ;;
- esac
- ;;
- 2)
- /usr/sbin/iwconfig ${iface} essid \"${SSID}\"
- /usr/sbin/iwconfig ${iface} key off
- ;;
- esac
- fi
-}
-
-config_ip() {
- cd /tmp/setup.opts
- 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
- DHCP=`cat ${iface}.DHCP`
- case ${DHCP} in
- 1)
- /sbin/dhcpcd -t 10 -h $(hostname) ${iface} &
- ;;
- 2)
- dialog --title "IP address" --inputbox "Please enter an IP address for ${iface}:" 20 50 "192.168.1.1" 2> ${iface}.IP
- IP=`cat ${iface}.IP`
- BC_TEMP="`echo $IP|cut -d . -f 1`.`echo $IP|cut -d . -f 2`.`echo $IP|cut -d . -f 3`.255"
- dialog --title "Broadcast address" --inputbox "Please enter a Broadcast address for ${iface}:" 20 50 "${BC_TEMP}" 2> ${iface}.BC
- BROADCAST=`cat ${iface}.BC`
- dialog --title "Network mask" --inputbox "Please enter a Network Mask for ${iface}:" 20 50 "255.255.255.0" 2> ${iface}.NM
- NETMASK=`cat ${iface}.NM`
- dialog --title "Gateway" --inputbox "Please enter a Gateway for ${iface} (hit enter for none:)" 20 50 2> ${iface}.GW
- GATEWAY=`cat ${iface}.GW`
- dialog --title "DNS server" --inputbox "Please enter a name server to use (hit enter for none:)" 20 50 2> ${iface}.DNS
- DNS=`cat ${iface}.DNS`
- /sbin/ifconfig ${iface} ${IP} broadcast ${BROADCAST} netmask ${NETMASK}
- if [ -n "${GATEWAY}" ]; then
- /sbin/route add default gw ${GATEWAY} dev ${iface} netmask 0.0.0.0 metric 1
- fi
- if [ -n "${DNS}" ]; then
- echo "nameserver ${DNS}" > /etc/resolv.conf
- else
- : > /etc/resolv.conf
- fi
- ;;
- esac
-}
-
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
-WIRED_WIRELESS=`cat ${iface}.WIRED_WIRELESS`
+WIRED_WIRELESS="$(cat ${iface}.WIRED_WIRELESS)"
case ${WIRED_WIRELESS} in
1)
- config_wireless
- config_ip
+ livecd_config_wireless
+ livecd_config_ip
;;
2)
- config_ip
+ livecd_config_ip
;;
*)
exit 0