-
Notifications
You must be signed in to change notification settings - Fork 0
/
write-sdcard-fs
executable file
·103 lines (78 loc) · 2.1 KB
/
write-sdcard-fs
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
95
96
97
98
99
100
#!/bin/bash
NOT_SOURCED=0
test "X$(basename -- "$0")" = "Xwrite-sdcard-fs" && NOT_SOURCED=1
if [ $NOT_SOURCED = 1 ]; then
echo
echo "$(tput setaf 2)""Please source the script: source install-mix6000-linux""$(tput sgr 0)"
echo
exit 1
fi
echo
echo "$(tput setaf 2)""Please enter your sudo password:""$(tput sgr 0)"
sudo -p "" -v
CPWD=`pwd`
USERN=`whoami`
#Ubuntu mount paths differ
LSBVERSION=$(lsb_release -r)
VERION14=$(echo "$LSBVERSION" | awk '{if ($2 >= 14.04) print 1; else print 0}')
if [ $VERION14 -eq 1 ]; then
BOOT_PATH="/media/$USERN/BOOT"
FS_PATH="/media/$USERN/FS"
echo
echo "Ubuntu >=14.04 mount paths"
echo
else
BOOT_PATH="/media/BOOT"
FS_PATH="/media/FS"
echo
echo "Ubuntu <14.04 mount paths"
echo
fi
cd $CPWD/oe/deploy
cd $(ls | grep libc)
cd $(ls | grep image)
cd $(ls | grep sam)
OE_DEPLOY=`pwd`
SDCARD_DEV="mmcblk0"
read -p "Please reinsert the SDCARD (Remove and Insert to force update), then press enter"
echo
if [ ! -d $FS_PATH ]; then
echo
echo "$(tput setaf 2)""Filesystem (FS) partition not found under $FS_PATH""$(tput sgr 0)"
echo
echo "$(tput setaf 2)""Run: source sdcard-format""$(tput sgr 0)"
echo
cd $CPWD
return
fi
echo
echo "$(tput setaf 2)""Reformatting SDCARD filesystem partition...""$(tput sgr 0)"
echo
sudo umount $FS_PATH
sudo mkfs.ext4 /dev/${SDCARD_DEV}p2 -L FS
sudo tune2fs -O ^huge_file /dev/${SDCARD_DEV}p2
sudo fsck /dev/${SDCARD_DEV}p2
sync
read -p "Please reinsert the SDCARD (Remove and Insert to force update), then press enter"
if [ ! -d $FS_PATH ]; then
echo
echo "$(tput setaf 2)""Filesystem (FS) partition not found under $FS_PATH""$(tput sgr 0)"
echo
echo "$(tput setaf 2)""Run: source sdcard-format""$(tput sgr 0)"
echo
cd $CPWD
return
fi
echo
echo "$(tput setaf 2)""Copying files:""$(tput sgr 0)"
echo
cd $OE_DEPLOY
FS_IMAGE=$(ls | grep mix6000*tar.xz)
sudo tar xvJf $FS_IMAGE -C $FS_PATH
sync
echo
sudo umount $BOOT_PATH
sudo umount $FS_PATH
echo "$(tput setaf 2)""$(tput bold)""FS partition updated. Safe to remove SDCARD." "$(tput sgr 0)"
echo
cd $CPWD