forked from raidzero/RZrecovery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcwm-restore.sh
executable file
·62 lines (54 loc) · 1.44 KB
/
cwm-restore.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
53
54
55
56
57
58
59
60
61
#!/sbin/sh
#cwm nandroid restore tool, should work on tar and img nandroids
. /ui_commands.sh
NAND_NAME=$1
STORAGE_ROOT=$2
NAND_DIR="$STORAGE_ROOT/clockworkmod/backup/$NAND_NAME"
pipeline() {
echo "* show_indeterminate_progress"
awk "NR==1 {print \"* ptotal $1\"} {print \"* pcur \" NR}"
echo "* reset_progress"
}
cd $NAND_DIR
system=`find . -name "*system*"`
data=`find . -name "*data*"`
boot=`find . -name "*boot*"`
secure=`find . -name "*android_secure*"`
cache=`find . -name "*cache*"`
for image in system data boot secure cache; do
image_dir=$image
dest_dir=$image
image=`find . -name "*$image*"`
if [ "$image_dir" == "secure" ]; then
dest_dir=.android_secure
fi
if [ ! -z "$image" ]; then
IMAGE_IS_TAR=`echo $image | grep "\.tar" | wc -l`
ui_print "Processing $image..."
if [ $IMAGE_IS_TAR -ne 0 ]; then
ui_print "Unpacking..."
PTOTAL=$(($(tar tf $image | wc -l)-2))
if [ "$image_dir" == "secure" ]; then
dest_dir=$STORAGE_ROOT/.android_secure
else
dest_dir="/$dest_dir"
fi
rm -rf $dest_dir/*
tar xvf $NAND_DIR/$image -C $dest_dir | pipeline $PTOTAL
else
dest_dir="/boot"
format $dest_dir
cd $dest_dir
unyaffs $NAND_DIR/boot.img
RTN=`find . | grep -v "boot.img" | wc -l`
if [ $RTN -le 1 ]; then
flash_img $dest_dir $NAND_DIR/boot.img
fi
fi
fi
cd $NAND_DIR
#reclaim any cached ram and write all changes to disk
sync
echo 3 > /proc/sys/vm/drop_caches
done
ui_print "Restore complete!"