summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Gianelloni <wolf31o2@gentoo.org>2006-05-30 20:20:11 +0000
committerChris Gianelloni <wolf31o2@gentoo.org>2006-05-30 20:20:11 +0000
commitc441cd26e5a480c69c4237ae4e2fdf49814f26d5 (patch)
treea4bc1424e824ed35756f8c86fb4b98c7f77fc41f /src/livecd-tools
parentCheck for presence of dialog before running. Suggestion made by Markus Saari... (diff)
downloadgentoo-c441cd26e5a480c69c4237ae4e2fdf49814f26d5.tar.gz
gentoo-c441cd26e5a480c69c4237ae4e2fdf49814f26d5.tar.bz2
gentoo-c441cd26e5a480c69c4237ae4e2fdf49814f26d5.zip
Added patch from Daniel Drake <dsd@gentoo.org> to simplify network setup on 2.6 kernels. You 2.4 suckas bettah recognize... This is for bug #133955.
Diffstat (limited to 'src/livecd-tools')
-rw-r--r--src/livecd-tools/livecd-functions.sh130
-rw-r--r--src/livecd-tools/net-setup18
2 files changed, 144 insertions, 4 deletions
diff --git a/src/livecd-tools/livecd-functions.sh b/src/livecd-tools/livecd-functions.sh
index eac21fca86..be8c557da6 100644
--- a/src/livecd-tools/livecd-functions.sh
+++ b/src/livecd-tools/livecd-functions.sh
@@ -1,7 +1,7 @@
#!/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/livecd-functions.sh,v 1.22 2006/05/15 12:55:27 wolf31o2 Exp $
+# $Header: /var/cvsroot/gentoo/src/livecd-tools/livecd-functions.sh,v 1.23 2006/05/30 20:20:11 wolf31o2 Exp $
# Global Variables:
# CDBOOT -- is booting off CD
@@ -262,6 +262,134 @@ livecd_write_net_conf() {
esac
}
+get_ifmac() {
+ local iface=$1
+
+ # Example: 00:01:6f:e1:7a:06
+ cat /sys/class/net/${iface}/address
+}
+
+
+get_ifdriver() {
+ local iface=$1
+
+ # Example: ../../../bus/pci/drivers/forcedeth (wanted: forcedeth)
+ local if_driver="$(readlink /sys/class/net/${iface}/device/driver)"
+ basename ${if_driver}
+}
+
+get_ifbus() {
+ local iface=$1
+
+ # Example: ../../../bus/pci (wanted: pci)
+ # Example: ../../../../bus/pci (wanted: pci)
+ # Example: ../../../../../../bus/usb (wanted: usb)
+ local if_bus="$(readlink /sys/class/net/${iface}/device/bus)"
+ basename ${if_bus}
+}
+
+get_ifproduct() {
+ local iface=$1
+ local bus="$(get_ifbus ${iface})"
+ local if_pciaddr
+ local if_devname
+ local if_usbpath
+ local if_usbmanufacturer
+ local if_usbproduct
+
+ if [[ ${bus} == "pci" ]]; then
+ # Example: ../../../devices/pci0000:00/0000:00:0a.0 (wanted: 0000:00:0a.0)
+ # Example: ../../../devices/pci0000:00/0000:00:09.0/0000:01:07.0 (wanted: 0000:01:07.0)
+ if_pciaddr="$(readlink /sys/class/net/${iface}/device)"
+ if_pciaddr="$(basename ${if_pciaddr})"
+
+ # Example: 00:0a.0 Bridge: nVidia Corporation CK804 Ethernet Controller (rev a3)
+ # (wanted: nVidia Corporation CK804 Ethernet Controller)
+ if_devname="$(lspci -s ${if_pciaddr})"
+ if_devname="${if_devname#*: }"
+ if_devname="${if_devname%(rev *)}"
+ fi
+
+ if [[ ${bus} == "usb" ]]; then
+ if_usbpath="$(readlink /sys/class/net/${iface}/device)"
+ if_usbpath="/sys/class/net/${iface}/$(dirname ${if_usbpath})"
+ if_usbmanufacturer="$(< ${if_usbpath}/manufacturer)"
+ if_usbproduct="$(< ${if_usbpath}/product)"
+
+ [[ -n ${if_usbmanufacturer} ]] && if_devname="${if_usbmanufacturer} "
+ [[ -n ${if_usbproduct} ]] && if_devname="${if_devname}${if_usbproduct}"
+ fi
+
+ if [[ ${bus} == "ieee1394" ]]; then
+ if_devname="IEEE1394 (FireWire) Network Adapter";
+ fi
+
+ echo ${if_devname}
+}
+
+get_ifdesc() {
+ local iface=$1
+ desc="$(get_ifproduct ${iface})"
+ if [[ -n ${desc} ]]; then
+ echo $desc
+ return;
+ fi
+
+ desc="$(get_ifdriver ${iface})"
+ if [[ -n ${desc} ]]; then
+ echo $desc
+ return;
+ fi
+
+ desc="$(get_ifmac ${iface})"
+ if [[ -n ${desc} ]]; then
+ echo $desc
+ return;
+ fi
+
+ echo "Unknown"
+}
+
+show_ifmenu() {
+ local old_ifs="${IFS}"
+ local opts
+ IFS="
+"
+ for ifname in $(/sbin/ifconfig -a | grep "^[^ ]"); do
+ ifname="${ifname%% *}"
+ [[ ${ifname} == "lo" ]] && continue
+ opts="${opts} ${ifname} '$(get_ifdesc ${ifname})'"
+ done
+ IFS="${old_ifs}"
+
+ if ! eval dialog --menu \"Please select the interface that you wish to configure from the list below:\" 0 0 0 $opts 2>iface; then
+ exit
+ fi
+
+ iface="$(< iface)"
+}
+
+show_ifconfirm() {
+ local iface=$1
+ local if_mac="$(get_ifmac ${iface})"
+ local if_driver="$(get_ifdriver ${iface})"
+ local if_bus="$(get_ifbus ${iface})"
+ local if_product="$(get_ifproduct ${iface})"
+
+ local text="Details for network interface ${iface} are shown below.\n\nInterface name: ${iface}\n"
+ [[ -n ${if_product} ]] && text="${text}Device: ${if_product}\n"
+ [[ -n ${if_mac} ]] && text="${text}MAC address: ${if_mac}\n"
+ [[ -n ${if_driver} ]] && text="${text}Driver: ${if_driver}\n"
+ [[ -n ${if_bus} ]] && text="${text}Bus type: ${if_bus}\n"
+ text="${text}\nIs this the interface that you wish to configure?"
+
+ if ! dialog --title "Interface details" --yesno "${text}" 15 70; then
+ result="no"
+ else
+ result="yes"
+ fi
+}
+
livecd_console_settings() {
# scan for a valid baud rate
case "$1" in
diff --git a/src/livecd-tools/net-setup b/src/livecd-tools/net-setup
index af673f25be..357cbe7442 100644
--- a/src/livecd-tools/net-setup
+++ b/src/livecd-tools/net-setup
@@ -1,7 +1,7 @@
#!/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.18 2006/05/30 19:50:59 wolf31o2 Exp $
+# $Header: /var/cvsroot/gentoo/src/livecd-tools/net-setup,v 1.19 2006/05/30 20:20:11 wolf31o2 Exp $
if [ -f /sbin/livecd-functions.sh ]
then
@@ -19,10 +19,13 @@ fi
livecd_check_root || exit 1
+# Hide any potential error messages from the readlink/dirname/etc calls below
+exec 2>/dev/null
+
if [ -z "${1}" ]
then
- echo "ERROR: please specify a network interface"
- exit 1
+ show_ifmenu
+ echo $iface
else
iface="${1}"
fi
@@ -30,6 +33,15 @@ fi
[ ! -d /tmp/setup.opts ] && mkdir /tmp/setup.opts
cd /tmp/setup.opts
+while true; do
+ show_ifconfirm $iface
+ [[ $result == "yes" ]] && break
+ show_ifmenu
+done
+
+# Show stderr again
+exec 2>/dev/stderr
+
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)"
case ${WIRED_WIRELESS} in