]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/install+setup/install/probenic.sh
Merge branch 'master' into fifteen
[people/teissler/ipfire-2.x.git] / src / install+setup / install / probenic.sh
1 #!/bin/sh
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2011 IPFire Team <info@ipfire.org> #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 if [ -e /var/ipfire/ethernet/scanned_nics ]; then
23 rm -f /var/ipfire/ethernet/scanned_nics
24 fi
25 touch /var/ipfire/ethernet/scanned_nics
26
27 for card in `ls /sys/class/net`; do
28
29 #Check if this is an Ethernet device (type=1)
30 if [ `cat /sys/class/net/$card/type` == "1" ]; then
31 hwaddr=`cat /sys/class/net/$card/address`
32
33 #Check that is no VLAN if
34 if [[ ! "$card" =~ "[.]" ]]; then
35
36 #check if this not a bridge
37 if [ ! -e /sys/class/net/$card/brforward ]; then
38
39 #Check if mac is valid (not 00:00... or FF:FF...)
40 if [ ! "$hwaddr" == "00:00:00:00:00:00" ];then
41 if [ ! "$hwaddr" == "ff:ff:ff:ff:ff:ff" ];then
42
43 driver=`grep DRIVER= /sys/class/net/$card/device/uevent | cut -d"=" -f2`
44 type=`grep MODALIAS= /sys/class/net/$card/device/uevent | cut -d"=" -f2 | cut -d":" -f1`
45
46 #Default if not available in /sys/class/net
47 if [ "a$type" == "a" ]; then
48 type="???"
49 fi
50 if [ "a$driver" == "a" ]; then
51 driver="Unknown Network Interface ($card)"
52 fi
53 description=`echo $type: $driver`
54
55 #Get more details for pci and usb devices
56 if [ "$type" == "pci" ]; then
57 slotname=`grep PCI_SLOT_NAME= /sys/class/net/$card/device/uevent | cut -d"=" -f2`
58 name=`lspci -s $slotname | cut -d':' -f3 | cut -c 2-`
59 description=`echo $type: $name`
60 fi
61 if [ "$type" == "usb" ]; then
62 bus=`grep DEVICE= /sys/class/net/$card/device/uevent | cut -d"/" -f5`
63 dev=`grep DEVICE= /sys/class/net/$card/device/uevent | cut -d"/" -f6`
64 #work around the base8 convert
65 let bus=`echo 1$bus`-1000
66 let dev=`echo 1$dev`-1000
67 name=`lsusb -s $bus:$dev | cut -d':' -f3 | cut -c 6-`
68 #kernel higher 3.2 changes
69 if [ "$name" == "" ]; then
70 vid=`grep PRODUCT= /sys/class/net/$card/device/uevent | cut -d"=" -f2 | cut -d"/" -f1`
71 pid=`grep PRODUCT= /sys/class/net/$card/device/uevent | cut -d"=" -f2 | cut -d"/" -f2`
72 name=`lsusb -d $vid:$pid | cut -d':' -f3 | cut -c 6-`
73 fi
74 description=`echo $type: $name`
75 fi
76
77 echo desc: \"$description\" >>/var/ipfire/ethernet/scanned_nics
78 echo driver: $driver >>/var/ipfire/ethernet/scanned_nics
79 echo network.hwaddr: $hwaddr >>/var/ipfire/ethernet/scanned_nics
80 fi
81 fi
82 fi
83 fi
84 fi
85 done
86
87 # Revert Accesspoint marking at mac address
88 sed -i 's|hwaddr: 06:|hwaddr: 00:|g' /var/ipfire/ethernet/scanned_nics
89
90 exit 0