-
Notifications
You must be signed in to change notification settings - Fork 9
/
distro_build_script.sh
164 lines (131 loc) · 4 KB
/
distro_build_script.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
sudo su
add-apt-repository universe
DEBIAN_FRONTEND=noninteractive apt-get install -y \
debootstrap \
squashfs-tools \
xorriso \
grub-pc-bin \
grub-efi-amd64-bin \
mtools
rm -r $HOME/LIVE_BOOT
mkdir $HOME/LIVE_BOOT
debootstrap \
--arch=i386 \
--variant=minbase \
stretch \
$HOME/LIVE_BOOT/chroot \
http://ftp.ch.debian.org/debian/
wget https://github.com/airgap-it/airgap-vault/releases/download/v1.3.1/airgap-vault_1.3.1_i386.deb
mv airgap-vault_1.3.1_i386.deb $HOME/LIVE_BOOT/chroot/
cat << EOF >$HOME/LIVE_BOOT/chroot/chroot.sh
echo "airgapdistro" > /etc/hostname;
echo "airgapdistro 127.0.0.1" > /etc/hosts;
DEBIAN_FRONTEND=noninteractive apt-get update;
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
linux-image-686 \
live-boot \
systemd-sysv\
xserver-xorg-core \
xserver-xorg \
xinit \
libasound2 \
gconf2 \
gconf-service \
libnotify4 \
libappindicator1 \
libxtst6 \
libnss3 \
libxss1 \
libgtk-3-0 \
libv4l-0;
dpkg -i /airgap-vault_1.3.1_i386.deb;
rm /airgap-vault_1.3.1_i386.deb;
DEBIAN_FRONTEND=noninteractive apt --fix-broken -y install;
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends;
DEBIAN_FRONTEND=noninteractive apt-get purge aptitude
DEBIAN_FRONTEND=noninteractive apt-get -y clean autoclean;
echo "exec airgap-vault" > /root/.xinitrc;
chmod +x /root/.xinitrc;
cat << EOFCHROOT > /etc/systemd/system/x11.service
[Service]
ExecStart=/bin/su root -l -c xinit -- VT08
[Install]
WantedBy=multi-user.target
EOFCHROOT
systemctl enable x11
rm -rf /lib/modules/**/kernel/net
rm -rf /var/lib/{apt,dpkg,cache,log}/
rm -rf /usr/share/man
rm -rf /usr/share/doc
rm -rf /usr/share/icons
rm -rf /usr/share/locale
EOF
chmod +x $HOME/LIVE_BOOT/chroot/chroot.sh
chroot $HOME/LIVE_BOOT/chroot /chroot.sh
rm -r $HOME/LIVE_BOOT/{scratch,image/live}
mkdir -p $HOME/LIVE_BOOT/{scratch,image/live}
mksquashfs \
$HOME/LIVE_BOOT/chroot \
$HOME/LIVE_BOOT/image/live/filesystem.squashfs \
-e boot;
cp $HOME/LIVE_BOOT/chroot/boot/vmlinuz-* \
$HOME/LIVE_BOOT/image/vmlinuz && \
cp $HOME/LIVE_BOOT/chroot/boot/initrd.img-* \
$HOME/LIVE_BOOT/image/initrd
cat << EOF >$HOME/LIVE_BOOT/scratch/grub.cfg
search --set=root --file /DEBIAN_CUSTOM
set default="0"
set timeout=0
menuentry "AirGap Distro" {
linux /vmlinuz boot=live quiet nomodeset
initrd /initrd
}
EOF
touch $HOME/LIVE_BOOT/image/DEBIAN_CUSTOM
grub-mkstandalone \
--format=x86_64-efi \
--output=$HOME/LIVE_BOOT/scratch/bootx64.efi \
--locales="" \
--fonts="" \
"boot/grub/grub.cfg=$HOME/LIVE_BOOT/scratch/grub.cfg";
(cd $HOME/LIVE_BOOT/scratch && \
dd if=/dev/zero of=efiboot.img bs=1M count=10 && \
mkfs.vfat efiboot.img && \
mmd -i efiboot.img efi efi/boot && \
mcopy -i efiboot.img ./bootx64.efi ::efi/boot/
)
grub-mkstandalone \
--format=i386-pc \
--output=$HOME/LIVE_BOOT/scratch/core.img \
--install-modules="linux normal iso9660 biosdisk memdisk search tar ls" \
--modules="linux normal iso9660 biosdisk search" \
--locales="" \
--fonts="" \
"boot/grub/grub.cfg=$HOME/LIVE_BOOT/scratch/grub.cfg"
cat \
/usr/lib/grub/i386-pc/cdboot.img \
$HOME/LIVE_BOOT/scratch/core.img \
> $HOME/LIVE_BOOT/scratch/bios.img
sleep 10
xorriso \
-as mkisofs \
-iso-level 3 \
-full-iso9660-filenames \
-volid "DEBIAN_CUSTOM" \
-eltorito-boot \
boot/grub/bios.img \
-no-emul-boot \
-boot-load-size 4 \
-boot-info-table \
--eltorito-catalog boot/grub/boot.cat \
--grub2-boot-info \
--grub2-mbr /usr/lib/grub/i386-pc/boot_hybrid.img \
-eltorito-alt-boot \
-e EFI/efiboot.img \
-no-emul-boot \
-append_partition 2 0xef ${HOME}/LIVE_BOOT/scratch/efiboot.img \
-output "/tmp/airgap-vault-distro.iso" \
-graft-points \
"${HOME}/LIVE_BOOT/image" \
/boot/grub/bios.img=$HOME/LIVE_BOOT/scratch/bios.img \
/EFI/efiboot.img=$HOME/LIVE_BOOT/scratch/efiboot.img