forked from eduardofilo/RG350_adam_image
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flash.sh
executable file
·72 lines (59 loc) · 1.46 KB
/
flash.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
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
# BEGIN PARAMETER ZONE
SD_DEV=/dev/mmcblk0
SD_P1=${SD_DEV}p1
SD_P2=${SD_DEV}p2
# END PARAMETER ZONE
DIRECTORY=$(pwd)
# Check if we're root and re-execute if we're not.
rootcheck () {
if [ $(id -u) != "0" ]
then
sudo "$0" "$@"
exit $?
fi
}
if [ $# -ne 1 ] ; then
echo "usage: ./flash.sh <v>"
exit 1
fi
if [ ! -b ${SD_DEV} ] ; then
echo "Dev ${SD_DEV} not found"
exit 1
fi
rootcheck "${@}"
echo "Unmounting P1 and P2"
umount ${SD_P1} 2> /dev/null
umount ${SD_P2} 2> /dev/null
echo "Flashing"
if [ -f releases/adam_v${1}.img.gz ] ; then
gunzip releases/adam_v${1}.img.gz -c | dd of=${SD_DEV} bs=2M status=progress conv=fsync
else
xzcat releases/adam_v${1}.img.xz | dd of=${SD_DEV} bs=2M status=progress conv=fsync
fi
sync
sleep 2
echo "Remounting P1 and P2"
mkdir ${DIRECTORY}/mnt_p1
mount -t vfat ${SD_P1} ${DIRECTORY}/mnt_p1
mkdir ${DIRECTORY}/mnt_p2
mount -t ext4 ${SD_P2} ${DIRECTORY}/mnt_p2
sync
sleep 1
echo "Installing RG280V kernel"
cp ${DIRECTORY}/mnt_p1/rg280v/* ${DIRECTORY}/mnt_p1
sync
echo "Erasing .resize_me and changing shadow"
if [ -f ${DIRECTORY}/mnt_p2/.resize_me ] ; then
rm ${DIRECTORY}/mnt_p2/.resize_me
fi
cp ${DIRECTORY}/assets/shadow_without_pwd ${DIRECTORY}/mnt_p2/local/etc/shadow
chown 0:0 ${DIRECTORY}/mnt_p2/local/etc/shadow
chmod 600 ${DIRECTORY}/mnt_p2/local/etc/shadow
sync
sleep 1
echo "Final unmount"
umount ${SD_P1}
umount ${SD_P2}
rmdir ${DIRECTORY}/mnt_p1
rmdir ${DIRECTORY}/mnt_p2