cloner: fix a spelling error just for Bruce
[bootimage-initfs.git] / etc / hardware_output.sh
1 #!/bin/ash
2
3 . /etc/library.sh
4
5
6 disk_list() {
7
8         DISK_COUNT=0
9
10         for i in `ls -1 /proc/ide/hd* | grep "/proc/ide/hd[a-z]$" 2>> /tmp/stderr.log`
11         do
12                 dev=`basename $i`
13                 size=`disk_size $dev`
14                 model=`cat /proc/ide/$dev/model | head -1`
15                 echo "DISK_${DISK_COUNT}_DEV=\"$dev\""
16                 echo "DISK_${DISK_COUNT}_SIZE=\"$size\""
17                 echo "DISK_${DISK_COUNT}_MODEL=\"$model\""
18                 DISK_COUNT=`expr ${DISK_COUNT} + 1`
19         done
20
21         for i in `ls -1 /dev/sd* | grep "/dev/sd[a-z]$`
22         do
23                 dev=`basename $i`
24                 exists=`cat /proc/partitions | awk '{print  $4}' | grep $dev`
25                 if [ "${exists}" != "" ]
26                 then
27                         size=`disk_size $dev`
28                         model=`cat /sys/block/$dev/device/model`
29                         vendor=`cat /sys/block/$dev/device/vendor`      
30                         scsi="${scsi} ### $dev:$size:$vendor $model"
31
32                         echo "DISK_${DISK_COUNT}_DEV=\"$dev\""
33                         echo "DISK_${DISK_COUNT}_SIZE=\"$size\""
34                         echo "DISK_${DISK_COUNT}_MODEL=\"$vendor $model\""
35                         DISK_COUNT=`expr ${DISK_COUNT} + 1`
36                 fi
37         done
38         echo "DISK_COUNT=\"${DISK_COUNT}\""
39 }
40
41 disk_size() {
42         dev=$1
43         
44         size=`cat /proc/partitions | awk '{ print $3, $4 }' | grep "${dev}$" | awk '{print $1}'`
45         echo $size
46 }
47
48 network_list() {
49
50         NIC_COUNT=0
51
52         for dev in `ls -1 /sys/class/net`
53         do
54                 driver=""
55                 pci_dev=""
56                 dev_vend=""
57                 dev_dev=""
58
59                 hwaddr=`cat /sys/class/net/${dev}/address`
60
61                 if [ "${dev}" = "lo" ]
62                 then
63                     continue
64                 fi
65                 echo "NIC_${NIC_COUNT}_DEV=\"${dev}\""
66                 echo "NIC_${NIC_COUNT}_HWADDR=\"${hwaddr}\""
67
68                 if [ -e /sys/class/net/${dev}/driver ]
69                 then
70                         driverlnk=`readlink /sys/class/net/${dev}/driver`
71                         driver=`basename $driverlnk`
72                 fi
73
74                 if [ -e /sys/class/net/${dev}/device ]
75                 then
76                         dev_vend=`cat /sys/class/net/${dev}/device/vendor`
77                         dev_dev=`cat /sys/class/net/${dev}/device/device`
78                 fi
79                 #driver=`basename ${driverlnk}`
80                 echo "NIC_${NIC_COUNT}_DRIVER=\"${driver}\""
81                 echo "NIC_${NIC_COUNT}_PCIDEV=\"${dev_dev}\""
82                 echo "NIC_${NIC_COUNT}_PCIVENDOR=\"${dev_vend}\""
83
84                 NIC_COUNT=`expr ${NIC_COUNT} + 1`
85         done
86         echo "NIC_COUNT=\"${NIC_COUNT}\""
87
88 }
89
90 pci_list() {
91         PCI_COUNT=0
92         for i in /sys/bus/pci/devices/*
93         do
94                 busid=`basename $i`
95                 device=`cat ${i}/device`
96                 vendor=`cat ${i}/vendor`
97                 irq=`cat ${i}/irq`
98                 class=`cat ${i}/class`
99
100                 echo "PCI_${PCI_COUNT}_BUSID=\"$busid\""
101                 echo "PCI_${PCI_COUNT}_DEVICE=\"$device\""
102                 echo "PCI_${PCI_COUNT}_VENDOR=\"$vendor\""
103                 echo "PCI_${PCI_COUNT}_CLASS=\"$class\""
104                 echo "PCI_${PCI_COUNT}_IRQ=\"$irq\""
105
106                 PCI_COUNT=`expr ${PCI_COUNT} + 1`
107         done
108
109         echo "PCI_COUNT=\"${PCI_COUNT}\""
110 }
111
112 /usr/bin/act_dmi        > /tmp/hardware.dat
113 disk_list               >> /tmp/hardware.dat
114 network_list    >> /tmp/hardware.dat
115 pci_list                >> /tmp/hardware.dat
116