r600 - ppc/trunk/scripts x86/branches/utf8/scripts x86/branches/utf8-newmake/scripts x86_64/trunk/scripts

justin at linuxfromscratch.org justin at linuxfromscratch.org
Sat Aug 27 22:06:18 PDT 2005


Author: justin
Date: 2005-08-27 23:06:17 -0600 (Sat, 27 Aug 2005)
New Revision: 600

Modified:
   ppc/trunk/scripts/net-setup
   x86/branches/utf8-newmake/scripts/net-setup
   x86/branches/utf8/scripts/net-setup
   x86_64/trunk/scripts/net-setup
Log:
Sync net-setup script from trunk to ppc, utf8, utf8-newmake and x86_64 branches/arches.

Modified: ppc/trunk/scripts/net-setup
===================================================================
--- ppc/trunk/scripts/net-setup	2005-08-27 16:14:47 UTC (rev 599)
+++ ppc/trunk/scripts/net-setup	2005-08-28 05:06:17 UTC (rev 600)
@@ -1,185 +1,436 @@
 #!/bin/bash
 #
-# Script for interactively choosing a network service
-# and starting eth0 on the LFS 6.0 bootcd.
+# Script for interactively choosing a network interface, 
+# service and configuring this service.  First implemented
+# in the x86-6.0-1 CD.
 #
 # Written by Jeremy Huntwork 09.17.2004
+# Additional features by Justin Knierim with the help
+#   of Alexander Patrakov 08.08.05
 #
 
+# Locations of network configs, ifup and ifdown
 DIR=/etc/sysconfig/network-devices
-ETH0CFG=$DIR/ifconfig.eth0
 IFUP=$DIR/ifup
 IFDOWN=$DIR/ifdown
-LINKTEST=`ip link show eth0 2> /dev/null`
-GREETING="Let's configure your network device!"
 
-# Function to set nameservers in /etc/resolv.conf
-# Allows user to enter any number of nameservers,
-# exits when user types "done"
+# Set variables after network device is selected
+set_devvars(){
+	ETHXCFG=$DIR/ifconfig.$DEV
+	LINKTEST=`/sbin/ip link show $DEV 2> /dev/null`
+}
 
+# Form to enter nameservers for /etc/resolv.conf
 set_dns(){
+	DLG_COMMAND="dialog --title \"DNS Servers - /etc/resolv.conf\" --no-cancel \
+        --form \"Please enter the DNS IP addresses below:\" 0 0 3 \
+	\"Server 1:\" 1 1 \"$F_DNS1\" 1 25 15 0 \
+	\"Server 2:\" 2 1 \"$F_DNS2\" 2 25 15 0 \
+	\"Server 3:\" 3 1 \"$F_DNS3\" 3 25 15 0"
+	SELECTION=`eval $DLG_COMMAND 3>&2 2>&1 1>&3`
 
-	echo "Enter a DNS server: "
-	echo "(Enter server addresses, one per line in order of preference, and type \"done\" when finished."
-	read DNS
-	counter=0
-	while [ $DNS != "done" ]
-	do
-		# Check that user enters four numbers separated by '.'
-		if [ -z "$DNS" -o -n "${DNS##?*.?*.?*.?*}" ] ; then
-			echo "$DNS is not a valid nameserver address."
-		else
-			# If this is the first entry, overwrite any existing
-			# /etc/resolv.conf, else append.
-			if [ $counter -eq 0 ] ; then
-				echo "nameserver $DNS" > /etc/resolv.conf
-			else 
-				echo "nameserver $DNS" >> /etc/resolv.conf
-			fi
-		fi
-		read DNS
-		counter=`expr $counter + 1`
-	done
-}		
+	STATUS=$?
+	if [ "$STATUS" -ne 0 ] ; then
+		exit 1
+	fi
 
-set_static_ip(){
-	echo "Enter your IP address:"
-	read IP
-	if [ -z "$IP" -o -n "${IP##?*.?*.?*.?*}" ] ; then
-		echo ""
-		echo "$IP is not a valid IP address."
-		set_static_ip;
+	unset F_DNS1 F_DNS2 F_DNS3
+	eval "`echo "$SELECTION" | sed -e '1s,^,F_DNS1=",' -e '2s,^,F_DNS2=",' \
+	      -e '3s,^,F_DNS3=",' | sed -e 's,$,",'`"
+
+	# Validate DNS IP addresses
+	DNS_OK=1
+	if [ -n "$F_DNS1" -a "${F_DNS1##?*.?*.?*.?*}" ] || \
+	   [ -n "$F_DNS2" -a "${F_DNS2##?*.?*.?*.?*}" ] || \
+	   [ -n "$F_DNS3" -a "${F_DNS3##?*.?*.?*.?*}" ] ; then
+                DNS_OK=0
+		DNS_ERRMSG="One of the entered IP addresses is not valid."
+        fi
+
+	if [ "$DNS_OK" -eq 1 ] ; then
+		rm -f /etc/resolv.conf
+		[ -n "$F_DNS1" ] && echo "nameserver $F_DNS1" >> /etc/resolv.conf
+		[ -n "$F_DNS2" ] && echo "nameserver $F_DNS2" >> /etc/resolv.conf
+		[ -n "$F_DNS3" ] && echo "nameserver $F_DNS3" >> /etc/resolv.conf
+
+		unset F_DNS1 F_DNS2 F_DNS3 SELECTION DLG_COMMAND STATUS
+		unset DNS_OK DNS_ERRMSG
 	else
-		echo "IP=$IP" >> $ETH0CFG
+		DLG_COMMAND="dialog --title \"DNS IP Validation Error\" \
+		--msgbox \"$DNS_ERRMSG\" 6 60"
+		eval $DLG_COMMAND
+		set_dns;	
 	fi
-}
+}		
 
-set_static_gateway(){
-	echo "Enter your default gateway:"
-	read GTWY
-	if [ -z "$GTWY" -o -n "${GTWY##?*.?*.?*.?*}" ] ; then
-		echo ""
-		echo "$GTWY is not a valid default gateway."
-		set_static_gateway;
-	else
-		echo "GATEWAY=$GTWY" >> $ETH0CFG
+# Setup IP address, prefix, gateway and broadcast
+set_static_cfg(){
+	# Default values (only apply on first run-through, meaning SIP_OK doesn't exist)
+	if [ -z "$SIP_OK" ] ; then
+		F_PREFIX=24
 	fi
-}
 
-set_static_prefix(){
-	echo "Enter your prefix: "
-	echo "(This determines your subnet mask. For example, a prefix of 24 would give you a subnet mask of 255.255.255.0)"
-	read PRFX
-	# First verify that user has entered a prefix, and not just pressed 'Enter'
-	if [ $PRFX ] ; then
-		# Check that prefix is a value between 8 & 30
-		if [ "$PRFX" -lt 8 -o "$PRFX" -gt 30 ] ; then
-			echo ""
-			echo "$PRFX is not a valid prefix."
-			set_static_prefix;
-		else
-			echo "PREFIX=$PRFX" >> $ETH0CFG
-		fi
+        DLG_COMMAND="dialog --title \"Static IP Configuration\" --no-cancel \
+        --form \"Please enter the network connection details:\" 0 0 4 \
+        \"IP Address:\" 1 1 \"$F_IPADDR\" 1 25 15 0 \
+        \"Prefix:\" 2 1 \"$F_PREFIX\" 2 25 2 0 \
+        \"Broadcast:\" 3 1 \"$F_BROADCAST\" 3 25 15 0 \
+	\"Gateway:\" 4 1 \"$F_GATEWAY\" 4 25 15 0"
+        SELECTION=`eval $DLG_COMMAND 3>&2 2>&1 1>&3`
+
+        STATUS=$?
+        if [ "$STATUS" -ne 0 ] ; then
+                exit 1
+        fi
+
+	unset F_IPADDR F_PREFIX F_BROADCAST F_GATEWAY
+        eval "`echo "$SELECTION" | sed -e '1s,^,F_IPADDR=",' -e '2s,^,F_PREFIX=",' \
+              -e '3s,^,F_BROADCAST=",' -e '4s,^,F_GATEWAY=",' | sed -e 's,$,",'`"
+
+        # Validate entries (Must give IP, prefix and broadcast.  Gateway optional.)
+        SIP_OK=1
+        if [ -n "$F_IPADDR" -a "${F_IPADDR##?*.?*.?*.?*}" ] || \
+           [ -n "$F_BROADCAST" -a "${F_BROADCAST##?*.?*.?*.?*}" ] || \
+           [ -n "$F_GATEWAY" -a "${F_GATEWAY##?*.?*.?*.?*}" ] ; then
+                SIP_OK=0
+		SIP_ERRMSG="One of the entered IP addresses or prefix is not valid."
+	fi
+	if [ "$F_PREFIX" -lt 8 -o "$F_PREFIX" -gt 30 ] ; then
+		SIP_OK=0
+		SIP_ERRMSG="The prefix is not valid.  Please enter a value from 8 to 30."
+	fi
+	if [ -z "$F_IPADDR" -o -z "$F_BROADCAST" -o -z "$F_PREFIX" ] ; then
+		SIP_OK=0
+		SIP_ERRMSG="Please enter an IP address, broadcast and prefix."		
+        fi
+
+        if [ "$SIP_OK" -eq 1 ] ; then
+                echo "IP=$F_IPADDR" >> $ETHXCFG
+		echo "PREFIX=$F_PREFIX" >> $ETHXCFG
+		echo "BROADCAST=$F_BROADCAST" >> $ETHXCFG
+		[ -n "$F_GATEWAY" ] && echo "GATEWAY=$F_GATEWAY" >> $ETHXCFG
+
+                unset F_IPADDR F_PREFIX F_BROADCAST F_GATEWAY DLG_COMMAND STATUS
+                unset SELECTION SIP_OK SIP_ERRMSG
 	else
-		echo "Prefix cannot be empty."
-		echo ""
-		set_static_prefix;
+                DLG_COMMAND="dialog --title \"Static IP Validation Error\" \
+                --msgbox \"$SIP_ERRMSG\" 6 60"
+                eval $DLG_COMMAND
+                set_static_cfg;
 	fi
 }
 
-set_static_broadcast(){
-	echo "Enter your broadcast address: "
-	read BRDCST
-	if [ -z "$BRDCST" -o -n "${BRDCST##?*.?*.?*.?*}" ] ; then
-		echo ""
-		echo "$BRDCST is not a valid broadcast address."
-		set_static_broadcast;
-	else
-		echo "BROADCAST=$BRDCST" >> $ETH0CFG
+# GPRS Device options
+set_gprs_cfg(){
+        # Default values (only apply on first run-through, meaning GPRS_OK doesn't exist)
+        if [ -z "$GPRS_OK" ] ; then
+                F_DEVICE=/dev/ttyS1
+                F_SPEED=115200
+		F_SETTING=1
+        fi
+
+        DLG_COMMAND="dialog --title \"GPRS Device Configuration\" --no-cancel \
+        --form \"Please enter the GPRS device details below. The default value for the setting number is 1.\" 0 0 4 \
+        \"APN:\" 1 1 \"$F_APN\" 1 25 30 0 \
+        \"Device:\" 2 1 \"$F_DEVICE\" 2 25 20 0 \
+        \"Speed:\" 3 1 \"$F_SPEED\" 3 25 10 0 \
+	\"Setting Number:\" 4 1 \"$F_SETTING\" 4 25 4 0"
+        SELECTION=`eval $DLG_COMMAND 3>&2 2>&1 1>&3`
+
+        STATUS=$?
+        if [ "$STATUS" -ne 0 ] ; then
+                exit 1
+        fi
+
+	unset F_APN F_DEVICE F_SPEED F_SETTING
+        eval "`echo "$SELECTION" | sed -e '1s,^,F_APN=",' -e '2s,^,F_DEVICE=",' \
+              -e '3s,^,F_SPEED=",' -e '4s,^,F_SETTING=",' | sed -e 's,$,",'`"
+
+        # Validate entries (All values are required.)
+        GPRS_OK=1
+	if [ -z "$F_APN" -o -z "$F_DEVICE" -o -z "$F_SPEED" -o -z "$F_SETTING" ] ; then
+		GPRS_OK=0
+		GPRS_ERRMSG="All fields are required to setup your GPRS device."
 	fi
+
+        if [ "$GPRS_OK" -eq 1 ] ; then
+		# Make a backup and restore before changes, so the sed's work correctly.
+		[ -f /etc/ppp/peers/gprs.orig ] || cp /etc/ppp/peers/gprs /etc/ppp/peers/gprs.orig
+		[ -f /etc/ppp/gprs.chat.orig ] || cp /etc/ppp/gprs.chat /etc/ppp/gprs.chat.orig
+		cp /etc/ppp/peers/gprs.orig /etc/ppp/peers/gprs
+		cp /etc/ppp/gprs.chat.orig /etc/ppp/gprs.chat
+
+		# Alter /etc/ppp/peers/gprs file.
+		sed -i -e "s at inet.example.com@$F_APN at g" -e "s@/dev/ttyS1@$F_DEVICE at g" \
+		       -e "s at 115200@$F_SPEED at g" /etc/ppp/peers/gprs
+
+		# Alter /etc/ppp/gprs.chat (advanced setting)
+		sed -i -e "s at CGDCONT=1 at CGDCONT=$F_SETTING at g" \
+                       -e "s@\*\*\*1@\*\*\*$F_SETTING at g" /etc/ppp/gprs.chat
+
+                unset F_APN F_DEVICE F_SPEED F_SETTING DLG_COMMAND STATUS
+                unset SELECTION GPRS_OK GPRS_ERRMSG
+        else
+                DLG_COMMAND="dialog --title \"GPRS Validation Error\" \
+                --msgbox \"$GPRS_ERRMSG\" 6 60"
+                eval $DLG_COMMAND
+                set_gprs_cfg;
+        fi
 }
 
-# Main function. Presents user with a choice of
-# static or dhcp and attempts to bring up eth0
+# Modem Device options
+set_modem_cfg(){
+        # Default values (only apply on first run-through, meaning MODEM_OK doesn't exist)
+        if [ -z "$MODEM_OK" ] ; then
+                F_DEVICE=/dev/ttyS1
+                F_SPEED=115200
+        fi
 
-choose_service(){
+        DLG_COMMAND="dialog --title \"Modem Configuration\" --no-cancel \
+        --form \"Please enter the modem details below:\" 0 0 5 \
+        \"Telephone Number:\" 1 1 \"$F_PHONE\" 1 25 20 0 \
+        \"User:\" 2 1 \"$F_USERNAME\" 2 25 30 0 \
+        \"Password:\" 3 1 \"$F_PASSWORD\" 3 25 30 0 \
+        \"Device:\" 4 1 \"$F_DEVICE\" 4 25 20 0 \
+        \"Speed:\" 5 1 \"$F_SPEED\" 5 25 10 0"
+        SELECTION=`eval $DLG_COMMAND 3>&2 2>&1 1>&3`
 
+        STATUS=$?
+        if [ "$STATUS" -ne 0 ] ; then
+                exit 1
+        fi
+
+        unset F_PHONE F_USERNAME F_PASSWORD F_DEVICE F_SPEED
+        eval "`echo "$SELECTION" | sed -e '1s,^,F_PHONE=",' -e '2s,^,F_USERNAME=",' \
+              -e '3s,^,F_PASSWORD=",' -e '4s,^,F_DEVICE=",' -e '5s,^,F_SPEED=",' | sed -e 's,$,",'`"
+
+        # Validate entries (All values except password are required.)
+        MODEM_OK=1
+        if [ -z "$F_PHONE" -o -z "$F_USERNAME" -o -z "$F_DEVICE" -o -z "$F_SPEED" ] ; then
+                MODEM_OK=0
+                MODEM_ERRMSG="The telephone number, username, device and speed are required fields."
+        fi
+
+        if [ "$MODEM_OK" -eq 1 ] ; then
+                # Make a backup and restore before changes, so the sed's work correctly.
+                [ -f /etc/ppp/peers/dialup.orig ] || cp /etc/ppp/peers/dialup /etc/ppp/peers/dialup.orig
+                [ -f /etc/ppp/pap-secrets.orig ] || cp /etc/ppp/pap-secrets /etc/ppp/pap-secrets.orig
+                cp /etc/ppp/peers/dialup.orig /etc/ppp/peers/dialup
+                cp /etc/ppp/pap-secrets.orig /etc/ppp/pap-secrets
+
+                # Alter /etc/ppp/peers/dialup file.
+                sed -i -e "s at TTTTTTT@$F_PHONE at g" -e "s@/dev/ttyS1@$F_DEVICE at g" \
+                       -e "s at 115200@$F_SPEED at g" -e "s@\"jdoe\"@\"$F_USERNAME\"@g" \
+		       /etc/ppp/peers/dialup
+
+                # Alter /etc/ppp/pap-secrets
+		echo $F_USERNAME dialup $F_PASSWORD >> /etc/ppp/pap-secrets
+
+                unset F_PHONE F_USERNAME F_PASSWORD F_DEVICE F_SPEED DLG_COMMAND STATUS
+                unset SELECTION MODEM_OK MODEM_ERRMSG
+        else
+                DLG_COMMAND="dialog --title \"Modem Validation Error\" \
+                --msgbox \"$MODEM_ERRMSG\" 6 60"
+                eval $DLG_COMMAND
+                set_modem_cfg;
+        fi
+}
+
+# Main Menu for Network Devices
+net_service_menu(){
 	# Remove previous config, so ifup won't get confused.
-	rm -f $ETH0CFG
+	rm -f $ETHXCFG
 
-	echo ""
-	echo "What type of service should eth0 use?"
-	echo "(static, dhcp or pppoe)"
-	read SERVICE
+	unset ARGS
+	ARGS="$ARGS dhcp \"Acquire IP address through dhcp.\""
+	ARGS="$ARGS static \"Enter a static IP Address.\""
+	ARGS="$ARGS pppoe \"Setup an ADSL connection.\""
 
-case "$SERVICE" in
+	DLG_COMMAND="dialog --title \"Select network service\" --default-item dhcp \
+		--menu \"Select the network service to use for the $DEV interface:\" \
+		0 0 0 $ARGS"
+	SERVICE=`eval $DLG_COMMAND 3>&2 2>&1 1>&3`
 
-	dhcp) 
-		echo "SERVICE=dhcpcd" > $ETH0CFG
-		echo "DHCP_START=\"\"" >> $ETH0CFG
-		echo "DHCP_STOP=\"-k\"" >> $ETH0CFG
+	unset DLG_COMMAND ARGS
 
-		# Start the service
-		$IFUP eth0
+	case "$SERVICE" in
 
-		# Test if dhcp worked and did not set DNS.
-		# If so run set_dns function.
-		if echo `ip link show eth0 2> /dev/null` | grep -q UP ; then			
-			if [ ! -f /etc/resolv.conf ] ; then
-				echo "DHCP did not configure DNS."
-				set_dns;
+		dhcp) 
+			echo "SERVICE=dhcpcd" > $ETHXCFG
+			echo "DHCP_START=\"\"" >> $ETHXCFG
+			echo "DHCP_STOP=\"-k\"" >> $ETHXCFG
+
+			# Start the service
+			$IFUP $DEV
+
+			# Test if dhcp worked and did not set DNS.
+			# If so run set_dns function.
+			if echo "$LINKTEST" | grep -q UP ; then			
+				if [ ! -f /etc/resolv.conf ] ; then
+					set_dns;
+				fi
+				ip addr show $DEV
 			fi
-			ip addr show eth0
-		fi
-		;;
+			;;
+	
+		static)
+			echo "SERVICE=ipv4-static" > $ETHXCFG
+			set_static_cfg;
+			set_dns;
+			$IFUP $DEV
+			;;
+	
+		pppoe)
+			adsl-setup
+			;;
+		*)
+			exit 0
+			;;
+	esac
+}
 
-	static)
-		echo "SERVICE=ipv4-static" > $ETH0CFG
-		set_static_ip;
-		set_static_gateway;
-		set_static_prefix;
-		set_static_broadcast;
-		set_dns;
-		# Start the service
-		$IFUP eth0
-		;;
+# Main Menu for ppp modem devices
+ppp_modem_menu(){
+        unset ARGS
+        ARGS="$ARGS configure \"Configure your modem.\""
+        ARGS="$ARGS dial \"Dial modem and exit.\""
+        ARGS="$ARGS hangup \"Hang up modem and exit.\""
 
-	pppoe)
-		adsl-setup
-		;;
+        DLG_COMMAND="dialog --title \"Modem - Actions\" --default-item configure \
+                --menu \"Select the action to perform for your modem:\" \
+                0 0 0 $ARGS"
+        SERVICE=`eval $DLG_COMMAND 3>&2 2>&1 1>&3`
 
-	*)
-		# Error message in case user entered something unusable, like "waldo"
-		echo ""
-		echo "--------------------------"
-		echo " Invalid option: $SERVICE"
-		echo " Please try again."
-		echo "--------------------------"
-		choose_service;
-		;;
-esac
+        unset DLG_COMMAND ARGS
+
+        case "$SERVICE" in
+
+                configure)
+                        set_modem_cfg;
+                        ;;
+
+                dial)
+                        [ -e /dev/ppp ] || mknod /dev/ppp c 108 0
+                        modprobe ppp-generic ; pppd call dialup
+                        exit 0
+                        ;;
+
+                hangup)
+                        killall pppd
+                        exit 0
+                        ;;
+                *)
+                        exit 0
+                        ;;
+        esac
+
+        ppp_modem_menu;
 }
 
-# Script starts here. Tests first for link on eth0
+# Main Menu for ppp gprs devices
+ppp_gprs_menu(){
+        unset ARGS
+        ARGS="$ARGS configure \"Configure your GPRS device.\""
+        ARGS="$ARGS dial \"Dial GPRS device and exit.\""
+        ARGS="$ARGS hangup \"Hang up GPRS device and exit.\""
 
-if [ -n "$LINKTEST" ] ; then
+        DLG_COMMAND="dialog --title \"GPRS Device - Actions\" --default-item configure \
+                --menu \"Select the action to perform for your GPRS device:\" \
+                0 0 0 $ARGS"
+        SERVICE=`eval $DLG_COMMAND 3>&2 2>&1 1>&3`
 
-	# If link is not up, start main function choose_service.
+        unset DLG_COMMAND ARGS
 
-	if ! echo "$LINKTEST" | grep -q UP ; then
-		echo ""
-		echo $GREETING
-		choose_service;
+        case "$SERVICE" in
+
+                configure)
+			set_gprs_cfg;
+                        ;;
+
+                dial)
+			[ -e /dev/ppp ] || mknod /dev/ppp c 108 0 
+			modprobe ppp-generic ; pppd call gprs
+			exit 0
+                        ;;
+
+                hangup)
+			killall pppd
+			exit 0
+                        ;;
+                *)
+                        exit 0
+                        ;;
+        esac
+
+	ppp_gprs_menu;
+}
+
+# Script starts here. Check for root user.
+if [ `whoami` != "root" ] ; then
+	echo "You must be root to use $0"
+	exit 1;
+fi
+
+# Get list of devices and prompt user to select one
+if [ ! -d /sys/class/net ] ; then
+	echo "No devices found or sysfs not mounted!"
+	exit 1;
+fi
+
+for EDEV in /sys/class/net/eth* /sys/class/net/wlan* ; do
+	EDEV=`basename $EDEV`
+	if echo $EDEV | grep -q "*" ; then continue ; fi
+	if echo `/sbin/ip link show $EDEV 2> /dev/null` | grep -q UP ; then
+		EDEVSTATUS="UP"
 	else
+		EDEVSTATUS="DOWN"
+	fi
+	DEVLIST="$DEVLIST `basename $EDEV` \"$EDEVSTATUS\""
+done
+DEVLIST="$DEVLIST ppp-modem \"Configure a dial-up Modem\" ppp-gprs \"Configure a GPRS Modem\""
 
-	# If link is up, user likely has run this script already.
-	# Take down eth0 so we can set it up cleanly.
+DLG_COMMAND="dialog --title \"Network Configuration\" --default-item eth0 \
+       	--timeout 30 --menu \"Select the network device to configure:\" \
+	0 0 0 $DEVLIST"
+DEV=`eval $DLG_COMMAND 3>&2 2>&1 1>&3`
+unset EDEV EDEVSTATUS DEVLIST DLG_COMMAND
 
-		$IFDOWN eth0
-		echo ""
-		echo $GREETING
-		choose_service;
+# Continue if device was selected, exit if otherwise.
+if [ -n "$DEV" ] ; then
+	if [ "$DEV" == "ppp-modem" ] ; then
+		ppp_modem_menu;
+		exit 0
 	fi
-else
-	echo "Device eth0 is not present on this system!"
+	if [ "$DEV" == "ppp-gprs" ] ; then
+		ppp_gprs_menu;
+		exit 0
+	fi
+        # If the menu times out, activate eth0 with dhcpcd and exit.
+        if [ "$DEV" == "timeout" ] ; then
+                DEV="eth0"
+                set_devvars;
+                rm -f $ETHXCFG
+                echo "SERVICE=dhcpcd" > $ETHXCFG
+                echo "DHCP_START=\"\"" >> $ETHXCFG
+                echo "DHCP_STOP=\"-k\"" >> $ETHXCFG
+                $IFUP $DEV
+                exit 0
+        fi
+	
+	# If not ppp-modem or ppp-gprs, then network device to configure
+	set_devvars;
+
+	if [ -n "$LINKTEST" ] ; then
+		# Link is up. Bring it down and start service menu.
+		if echo "$LINKTEST" | grep -q UP ; then
+			$IFDOWN $DEV
+		fi
+
+		net_service_menu;
+	else
+		DLG_COMMAND="dialog --title \"Device Not Found\" \
+                --msgbox \"Device $DEV is not present on this system.\" 6 60"
+                eval $DLG_COMMAND
+		exit 1
+	fi
 fi

Modified: x86/branches/utf8/scripts/net-setup
===================================================================
--- x86/branches/utf8/scripts/net-setup	2005-08-27 16:14:47 UTC (rev 599)
+++ x86/branches/utf8/scripts/net-setup	2005-08-28 05:06:17 UTC (rev 600)
@@ -1,191 +1,436 @@
 #!/bin/bash
 #
-# Script for interactively choosing a network service
-# and starting eth0 on the LFS LiveCD. First implemented
+# Script for interactively choosing a network interface, 
+# service and configuring this service.  First implemented
 # in the x86-6.0-1 CD.
 #
 # Written by Jeremy Huntwork 09.17.2004
+# Additional features by Justin Knierim with the help
+#   of Alexander Patrakov 08.08.05
 #
 
+# Locations of network configs, ifup and ifdown
 DIR=/etc/sysconfig/network-devices
-ETH0CFG=$DIR/ifconfig.eth0
 IFUP=$DIR/ifup
 IFDOWN=$DIR/ifdown
-LINKTEST=`ip link show eth0 2> /dev/null`
-GREETING="Let's configure your network device!"
 
-# Function to set nameservers in /etc/resolv.conf
-# Allows user to enter any number of nameservers,
-# exits when user types "done"
+# Set variables after network device is selected
+set_devvars(){
+	ETHXCFG=$DIR/ifconfig.$DEV
+	LINKTEST=`/sbin/ip link show $DEV 2> /dev/null`
+}
 
+# Form to enter nameservers for /etc/resolv.conf
 set_dns(){
+	DLG_COMMAND="dialog --title \"DNS Servers - /etc/resolv.conf\" --no-cancel \
+        --form \"Please enter the DNS IP addresses below:\" 0 0 3 \
+	\"Server 1:\" 1 1 \"$F_DNS1\" 1 25 15 0 \
+	\"Server 2:\" 2 1 \"$F_DNS2\" 2 25 15 0 \
+	\"Server 3:\" 3 1 \"$F_DNS3\" 3 25 15 0"
+	SELECTION=`eval $DLG_COMMAND 3>&2 2>&1 1>&3`
 
-	echo "Enter a DNS server: "
-	echo "(Enter server addresses, one per line in order of preference, and type \"done\" when finished."
-	read DNS
-	counter=0
-	while [ $DNS != "done" ]
-	do
-		# Check that user enters four numbers separated by '.'
-		if [ -z "$DNS" -o -n "${DNS##?*.?*.?*.?*}" ] ; then
-			echo "$DNS is not a valid nameserver address."
-		else
-			# If this is the first entry, overwrite any existing
-			# /etc/resolv.conf, else append.
-			if [ $counter -eq 0 ] ; then
-				echo "nameserver $DNS" > /etc/resolv.conf
-			else 
-				echo "nameserver $DNS" >> /etc/resolv.conf
-			fi
-		fi
-		read DNS
-		counter=`expr $counter + 1`
-	done
-}		
+	STATUS=$?
+	if [ "$STATUS" -ne 0 ] ; then
+		exit 1
+	fi
 
-set_static_ip(){
-	echo "Enter your IP address:"
-	read IP
-	if [ -z "$IP" -o -n "${IP##?*.?*.?*.?*}" ] ; then
-		echo ""
-		echo "$IP is not a valid IP address."
-		set_static_ip;
+	unset F_DNS1 F_DNS2 F_DNS3
+	eval "`echo "$SELECTION" | sed -e '1s,^,F_DNS1=",' -e '2s,^,F_DNS2=",' \
+	      -e '3s,^,F_DNS3=",' | sed -e 's,$,",'`"
+
+	# Validate DNS IP addresses
+	DNS_OK=1
+	if [ -n "$F_DNS1" -a "${F_DNS1##?*.?*.?*.?*}" ] || \
+	   [ -n "$F_DNS2" -a "${F_DNS2##?*.?*.?*.?*}" ] || \
+	   [ -n "$F_DNS3" -a "${F_DNS3##?*.?*.?*.?*}" ] ; then
+                DNS_OK=0
+		DNS_ERRMSG="One of the entered IP addresses is not valid."
+        fi
+
+	if [ "$DNS_OK" -eq 1 ] ; then
+		rm -f /etc/resolv.conf
+		[ -n "$F_DNS1" ] && echo "nameserver $F_DNS1" >> /etc/resolv.conf
+		[ -n "$F_DNS2" ] && echo "nameserver $F_DNS2" >> /etc/resolv.conf
+		[ -n "$F_DNS3" ] && echo "nameserver $F_DNS3" >> /etc/resolv.conf
+
+		unset F_DNS1 F_DNS2 F_DNS3 SELECTION DLG_COMMAND STATUS
+		unset DNS_OK DNS_ERRMSG
 	else
-		echo "IP=$IP" >> $ETH0CFG
+		DLG_COMMAND="dialog --title \"DNS IP Validation Error\" \
+		--msgbox \"$DNS_ERRMSG\" 6 60"
+		eval $DLG_COMMAND
+		set_dns;	
 	fi
-}
+}		
 
-set_static_gateway(){
-	echo "Enter your default gateway:"
-	read GTWY
-	if [ -z "$GTWY" -o -n "${GTWY##?*.?*.?*.?*}" ] ; then
-		echo ""
-		echo "$GTWY is not a valid default gateway."
-		set_static_gateway;
-	else
-		echo "GATEWAY=$GTWY" >> $ETH0CFG
+# Setup IP address, prefix, gateway and broadcast
+set_static_cfg(){
+	# Default values (only apply on first run-through, meaning SIP_OK doesn't exist)
+	if [ -z "$SIP_OK" ] ; then
+		F_PREFIX=24
 	fi
-}
 
-set_static_prefix(){
-	echo "Enter your prefix: "
-	echo "(This determines your subnet mask. For example, a prefix of 24 would give you a subnet mask of 255.255.255.0)"
-	read PRFX
-	# First verify that user has entered a prefix, and not just pressed 'Enter'
-	if [ $PRFX ] ; then
-		# Check that prefix is a value between 8 & 30
-		if [ "$PRFX" -lt 8 -o "$PRFX" -gt 30 ] ; then
-			echo ""
-			echo "$PRFX is not a valid prefix."
-			set_static_prefix;
-		else
-			echo "PREFIX=$PRFX" >> $ETH0CFG
-		fi
+        DLG_COMMAND="dialog --title \"Static IP Configuration\" --no-cancel \
+        --form \"Please enter the network connection details:\" 0 0 4 \
+        \"IP Address:\" 1 1 \"$F_IPADDR\" 1 25 15 0 \
+        \"Prefix:\" 2 1 \"$F_PREFIX\" 2 25 2 0 \
+        \"Broadcast:\" 3 1 \"$F_BROADCAST\" 3 25 15 0 \
+	\"Gateway:\" 4 1 \"$F_GATEWAY\" 4 25 15 0"
+        SELECTION=`eval $DLG_COMMAND 3>&2 2>&1 1>&3`
+
+        STATUS=$?
+        if [ "$STATUS" -ne 0 ] ; then
+                exit 1
+        fi
+
+	unset F_IPADDR F_PREFIX F_BROADCAST F_GATEWAY
+        eval "`echo "$SELECTION" | sed -e '1s,^,F_IPADDR=",' -e '2s,^,F_PREFIX=",' \
+              -e '3s,^,F_BROADCAST=",' -e '4s,^,F_GATEWAY=",' | sed -e 's,$,",'`"
+
+        # Validate entries (Must give IP, prefix and broadcast.  Gateway optional.)
+        SIP_OK=1
+        if [ -n "$F_IPADDR" -a "${F_IPADDR##?*.?*.?*.?*}" ] || \
+           [ -n "$F_BROADCAST" -a "${F_BROADCAST##?*.?*.?*.?*}" ] || \
+           [ -n "$F_GATEWAY" -a "${F_GATEWAY##?*.?*.?*.?*}" ] ; then
+                SIP_OK=0
+		SIP_ERRMSG="One of the entered IP addresses or prefix is not valid."
+	fi
+	if [ "$F_PREFIX" -lt 8 -o "$F_PREFIX" -gt 30 ] ; then
+		SIP_OK=0
+		SIP_ERRMSG="The prefix is not valid.  Please enter a value from 8 to 30."
+	fi
+	if [ -z "$F_IPADDR" -o -z "$F_BROADCAST" -o -z "$F_PREFIX" ] ; then
+		SIP_OK=0
+		SIP_ERRMSG="Please enter an IP address, broadcast and prefix."		
+        fi
+
+        if [ "$SIP_OK" -eq 1 ] ; then
+                echo "IP=$F_IPADDR" >> $ETHXCFG
+		echo "PREFIX=$F_PREFIX" >> $ETHXCFG
+		echo "BROADCAST=$F_BROADCAST" >> $ETHXCFG
+		[ -n "$F_GATEWAY" ] && echo "GATEWAY=$F_GATEWAY" >> $ETHXCFG
+
+                unset F_IPADDR F_PREFIX F_BROADCAST F_GATEWAY DLG_COMMAND STATUS
+                unset SELECTION SIP_OK SIP_ERRMSG
 	else
-		echo "Prefix cannot be empty."
-		echo ""
-		set_static_prefix;
+                DLG_COMMAND="dialog --title \"Static IP Validation Error\" \
+                --msgbox \"$SIP_ERRMSG\" 6 60"
+                eval $DLG_COMMAND
+                set_static_cfg;
 	fi
 }
 
-set_static_broadcast(){
-	echo "Enter your broadcast address: "
-	read BRDCST
-	if [ -z "$BRDCST" -o -n "${BRDCST##?*.?*.?*.?*}" ] ; then
-		echo ""
-		echo "$BRDCST is not a valid broadcast address."
-		set_static_broadcast;
-	else
-		echo "BROADCAST=$BRDCST" >> $ETH0CFG
+# GPRS Device options
+set_gprs_cfg(){
+        # Default values (only apply on first run-through, meaning GPRS_OK doesn't exist)
+        if [ -z "$GPRS_OK" ] ; then
+                F_DEVICE=/dev/ttyS1
+                F_SPEED=115200
+		F_SETTING=1
+        fi
+
+        DLG_COMMAND="dialog --title \"GPRS Device Configuration\" --no-cancel \
+        --form \"Please enter the GPRS device details below. The default value for the setting number is 1.\" 0 0 4 \
+        \"APN:\" 1 1 \"$F_APN\" 1 25 30 0 \
+        \"Device:\" 2 1 \"$F_DEVICE\" 2 25 20 0 \
+        \"Speed:\" 3 1 \"$F_SPEED\" 3 25 10 0 \
+	\"Setting Number:\" 4 1 \"$F_SETTING\" 4 25 4 0"
+        SELECTION=`eval $DLG_COMMAND 3>&2 2>&1 1>&3`
+
+        STATUS=$?
+        if [ "$STATUS" -ne 0 ] ; then
+                exit 1
+        fi
+
+	unset F_APN F_DEVICE F_SPEED F_SETTING
+        eval "`echo "$SELECTION" | sed -e '1s,^,F_APN=",' -e '2s,^,F_DEVICE=",' \
+              -e '3s,^,F_SPEED=",' -e '4s,^,F_SETTING=",' | sed -e 's,$,",'`"
+
+        # Validate entries (All values are required.)
+        GPRS_OK=1
+	if [ -z "$F_APN" -o -z "$F_DEVICE" -o -z "$F_SPEED" -o -z "$F_SETTING" ] ; then
+		GPRS_OK=0
+		GPRS_ERRMSG="All fields are required to setup your GPRS device."
 	fi
+
+        if [ "$GPRS_OK" -eq 1 ] ; then
+		# Make a backup and restore before changes, so the sed's work correctly.
+		[ -f /etc/ppp/peers/gprs.orig ] || cp /etc/ppp/peers/gprs /etc/ppp/peers/gprs.orig
+		[ -f /etc/ppp/gprs.chat.orig ] || cp /etc/ppp/gprs.chat /etc/ppp/gprs.chat.orig
+		cp /etc/ppp/peers/gprs.orig /etc/ppp/peers/gprs
+		cp /etc/ppp/gprs.chat.orig /etc/ppp/gprs.chat
+
+		# Alter /etc/ppp/peers/gprs file.
+		sed -i -e "s at inet.example.com@$F_APN at g" -e "s@/dev/ttyS1@$F_DEVICE at g" \
+		       -e "s at 115200@$F_SPEED at g" /etc/ppp/peers/gprs
+
+		# Alter /etc/ppp/gprs.chat (advanced setting)
+		sed -i -e "s at CGDCONT=1 at CGDCONT=$F_SETTING at g" \
+                       -e "s@\*\*\*1@\*\*\*$F_SETTING at g" /etc/ppp/gprs.chat
+
+                unset F_APN F_DEVICE F_SPEED F_SETTING DLG_COMMAND STATUS
+                unset SELECTION GPRS_OK GPRS_ERRMSG
+        else
+                DLG_COMMAND="dialog --title \"GPRS Validation Error\" \
+                --msgbox \"$GPRS_ERRMSG\" 6 60"
+                eval $DLG_COMMAND
+                set_gprs_cfg;
+        fi
 }
 
-# Main function. Presents user with a choice of
-# static or dhcp and attempts to bring up eth0
+# Modem Device options
+set_modem_cfg(){
+        # Default values (only apply on first run-through, meaning MODEM_OK doesn't exist)
+        if [ -z "$MODEM_OK" ] ; then
+                F_DEVICE=/dev/ttyS1
+                F_SPEED=115200
+        fi
 
-choose_service(){
+        DLG_COMMAND="dialog --title \"Modem Configuration\" --no-cancel \
+        --form \"Please enter the modem details below:\" 0 0 5 \
+        \"Telephone Number:\" 1 1 \"$F_PHONE\" 1 25 20 0 \
+        \"User:\" 2 1 \"$F_USERNAME\" 2 25 30 0 \
+        \"Password:\" 3 1 \"$F_PASSWORD\" 3 25 30 0 \
+        \"Device:\" 4 1 \"$F_DEVICE\" 4 25 20 0 \
+        \"Speed:\" 5 1 \"$F_SPEED\" 5 25 10 0"
+        SELECTION=`eval $DLG_COMMAND 3>&2 2>&1 1>&3`
 
+        STATUS=$?
+        if [ "$STATUS" -ne 0 ] ; then
+                exit 1
+        fi
+
+        unset F_PHONE F_USERNAME F_PASSWORD F_DEVICE F_SPEED
+        eval "`echo "$SELECTION" | sed -e '1s,^,F_PHONE=",' -e '2s,^,F_USERNAME=",' \
+              -e '3s,^,F_PASSWORD=",' -e '4s,^,F_DEVICE=",' -e '5s,^,F_SPEED=",' | sed -e 's,$,",'`"
+
+        # Validate entries (All values except password are required.)
+        MODEM_OK=1
+        if [ -z "$F_PHONE" -o -z "$F_USERNAME" -o -z "$F_DEVICE" -o -z "$F_SPEED" ] ; then
+                MODEM_OK=0
+                MODEM_ERRMSG="The telephone number, username, device and speed are required fields."
+        fi
+
+        if [ "$MODEM_OK" -eq 1 ] ; then
+                # Make a backup and restore before changes, so the sed's work correctly.
+                [ -f /etc/ppp/peers/dialup.orig ] || cp /etc/ppp/peers/dialup /etc/ppp/peers/dialup.orig
+                [ -f /etc/ppp/pap-secrets.orig ] || cp /etc/ppp/pap-secrets /etc/ppp/pap-secrets.orig
+                cp /etc/ppp/peers/dialup.orig /etc/ppp/peers/dialup
+                cp /etc/ppp/pap-secrets.orig /etc/ppp/pap-secrets
+
+                # Alter /etc/ppp/peers/dialup file.
+                sed -i -e "s at TTTTTTT@$F_PHONE at g" -e "s@/dev/ttyS1@$F_DEVICE at g" \
+                       -e "s at 115200@$F_SPEED at g" -e "s@\"jdoe\"@\"$F_USERNAME\"@g" \
+		       /etc/ppp/peers/dialup
+
+                # Alter /etc/ppp/pap-secrets
+		echo $F_USERNAME dialup $F_PASSWORD >> /etc/ppp/pap-secrets
+
+                unset F_PHONE F_USERNAME F_PASSWORD F_DEVICE F_SPEED DLG_COMMAND STATUS
+                unset SELECTION MODEM_OK MODEM_ERRMSG
+        else
+                DLG_COMMAND="dialog --title \"Modem Validation Error\" \
+                --msgbox \"$MODEM_ERRMSG\" 6 60"
+                eval $DLG_COMMAND
+                set_modem_cfg;
+        fi
+}
+
+# Main Menu for Network Devices
+net_service_menu(){
 	# Remove previous config, so ifup won't get confused.
-	rm -f $ETH0CFG
+	rm -f $ETHXCFG
 
-	echo ""
-	echo "What type of service should eth0 use?"
-	echo "(static, dhcp or pppoe)"
-	read SERVICE
+	unset ARGS
+	ARGS="$ARGS dhcp \"Acquire IP address through dhcp.\""
+	ARGS="$ARGS static \"Enter a static IP Address.\""
+	ARGS="$ARGS pppoe \"Setup an ADSL connection.\""
 
-case "$SERVICE" in
+	DLG_COMMAND="dialog --title \"Select network service\" --default-item dhcp \
+		--menu \"Select the network service to use for the $DEV interface:\" \
+		0 0 0 $ARGS"
+	SERVICE=`eval $DLG_COMMAND 3>&2 2>&1 1>&3`
 
-	dhcp) 
-		echo "SERVICE=dhcpcd" > $ETH0CFG
-		echo "DHCP_START=\"\"" >> $ETH0CFG
-		echo "DHCP_STOP=\"-k\"" >> $ETH0CFG
+	unset DLG_COMMAND ARGS
 
-		# Start the service
-		$IFUP eth0
+	case "$SERVICE" in
 
-		# Test if dhcp worked and did not set DNS.
-		# If so run set_dns function.
-		if `ip link show eth0 2>/dev/null` | grep -q UP ; then			
-			if [ ! -f /etc/resolv.conf ] ; then
-				echo "DHCP did not configure DNS."
-				set_dns;
+		dhcp) 
+			echo "SERVICE=dhcpcd" > $ETHXCFG
+			echo "DHCP_START=\"\"" >> $ETHXCFG
+			echo "DHCP_STOP=\"-k\"" >> $ETHXCFG
+
+			# Start the service
+			$IFUP $DEV
+
+			# Test if dhcp worked and did not set DNS.
+			# If so run set_dns function.
+			if echo "$LINKTEST" | grep -q UP ; then			
+				if [ ! -f /etc/resolv.conf ] ; then
+					set_dns;
+				fi
+				ip addr show $DEV
 			fi
-			ip addr show eth0
-		fi
-		;;
+			;;
+	
+		static)
+			echo "SERVICE=ipv4-static" > $ETHXCFG
+			set_static_cfg;
+			set_dns;
+			$IFUP $DEV
+			;;
+	
+		pppoe)
+			adsl-setup
+			;;
+		*)
+			exit 0
+			;;
+	esac
+}
 
-	static)
-		echo "SERVICE=ipv4-static" > $ETH0CFG
-		set_static_ip;
-		set_static_gateway;
-		set_static_prefix;
-		set_static_broadcast;
-		set_dns;
-		# Start the service
-		$IFUP eth0
-		;;
+# Main Menu for ppp modem devices
+ppp_modem_menu(){
+        unset ARGS
+        ARGS="$ARGS configure \"Configure your modem.\""
+        ARGS="$ARGS dial \"Dial modem and exit.\""
+        ARGS="$ARGS hangup \"Hang up modem and exit.\""
 
-	pppoe)
-		adsl-setup
-		;;
+        DLG_COMMAND="dialog --title \"Modem - Actions\" --default-item configure \
+                --menu \"Select the action to perform for your modem:\" \
+                0 0 0 $ARGS"
+        SERVICE=`eval $DLG_COMMAND 3>&2 2>&1 1>&3`
 
-	*)
-		# Error message in case user entered something unusable, like "waldo"
-		echo ""
-		echo "--------------------------"
-		echo " Invalid option: $SERVICE"
-		echo " Please try again."
-		echo "--------------------------"
-		choose_service;
-		;;
-esac
+        unset DLG_COMMAND ARGS
+
+        case "$SERVICE" in
+
+                configure)
+                        set_modem_cfg;
+                        ;;
+
+                dial)
+                        [ -e /dev/ppp ] || mknod /dev/ppp c 108 0
+                        modprobe ppp-generic ; pppd call dialup
+                        exit 0
+                        ;;
+
+                hangup)
+                        killall pppd
+                        exit 0
+                        ;;
+                *)
+                        exit 0
+                        ;;
+        esac
+
+        ppp_modem_menu;
 }
 
-# Script starts here. Tests first for link on eth0
+# Main Menu for ppp gprs devices
+ppp_gprs_menu(){
+        unset ARGS
+        ARGS="$ARGS configure \"Configure your GPRS device.\""
+        ARGS="$ARGS dial \"Dial GPRS device and exit.\""
+        ARGS="$ARGS hangup \"Hang up GPRS device and exit.\""
 
+        DLG_COMMAND="dialog --title \"GPRS Device - Actions\" --default-item configure \
+                --menu \"Select the action to perform for your GPRS device:\" \
+                0 0 0 $ARGS"
+        SERVICE=`eval $DLG_COMMAND 3>&2 2>&1 1>&3`
+
+        unset DLG_COMMAND ARGS
+
+        case "$SERVICE" in
+
+                configure)
+			set_gprs_cfg;
+                        ;;
+
+                dial)
+			[ -e /dev/ppp ] || mknod /dev/ppp c 108 0 
+			modprobe ppp-generic ; pppd call gprs
+			exit 0
+                        ;;
+
+                hangup)
+			killall pppd
+			exit 0
+                        ;;
+                *)
+                        exit 0
+                        ;;
+        esac
+
+	ppp_gprs_menu;
+}
+
+# Script starts here. Check for root user.
 if [ `whoami` != "root" ] ; then
 	echo "You must be root to use $0"
 	exit 1;
 fi
 
-if [ -n "$LINKTEST" ] ; then
+# Get list of devices and prompt user to select one
+if [ ! -d /sys/class/net ] ; then
+	echo "No devices found or sysfs not mounted!"
+	exit 1;
+fi
 
-	# If link is not up, start main function choose_service.
-
-	if ! echo "$LINKTEST" | grep -q UP ; then
-		echo ""
-		echo $GREETING
-		choose_service;
+for EDEV in /sys/class/net/eth* /sys/class/net/wlan* ; do
+	EDEV=`basename $EDEV`
+	if echo $EDEV | grep -q "*" ; then continue ; fi
+	if echo `/sbin/ip link show $EDEV 2> /dev/null` | grep -q UP ; then
+		EDEVSTATUS="UP"
 	else
+		EDEVSTATUS="DOWN"
+	fi
+	DEVLIST="$DEVLIST `basename $EDEV` \"$EDEVSTATUS\""
+done
+DEVLIST="$DEVLIST ppp-modem \"Configure a dial-up Modem\" ppp-gprs \"Configure a GPRS Modem\""
 
-	# If link is up, user likely has run this script already.
-	# Take down eth0 so we can set it up cleanly.
+DLG_COMMAND="dialog --title \"Network Configuration\" --default-item eth0 \
+       	--timeout 30 --menu \"Select the network device to configure:\" \
+	0 0 0 $DEVLIST"
+DEV=`eval $DLG_COMMAND 3>&2 2>&1 1>&3`
+unset EDEV EDEVSTATUS DEVLIST DLG_COMMAND
 
-		$IFDOWN eth0
-		echo ""
-		echo $GREETING
-		choose_service;
+# Continue if device was selected, exit if otherwise.
+if [ -n "$DEV" ] ; then
+	if [ "$DEV" == "ppp-modem" ] ; then
+		ppp_modem_menu;
+		exit 0
 	fi
-else
-	echo "Device eth0 is not present on this system!"
+	if [ "$DEV" == "ppp-gprs" ] ; then
+		ppp_gprs_menu;
+		exit 0
+	fi
+        # If the menu times out, activate eth0 with dhcpcd and exit.
+        if [ "$DEV" == "timeout" ] ; then
+                DEV="eth0"
+                set_devvars;
+                rm -f $ETHXCFG
+                echo "SERVICE=dhcpcd" > $ETHXCFG
+                echo "DHCP_START=\"\"" >> $ETHXCFG
+                echo "DHCP_STOP=\"-k\"" >> $ETHXCFG
+                $IFUP $DEV
+                exit 0
+        fi
+	
+	# If not ppp-modem or ppp-gprs, then network device to configure
+	set_devvars;
+
+	if [ -n "$LINKTEST" ] ; then
+		# Link is up. Bring it down and start service menu.
+		if echo "$LINKTEST" | grep -q UP ; then
+			$IFDOWN $DEV
+		fi
+
+		net_service_menu;
+	else
+		DLG_COMMAND="dialog --title \"Device Not Found\" \
+                --msgbox \"Device $DEV is not present on this system.\" 6 60"
+                eval $DLG_COMMAND
+		exit 1
+	fi
 fi

Modified: x86/branches/utf8-newmake/scripts/net-setup
===================================================================
--- x86/branches/utf8-newmake/scripts/net-setup	2005-08-27 16:14:47 UTC (rev 599)
+++ x86/branches/utf8-newmake/scripts/net-setup	2005-08-28 05:06:17 UTC (rev 600)
@@ -377,8 +377,9 @@
 	exit 1;
 fi
 
-for EDEV in "/sys/class/net/eth* /sys/class/net/wlan*" ; do
+for EDEV in /sys/class/net/eth* /sys/class/net/wlan* ; do
 	EDEV=`basename $EDEV`
+	if echo $EDEV | grep -q "*" ; then continue ; fi
 	if echo `/sbin/ip link show $EDEV 2> /dev/null` | grep -q UP ; then
 		EDEVSTATUS="UP"
 	else
@@ -389,7 +390,7 @@
 DEVLIST="$DEVLIST ppp-modem \"Configure a dial-up Modem\" ppp-gprs \"Configure a GPRS Modem\""
 
 DLG_COMMAND="dialog --title \"Network Configuration\" --default-item eth0 \
-       	--timeout 20 --menu \"Select the network device to configure:\" \
+       	--timeout 30 --menu \"Select the network device to configure:\" \
 	0 0 0 $DEVLIST"
 DEV=`eval $DLG_COMMAND 3>&2 2>&1 1>&3`
 unset EDEV EDEVSTATUS DEVLIST DLG_COMMAND
@@ -404,6 +405,17 @@
 		ppp_gprs_menu;
 		exit 0
 	fi
+        # If the menu times out, activate eth0 with dhcpcd and exit.
+        if [ "$DEV" == "timeout" ] ; then
+                DEV="eth0"
+                set_devvars;
+                rm -f $ETHXCFG
+                echo "SERVICE=dhcpcd" > $ETHXCFG
+                echo "DHCP_START=\"\"" >> $ETHXCFG
+                echo "DHCP_STOP=\"-k\"" >> $ETHXCFG
+                $IFUP $DEV
+                exit 0
+        fi
 	
 	# If not ppp-modem or ppp-gprs, then network device to configure
 	set_devvars;

Modified: x86_64/trunk/scripts/net-setup
===================================================================
--- x86_64/trunk/scripts/net-setup	2005-08-27 16:14:47 UTC (rev 599)
+++ x86_64/trunk/scripts/net-setup	2005-08-28 05:06:17 UTC (rev 600)
@@ -377,8 +377,9 @@
 	exit 1;
 fi
 
-for EDEV in "/sys/class/net/eth* /sys/class/net/wlan*" ; do
+for EDEV in /sys/class/net/eth* /sys/class/net/wlan* ; do
 	EDEV=`basename $EDEV`
+	if echo $EDEV | grep -q "*" ; then continue ; fi
 	if echo `/sbin/ip link show $EDEV 2> /dev/null` | grep -q UP ; then
 		EDEVSTATUS="UP"
 	else
@@ -389,7 +390,7 @@
 DEVLIST="$DEVLIST ppp-modem \"Configure a dial-up Modem\" ppp-gprs \"Configure a GPRS Modem\""
 
 DLG_COMMAND="dialog --title \"Network Configuration\" --default-item eth0 \
-       	--timeout 20 --menu \"Select the network device to configure:\" \
+       	--timeout 30 --menu \"Select the network device to configure:\" \
 	0 0 0 $DEVLIST"
 DEV=`eval $DLG_COMMAND 3>&2 2>&1 1>&3`
 unset EDEV EDEVSTATUS DEVLIST DLG_COMMAND
@@ -404,6 +405,17 @@
 		ppp_gprs_menu;
 		exit 0
 	fi
+        # If the menu times out, activate eth0 with dhcpcd and exit.
+        if [ "$DEV" == "timeout" ] ; then
+                DEV="eth0"
+                set_devvars;
+                rm -f $ETHXCFG
+                echo "SERVICE=dhcpcd" > $ETHXCFG
+                echo "DHCP_START=\"\"" >> $ETHXCFG
+                echo "DHCP_STOP=\"-k\"" >> $ETHXCFG
+                $IFUP $DEV
+                exit 0
+        fi
 	
 	# If not ppp-modem or ppp-gprs, then network device to configure
 	set_devvars;




More information about the livecd mailing list