summaryrefslogtreecommitdiff
path: root/scripts/ipmi_if.sh
blob: 4068717bfb7db29387d9475643c35494e0d42dfb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh
#            ipmi_if.sh
# detect IPMI Interface type, usually KCS or SSIF 
#
# Future: also include preferred Driver type on another line
#
# ifdir=/usr/share/ipmiutil
ifdir=/var/lib/ipmiutil
ifout=$ifdir/ipmi_if.txt
dmiout=/tmp/dmi.out.$$

mkdir -p $ifdir
which dmidecode  >/dev/null 2>&1
if [ $? -ne 0 ]
then
   # if no dmidecode, old, so assume KCS 
   echo "Interface type: KCS" >$ifout
   exit 0
fi
dmidecode >$dmiout
# dmidecode |grep IPMI >/dev/null 2>&1
grep IPMI $dmiout >/dev/null 2>&1
if [ $? -ne 0 ]
then
   echo "Interface type: None" >$ifout
   exit 0
fi
iftype=`grep "Interface Type:" $dmiout |cut -f2 -d':'`
echo $iftype |grep KCS >/dev/null 2>&1
if [ $? -eq 0 ]
then
   echo "Interface type: KCS" >$ifout
else
   echo $iftype |grep "OUT OF SPEC" >/dev/null 2>&1
   if [ $? -eq 0 ]
   then
      echo "Interface type: SSIF" >$ifout
   else 
      echo "Interface type: $iftype" >$ifout
   fi
fi
# echo "IPMI `cat $ifout` interface found"

sa=`grep "I2C Slave Address:" $dmiout |cut -f2 -d':'`
echo "I2C Slave Address: $sa" >>$ifout
base=`grep "Base Address:" $dmiout |tail -n1 |cut -f2 -d':'`
echo "Base Address: $base" >>$ifout

spacing=1
spac_str=`grep "Register Spacing:" $dmiout |cut -f2 -d':'`
echo $spac_str | grep "Successive Byte" >/dev/null 2>&1
if [ $? -eq 0 ]; then
   spacing=1
else
   echo $spac_str | grep "32-bit" >/dev/null 2>&1
   if [ $? -eq 0 ]; then
      spacing=4
   else
      spacing=2
   fi
fi
echo "Register Spacing: $spacing" >>$ifout

biosver=`grep "Version: " $dmiout |head -n1 |cut -f2 -d':'`
echo "BIOS Version: $biosver" >>$ifout
exit 0