-
Notifications
You must be signed in to change notification settings - Fork 1
/
installer.sh
executable file
·71 lines (53 loc) · 1.45 KB
/
installer.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
#!/bin/sh
clear
#### Root check
if [ `id -u` != 0 ]; then
echo "Please run installation process as root!"
exit
fi
#### Environment check
if [ "`cat /etc/issue | grep SOSBoot`" == "" ]; then
echo "Please run installation process from SOSBoot environment!"
exit
fi
#### Partition check
for partnum in `seq 1 7`
do
if [ ! -b /dev/mmcblk0p${partnum} ]; then
echo "Partition #${partnum} missing. Please remove external SD cards or flash factory partition scheme"
exit
fi
done
#### Files check
if [ ! -f /mnt/kernel.img ]; then
echo "Kernel image missing (make sure kernel.img file is present)"
exit
fi
if [ ! -f /mnt/rootfs.tgz ]; then
echo "System image missing (make sure rootfs.tgz file is present)"
exit
fi
#### Confirmation
echo "DO YOU REALLY WANT TO OVERWRITE CURRENT FIRMWARE?"
echo "All data will be erased and Ubuntu files will be copied."
echo "Press ENTER to start, or CTRL+C to reboot."
read
#### Main process
sleep 2
echo " --> Preparing swap storage..."
mkswap /dev/mmcblk0p4 > /dev/null
echo " --> Preparing root storage..."
mkfs.ext4 /dev/mmcblk0p7 > /dev/null
mkdir /target
mount -t ext4 /dev/mmcblk0p7 /target
echo " --> Copying system files..."
cd /target
gunzip < /mnt/rootfs.tgz | tar xpf -
echo " --> Copying kernel image..."
dd if=/mnt/kernel.img of=/dev/mmcblk0p2 > /dev/null
echo " --> Housekeeping..."
cd /
sync
umount /target
echo ""
echo "Done. Please remove all external media and then press Ctrl+Alt+Del to reboot."