summaryrefslogtreecommitdiff
path: root/RIKOR/flash-sila-bmc.in
blob: 43ad8b9785460d1a34585a76f7793662c8b7b99f (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/sh

CWD=`pwd`

IMAGEDIR=${HOME}/sila
mkdir -p ${IMAGEDIR}

BINDIR=${HOME}/bin
mkdir -p ${BINDIR}

IMAGE=${IMAGEDIR}/image-bmc

cat > ${BINDIR}/flash-sila <<EOF
#!/bin/sh

flashcp -v ${IMAGE} /dev/mtd0
EOF

chmod a+x ${BINDIR}/flash-sila

#
# Extract image:
# =============
#
sed -e '1,/^exit$/d' "$0" | tar -C "${IMAGEDIR}" -xf -

echo -n "Verifying Image..."
( cd ${IMAGEDIR}
  cat image-bmc.sig MANIFEST.sig publickey.sig > image-full
  verify=`openssl dgst -verify publickey -signature image-full.sig image-full`
  if [ "${verify}" != "Verified OK" ] ; then
    echo -e "\nERROR: Wrong Image signature.\n"
    exit 1
  else
    rm -f MANIFEST image-full publickey *.sig
  fi
)
echo -e "\t OK"

#
# Get current MAC Address:
# =======================
#
mac=`ifconfig eth0 | grep HWaddr | tr -s ' ' | cut -f5 -d' '`

#
# Umount mtd file systems:
# =======================
#
cd /

while [ 1 ] ; do
  umount /tmp/.rwfs 2>/dev/null 1>/dev/null
  ret=$?
  if [ $ret -eq 0 ] ; then
    break
  fi
  echo "Trying to umount rwfs partition..."
  sleep 0.1
done

while [ 1 ] ; do
  umount /var/sofs 2>/dev/null 1>/dev/null
  ret=$?
  if [ $ret -eq 0 ] ; then
    break
  fi
  echo "Trying to umount sofs partition..."
  sleep 0.1
done

sleep 0.5

#
# Flash image:
# ===========
#
echo "Flashing SILA Image..."

${BINDIR}/flash-sila

echo -e "\t OK"


#
# Save current MAC Address:
# ========================
#
fw_setenv ethaddr  ${mac}  2>/dev/null
fw_setenv eth0addr ${mac}  2>/dev/null

reboot -f

exit