-
Notifications
You must be signed in to change notification settings - Fork 4
/
install.sh
executable file
·91 lines (71 loc) · 2.43 KB
/
install.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
# Default value used if no argument is provided
dev=sda
cat banner.txt
if [ $# -eq 1 ]
then
dev=$1
fi
echo "WARNING: Proceeding will result in the loss of ALL data on device /dev/$dev !! "
read -p "Are you sure you want to proceed [y,N]? " -r
echo
if [[ ! $REPLY =~ ^[yY]$ ]]
then
echo "Leaving flash process before any harm was done"
echo "Usage install.sh <device_name>"
echo
exit 0
fi
if mount | grep /dev/${dev}1 > /dev/null; then
echo "Removing mount to /dev/${dev}1"
umount /dev/${dev}1
fi
armbian=Armbian_5.44.180514_Pine64_Debian_stretch_next_4.14.40
centos=CentOS-7-aarch64-rootfs-7.4.1708.tar.xz
micro_sd_size=7500
gitdir=`pwd`
if [ ! -f $gitdir/armbian/${armbian}.img ]; then
cd $gitdir/armbian
if [ ! -f $gitdir/armbian/${armbian}.7z ]; then
wget https://github.com/Project31/centos-pine64/releases/download/vArmbian.5.44/${armbian}.7z
fi
p7zip -d ${armbian}.7z
fi
cd $gitdir
if [ ! -f $gitdir/centos/${centos} ]; then
cd centos
wget https://github.com/Project31/centos-pine64/releases/download/vCentos7.4.1708/$centos
fi
echo "Flashing Armbian to '$dev' ..."
dd bs=1MB if=armbian/${armbian}.img of=/dev/$dev status=progress
sync
echo Resize ${dev}1 partition
echo "resizepart 1 ${micro_sd_size}\n\q\n" | parted /dev/$dev
sync
resize2fs /dev/${dev}1
sync
echo "Mounting rootfs filesystem"
mount /dev/${dev}1 ./rootfs
echo "Saving Armbian UBoot and Kernel ..."
mkdir -p $gitdir/rootfs/armbian/lib
cp -r $gitdir/rootfs/boot $gitdir/rootfs/armbian/
cp -r $gitdir/rootfs/lib/firmware $gitdir/rootfs/armbian/lib
cp -r $gitdir/rootfs/lib/modules $gitdir/rootfs/armbian/lib
cd $gitdir/rootfs
shopt -s extglob
rm -fr !("armbian")
echo "Extracting CentOS-7-aarch64-rootfs-7.4.1708..."
tar --numeric-owner -xpf $gitdir/centos/CentOS-7-aarch64-rootfs-7.4.1708.tar.xz
echo "Replacing CentOS kernel artifacts with Armbian"
rm -fr ./boot ./lib/modules ./lib/firmware
mv $gitdir/rootfs/armbian/boot .
mv $gitdir/rootfs/armbian/lib/modules $gitdir/rootfs/lib/
mv $gitdir/rootfs/armbian/lib/firmware $gitdir/rootfs/lib
rm -fr $gitdir/rootfs/armbian
echo "Adding /etc/fstab"
echo "UUID=ccdc39df-5dee-41fb-8f85-c68ee54dcd94 / ext4 defaults 0 0" > $gitdir/rootfs/etc/fstab
cp $gitdir/finish-centos-install.sh $gitdir/rootfs/root/
sync
umount $gitdir/rootfs
echo "Flashing complete!"
echo "Please boot from the microSD card, login using root/centos and run 'sh /root/finish-centos-install.sh' to complete the installation"