X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Finstall%2Bsetup%2Finstall%2Fprobenic.sh;h=f8ab7e114e780ad62aca5b869d1d732e029515b2;hb=9a0b3f02cc324b2a17fb85141a230b719d5d4f82;hp=38ad71c7b1aeb32c723a41cd8c608a95f0f33834;hpb=5057b6110c244b37dd9c18dc8da2515743fdcbeb;p=people%2Fpmueller%2Fipfire-2.x.git diff --git a/src/install+setup/install/probenic.sh b/src/install+setup/install/probenic.sh index 38ad71c7b1..f8ab7e114e 100644 --- a/src/install+setup/install/probenic.sh +++ b/src/install+setup/install/probenic.sh @@ -1,19 +1,76 @@ #!/bin/sh +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2009 Michael Tremer & Christian Schmidt # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################### -case "$1" in - install) - kudzu -qps -c NETWORK | egrep "desc|network.hwaddr" | \ - awk -F": " '{ print $2";" }' | sed -e '/..:..:..:..:..:..;/a\X' | \ - tr "\n" "X" | sed -e 's/XXX/\n/g' -e 's/;X/;/g' | \ - sort > /tmp/scanned_nics 2>/dev/null - ;; - "") - if [ ! -e /var/ipfire/ethernet/scan_lock ]; then - kudzu -qps -c NETWORK | egrep "desc|network.hwaddr" | \ - awk -F": " '{ print $2";" }' | sed -e '/..:..:..:..:..:..;/a\X' | \ - tr "\n" "X" | sed -e "s/XXX/\n/g" -e 's/;X/;/g' | \ - sort > /var/ipfire/ethernet/scanned_nics 2>/dev/null +if [ -e /var/ipfire/ethernet/scanned_nics ]; then + rm -f /var/ipfire/ethernet/scanned_nics +fi +touch /var/ipfire/ethernet/scanned_nics + +for card in `ls /sys/class/net`; do + + #Check if this is an Ethernet device (type=1) + if [ `cat /sys/class/net/$card/type` == "1" ]; then + hwaddr=`cat /sys/class/net/$card/address` + + #Check if mac is valid (not 00:00... or FF:FF...) + if [ ! "$hwaddr" == "00:00:00:00:00:00" ];then + if [ ! "$hwaddr" == "ff:ff:ff:ff:ff:ff" ];then + + driver=`grep PHYSDEVDRIVER= /sys/class/net/$card/uevent | cut -d"=" -f2` + type=`grep PHYSDEVBUS= /sys/class/net/$card/uevent | cut -d"=" -f2` + + #Default if not avaiable in /sys/class/net + if [ "a$type" == "a" ]; then + type="???" + fi + if [ "a$driver" == "a" ]; then + driver="Unknown Network card" + fi + description=`echo $type: $driver` + + #Get more details for pci and usb devices + if [ "$type" == "pci" ]; then + slotname=`grep PCI_SLOT_NAME= /sys/class/net/$card/device/uevent | cut -d"=" -f2` + name=`lspci -s $slotname | cut -d':' -f3 | cut -c 2-` + description=`echo $type: $name` + fi + if [ "$type" == "usb" ]; then + bus=`grep DEVICE= /sys/class/net/$card/device/uevent | cut -d"/" -f5` + dev=`grep DEVICE= /sys/class/net/$card/device/uevent | cut -d"/" -f6` + #work around the base8 convert + let bus=`echo 1$bus`-1000 + let dev=`echo 1$dev`-1000 + name=`lsusb -s $bus:$dev | cut -d':' -f3 | cut -c 6-` + description=`echo $type: $name` + fi + + echo desc: \"$description\" >>/var/ipfire/ethernet/scanned_nics + echo driver: $driver >>/var/ipfire/ethernet/scanned_nics + echo network.hwaddr: $hwaddr >>/var/ipfire/ethernet/scanned_nics + fi fi - ;; -esac + fi +done + +# Revert Accesspoint marking at mac address +sed -i 's|hwaddr: 06:|hwaddr: 00:|g' /var/ipfire/ethernet/scanned_nics + exit 0