From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id DEBE6138A87 for ; Sun, 22 Feb 2015 22:35:34 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 88BCDE0920; Sun, 22 Feb 2015 22:35:33 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 26254E0920 for ; Sun, 22 Feb 2015 22:35:33 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 71A413409F2 for ; Sun, 22 Feb 2015 22:35:31 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id E6BD412564 for ; Sun, 22 Feb 2015 22:35:29 +0000 (UTC) From: "William Hubbs" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" Message-ID: <1424644390.764f654a5136aa182e2a0ef8c8e26b81a8934dcb.williamh@gentoo> Subject: [gentoo-commits] proj/livecd-tools:master commit in: / X-VCS-Repository: proj/livecd-tools X-VCS-Files: net-setup X-VCS-Directories: / X-VCS-Committer: williamh X-VCS-Committer-Name: William Hubbs X-VCS-Revision: 764f654a5136aa182e2a0ef8c8e26b81a8934dcb X-VCS-Branch: master Date: Sun, 22 Feb 2015 22:35:29 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 0cb55e94-b022-4557-a6e8-90a2ed81d403 X-Archives-Hash: 502dec79a95f40be2dc3b1923439227f commit: 764f654a5136aa182e2a0ef8c8e26b81a8934dcb Author: William Hubbs gmail com> AuthorDate: Sun Feb 22 22:33:10 2015 +0000 Commit: William Hubbs gentoo org> CommitDate: Sun Feb 22 22:33:10 2015 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/livecd-tools.git;a=commit;h=764f654a Encorporate code from livecd-functions These functions only seem to be used by the net-setup script, so I do not see a reason to source livecd-functions when we can encorporate them directly. --- net-setup | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 97 insertions(+), 8 deletions(-) diff --git a/net-setup b/net-setup index e6d2979..0060872 100755 --- a/net-setup +++ b/net-setup @@ -1,5 +1,98 @@ #!/bin/bash +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_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_ifmac() { + local iface=$1 + + # Example: 00:01:6f:e1:7a:06 + cat /sys/class/net/${iface}/address +} + +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 @@ -212,22 +305,18 @@ write_net_conf() { esac } -if [ -f /sbin/livecd-functions.sh ] +if [ ! -x $(which dialog) ] then - source /sbin/livecd-functions.sh -else - echo "ERROR: /sbin/livecd-functions.sh could not be loaded!" + echo "ERROR: The dialog utility is required for net-setup. Exiting!" exit 1 fi -if [ ! -x $(which dialog) ] +if [ "$(whoami)" != "root" ] then - echo "ERROR: The dialog utility is required for net-setup. Exiting!" + echo "ERROR: must be root to continue" exit 1 fi -livecd_check_root || exit 1 - if [ -z "${1}" ] then show_ifmenu