-
Notifications
You must be signed in to change notification settings - Fork 1
/
get-eeprom.sh
executable file
·52 lines (47 loc) · 925 Bytes
/
get-eeprom.sh
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
#!/bin/bash
W1_DIR="/sys/bus/w1/devices/w1_bus_master1"
tmpDir="/tmp/eepromWriter"
dirs=$W1_DIR/23-*/
missingEeprom=true
for dir in $dirs
do
if [ -d $dir ]; then
(( itterationCount++ ))
{
cp $dir"eeprom" "/tmp/test.bin"
} && {
{
missingEeprom=false
{
eepromID=$(xxd -p $dir"id")
} && {
if [ -d $tmpDir ]; then
rm -rf $tmpDir
fi
mkdir $tmpDir
echo "$eepromID" > $tmpDir/uid
(dd conv=swab < $tmpDir/uid > $tmpDir/swab_uid) > /dev/null 2>&1
swabID=$(cat $tmpDir/swab_uid)
revID=$(echo $swabID|rev)
echo "$revID" > $tmpDir/rev_uid
binaryName="original-"$eepromID".bin"
{
cp $dir"eeprom" $tmpDir"/"$binaryName
} || {
missingEeprom=true
}
}
} || {
missingEeprom=true
}
}
fi
done
if [ "$missingEeprom" = true ]; then
echo "No EEPROM found."
if [ -d $tmpDir ]; then
rm -rf $tmpDir
fi
else
ls /tmp/eepromWriter
fi