forked from raidzero/RZrecovery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflash_img
executable file
·42 lines (37 loc) · 1.15 KB
/
flash_img
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
#!/sbin/sh
PARTITION=$1
IMAGE=$2
if [ "$PARTITION" == "boot" ]; then
if [ `cat /etc/recovery.fstab | grep boot | egrep -v "("fota"|"bootloader")" | awk '{print$2}'` == "mtd" ]; then
BOOT_DEVICE="/dev/mtd/"`cat /proc/mtd | grep boot | egrep -v "("fota"|"bootloader")" | awk '{print$1}' | sed 's/://g'`
else
BOOT_DEVICE=`cat /etc/recovery.fstab | grep boot | egrep -v "("bootloader"|"fota_boot")" | awk '{print$3}'`
fi
flash_image $PARTITION $IMAGE
FI_RET=$?
if [ $FI_RET -eq 0 ]; then
exit 101
else
dd if=$IMAGE of=$BOOT_DEVICE
DD_RET=$?
[ $DD_RET -ne 0 ] exit 102
[ $DD_RET -eq 0 ] exit 103
fi
fi
if [ "$PARTITION" == "recovery" ]; then
if [ `cat /etc/recovery.fstab | grep recovery | awk '{print$2}'` == "mtd" ]; then
RECOVERY_DEVICE="/dev/mtd/"`cat /proc/mtd | grep recovery | awk '{print$1}' | sed 's/://g'`
else
RECOVERY_DEVICE=`cat /etc/recovery.fstab | grep recovery | awk '{print$3}'`
fi
flash_image $PARTITION $IMAGE
FI_RET=$?
if [ $FI_RET -eq 0 ]; then
exit 201
else
dd if=$IMAGE of=$RECOVERY_DEVICE
DD_RET=$?
[ $DD_RET -ne 0 ] && exit 202
[ $DD_RET -eq 0 ] && exit 203
fi
fi