From: "William Hubbs" <williamh@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/livecd-tools:master commit in: /
Date: Sun, 22 Feb 2015 22:35:29 +0000 (UTC) [thread overview]
Message-ID: <1424644390.764f654a5136aa182e2a0ef8c8e26b81a8934dcb.williamh@gentoo> (raw)
commit: 764f654a5136aa182e2a0ef8c8e26b81a8934dcb
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sun Feb 22 22:33:10 2015 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> 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
next reply other threads:[~2015-02-22 22:35 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-22 22:35 William Hubbs [this message]
-- strict thread matches above, loose matches on Subject: below --
2019-09-26 17:07 [gentoo-commits] proj/livecd-tools:master commit in: / Rick Farina
2017-03-07 15:35 Brian Evans
2017-02-25 0:54 Robin H. Johnson
2017-01-10 21:54 Brian Evans
2015-10-18 2:26 William Hubbs
2015-10-18 1:45 Jorge Manuel B. S. Vicetto
2015-01-14 18:33 William Hubbs
2015-01-14 2:55 Jorge Manuel B. S. Vicetto
2013-07-07 22:48 William Hubbs
2013-07-07 22:28 William Hubbs
2013-07-06 23:53 William Hubbs
2013-02-25 18:20 William Hubbs
2013-02-25 17:48 William Hubbs
2013-02-25 17:48 William Hubbs
2011-06-30 20:31 William Hubbs
2011-06-28 19:56 William Hubbs
2011-06-28 17:32 William Hubbs
2011-05-01 2:49 William Hubbs
2011-05-01 2:49 William Hubbs
2011-05-01 2:49 William Hubbs
2011-05-01 2:49 William Hubbs
2011-05-01 2:49 William Hubbs
2011-05-01 2:49 William Hubbs
2011-05-01 2:49 William Hubbs
2011-05-01 2:49 William Hubbs
2011-05-01 2:49 William Hubbs
2011-05-01 2:49 William Hubbs
2011-05-01 2:49 William Hubbs
2011-05-01 2:49 William Hubbs
2011-05-01 2:49 William Hubbs
2011-05-01 2:49 William Hubbs
2011-05-01 2:49 William Hubbs
2011-05-01 2:49 William Hubbs
2011-05-01 2:49 William Hubbs
2011-05-01 2:49 William Hubbs
2011-05-01 2:49 William Hubbs
2011-05-01 2:49 William Hubbs
2011-05-01 2:49 William Hubbs
2011-05-01 2:49 William Hubbs
2011-05-01 2:49 William Hubbs
2011-05-01 2:49 William Hubbs
2011-05-01 2:49 William Hubbs
2011-02-17 5:38 William Hubbs
2011-02-10 21:30 William Hubbs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1424644390.764f654a5136aa182e2a0ef8c8e26b81a8934dcb.williamh@gentoo \
--to=williamh@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox