-
Notifications
You must be signed in to change notification settings - Fork 24
/
install.sh
119 lines (90 loc) · 3.34 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
set -e
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
if [ -z "$1" ] ; then
echo "Usage: $0 /dev/sdX"
exit 1
fi
SDX="$1" # /dev/sdX
if [ ! -e "$1" ] ; then
echo "$1 does not exist"
fi
mntpart=$(mount | grep "$SDX" | head -n 1 | cut -d " " -f 3)
if [ "" != "$mntpart" ] ; then
if [ ! -e "$mntpart" ] ; then
echo "$mntpart does not exist"
fi
echo "$SDX is mounted to $mntpart and currently contains:"
ls "$mntpart"
fi
echo "Format this disk and install SystemImageKit?"
echo "Everything on all partitions of this disk will be deleted!"
read -p "Are you sure? " -n 1 -r
echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 0
fi
read -p "Are you really sure? " -n 1 -r
echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 0
fi
echo "Continuing..."
# On the desktop, stop automatic mounting of disks
systemctl stop udisks2.service
umount $SDX* || true
# Nuke any previous partitioning scheme; otherwise the next
# step may fail if the disk was previously partitioned differently
sudo dd if=/dev/zero of=$SDX bs=2M count=1
# Make one partition
echo 'start=2048, type=0b' | sfdisk $SDX
# Make first partition bootable
sfdisk -A $SDX 1
sleep 1
# Format
mkfs.vfat "$SDX"1
# Mount
mount "$SDX"1 /mnt/
# Install SystemImageKit
apt-get -y install git grub-pc-bin grub-common grub-efi-amd64-bin
git clone https://github.com/probonopd/SystemImageKit.git /mnt
# Clear the gap between the boot sector and the first partition
# to prevent from GRUB having issues being installed
dd if=/dev/zero of=$SDX seek=1 count=2047
# Install bootloader for PC
# Tested with grub-install (GRUB) 2.02~beta2-9 from Ubuntu 14.04 LTS Trusty Tahr
# and with grub2-install (GRUB) 2.02~beta2 from Fedora 22 (Rawhide)
grub-install --recheck --boot-directory=/mnt/boot/ $SDX || true # Ubuntu
grub2-install --recheck --boot-directory=/mnt/boot/ $SDX || true # Fedora
# Install bootloader for Mac
mkdir -p /mnt/boot/efi
sudo grub-install --recheck --no-nvram --target=x86_64-efi --efi-directory=/mnt/boot/EFI --boot-directory=/mnt/boot/ "$SDX"1 || true
mkdir -p /mnt/EFI
mv /mnt/boot/EFI/BOOT /mnt/EFI/BOOT
# Generate additional initrd (gets loaded in addition to the one on the ISO)
/mnt/boot/iso/additional-initramfs/generate
# Download Starter ISO
if [ -e "/isodevice/boot/iso/xubuntu-18.04-desktop-amd64.iso" ] ; then
cp "/isodevice/boot/iso/xubuntu-18.04-desktop-amd64.iso" /mnt/boot/iso/
else
wget -c "http://cdimage.ubuntu.com/xubuntu/releases/18.04/release/xubuntu-18.04-desktop-amd64.iso" -O /mnt/boot/iso/xubuntu-18.04-desktop-amd64.iso
fi
# Download Starter Applications
mkdir -p /mnt/Applications # This is where AppImageKit picks them up
FILENAME=$(wget -q "https://dl.bintray.com/probono/AppImages/" -O - | grep Firefox-[0-9] | grep -v zsync | cut -d ":" -f 2 | cut -d '"' -f 1 | sort -Vr | head -n 1)
wget -c "https://dl.bintray.com/probono/AppImages/$FILENAME" -O "/mnt/Applications/$FILENAME"
# Configure bootloader
/mnt/boot/bin/detect
# Create and install ExtensionImages, e.g., for Adobe Flash Player and proprietary firmware
bash /mnt/boot/bin/generate-appimaged-extension
bash /mnt/boot/bin/generate-b43firmware-extension
# bash /mnt/boot/bin/generate-dymo-extension
umount /mnt
# The disk should now be bootable
# On the desktop, stop automatic mounting of disks
systemctl start udisks2.service