]> git.openstreetmap.org Git - chef.git/blob - cookbooks/devices/files/default/fixeep-82574_83.sh
Qualify property names
[chef.git] / cookbooks / devices / files / default / fixeep-82574_83.sh
1 #!/bin/bash
2
3 if [ -z "$1" ]; then
4         echo "Usage: $0 \<interface\>"
5         echo "       i.e. $0 eth0"
6         exit 1
7 fi
8
9 if ! ifconfig $1 > /dev/null; then
10         exit 1
11 fi
12
13 bdf=$(ethtool -i $1 | grep "bus-info:" | awk '{print $2}')
14 dev=$(lspci -s $bdf -x | grep "00: 86 80" | awk '{print "0x"$5$4$3$2}')
15
16 case $dev in
17         0x10d38086)
18                 echo "$1: is a \"82574L Gigabit Network Connection\""
19                 ;;
20         0x10f68086)
21                 echo "$1: is a \"82574L Gigabit Network Connection\""
22                 ;;
23         0x150c8086)
24                 echo "$1: is a \"82583V Gigabit Network Connection\""
25                 ;;
26         *)
27                 echo "No appropriate hardware found for this fixup"
28                 exit 1
29                 ;;
30 esac
31
32 echo "This fixup is applicable to your hardware"
33
34 var=$(ethtool -e $1 | grep 0x0010 | awk '{print $16}')
35 new=$(echo ${var:0:1}`echo ${var:1} | tr '014589bc' '2367abef'`)
36
37 if [ ${var:0:1}${var:1} == $new ]; then
38         echo "Your eeprom is up to date, no changes were made"
39         exit 2
40 fi
41
42 echo "executing command: ethtool -E $1 magic $dev offset 0x1e value 0x$new"
43 ethtool -E $1 magic $dev offset 0x1e value 0x$new
44
45 echo "Change made. You *MUST* reboot your machine before changes take effect!"