- use hal
This commit is contained in:
Stanislav Ievlev 2007-11-14 15:05:35 +03:00
parent 69a16cf90b
commit c513999564
5 changed files with 70 additions and 23 deletions

View File

@ -1,11 +1,13 @@
%define _altdata_dir %_datadir/alterator
Name: alterator-net-common
Version: 0.1
Release: alt3
Version: 0.2
Release: alt1
Packager: Stanislav Ievlev <inger@altlinux.org>
Requires: libshell hal
Requires: etcnet
BuildArch: noarch
@ -30,6 +32,9 @@ helpers for etcnet administration
%_libexecdir/%name/
%changelog
* Wed Nov 14 2007 Stanislav Ievlev <inger@altlinux.org> 0.2-alt1
- use hal
* Tue Oct 30 2007 Stanislav Ievlev <inger@altlinux.org> 0.1-alt3
- add iftabupdate utility

View File

@ -1,25 +1,29 @@
#!/bin/sh
usage()
{
echo "Usage: $0 <interface>" > /dev/stderr
exit 1
}
. shell-error
description()
{
echo "$4"
}
[ -z "$1" ] && fatal "Usage: $0 <interface>"
[ -z "$1" ] && usage
/sbin/service messagebus start >/dev/null 2>/dev/null
/sbin/service haldaemon start >/dev/null 2>/dev/null
device=$(readlink "/sys/class/net/$1/device")
iface_udi="$(hal-find-by-property --key=net.interface --string="$1")"
[ -n "$iface_udi" ] || fatal "interface $1 not found"
if echo "$device" | grep -q usb; then
cat "$device/../manufacturer"
else
slot=${device##*/}
if [ -n "$slot" ]; then
eval description $(lspci -m -s "$slot")
fi
fi
device_udi="$(hal-get-property --udi="$iface_udi" --key=net.originating_device)"
[ -n "$device_udi" ] || fatal "originating device for interface $1 not found"
device_subsystem="$(hal-get-property --udi="$device_udi" --key=info.subsystem)"
case "$device_subsystem" in
pci)
printf '%s\n' \
"$(hal-get-property --udi="$device_udi" --key=pci.product)"
;;
usb)
printf '%s\n' \
"$(hal-get-property --udi="$device_udi" --key=usb.vendor)"
;;
*)
fatal "wrong device subsystem $device_subsystem"
esac

View File

@ -0,0 +1,15 @@
#!/bin/sh
. shell-error
[ -z "$1" ] && fatal "Usage: $0 <interface>"
/sbin/service messagebus start >/dev/null 2>/dev/null
/sbin/service haldaemon start >/dev/null 2>/dev/null
iface_udi="$(hal-find-by-property --key=net.interface --string="$1")"
[ -n "$iface_udi" ] || fatal "interface $1 not found"
[ "$(hal-get-property --udi="$iface_udi" --key=info.category)" = "net.80211" ]

View File

@ -0,0 +1,16 @@
#!/bin/sh
. shell-error
[ -z "$1" ] && fatal "Usage: $0 <interface>"
/sbin/service messagebus start >/dev/null 2>/dev/null
/sbin/service haldaemon start >/dev/null 2>/dev/null
iface_udi="$(hal-find-by-property --key=net.interface --string="$1")"
[ -n "$iface_udi" ] || fatal "interface $1 not found"
device_udi="$(hal-get-property --udi="$iface_udi" --key=net.originating_device)"
[ -n "$device_udi" ] || fatal "originating device for interface $1 not found"
hal-get-property --udi="$device_udi" --key=info.linux.driver

View File

@ -1,4 +1,11 @@
#!/bin/sh
/sbin/ip -o a l|
sed -nre 's|^[0-9]+: ([^:]+): [^/]* link/ether ([a-f0-9:]+).*|\1 \2|p'
/sbin/service messagebus start >/dev/null 2>/dev/null
/sbin/service haldaemon start >/dev/null 2>/dev/null
(hal-find-by-capability --capability=net.80203 ; hal-find-by-capability --capability=net.80211)|
while read udi ;do
printf '%s %s\n' \
"$(hal-get-property --udi=$udi --key=net.interface)" \
"$(hal-get-property --udi=$udi --key=net.address)"
done