-
Notifications
You must be signed in to change notification settings - Fork 0
/
habittiBuilder.sh
60 lines (60 loc) · 4.29 KB
/
habittiBuilder.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
#Download debian live image if not already downloaded
if [ -e debian.iso ]; then
echo "debian.iso exists, skipping download."
else
wget https://get.debian.org/images/archive/11.6.0-live/amd64/iso-hybrid/debian-live-11.6.0-amd64-gnome.iso -O debian.iso
fi
#Check if abitti filesystem exists
if [ -e filesystem.squashfs ]; then
echo "filesystem.squashfs exists, proceeding."
else
echo "filesystem.squashfs does not exist. Please extract it from the Abitti image provided by YTL."
exit 1
fi
#Unsquashfs abitti
sudo unsquashfs ./filesystem.squashfs
sudo rm ./filesystem.squashfs
#Extract debian iso
sudo xorriso -osirrox on -indev debian.iso -extract / debian
#Required for system to boot correctly (idk wtf this does)
sudo cp -r ./5.10.0-21-amd64 ./squashfs-root/lib/modules/
sudo cp -r ./5.10.0-20-amd64 ./squashfs-root/lib/modules/
#Allow dhcp
sudo sed -i 's/also require swap-server;//' ./squashfs-root/etc/dhcp/dhclient.conf
#Remove firewall
sudo find ./squashfs-root/etc/digabi/firewall.d -type f -exec sed -i 's/DROP/ACCEPT/g' {} +
sudo sed -i 's/DROP/ACCEPT/g' ./squashfs-root/lib/live/config/0001-iptables-set-drop-policy
sudo sed -i 's/^/#/' ./squashfs-root/usr/local/sbin/digabi-firewall-check
sudo sed -i '/REJECT/d' ./squashfs-root/etc/digabi/firewall.d/9000-log-and-reject.v4.conf
#Change release name to distinguish from unmodified Abitti
sudo sed -i 's/ABITTI/HABITTI/' ./squashfs-root/etc/digabios-release
#Add root user with the name "habitti"
echo "\nhabitti::0:0:root:/root:/bin/bash" | sudo tee -a ./squashfs-root/etc/passwd > /dev/null
#Add user digabi to sudoers (default abitti user)
echo "\ndigabi ALL=(ALL:ALL) ALL" | sudo tee -a ./squashfs-root/etc/sudoers > /dev/null
#Allow user digabi to use terminal
sudo sed -i 's/false/bash/' ./squashfs-root/lib/live/config/0031-lock-user-account
sudo chmod o+rx ./squashfs-root/usr/bin/terminator
#Replace apt sources with the default debian sources
echo "deb http://deb.debian.org/debian bullseye main contrib non-free\ndeb-src http://deb.debian.org/debian bullseye main contrib non-free\ndeb http://deb.debian.org/debian-security/ bullseye-security main contrib non-free\ndeb-src http://deb.debian.org/debian-security/ bullseye-security main contrib non-free\ndeb http://deb.debian.org/debian bullseye-updates main contrib non-free\ndeb-src http://deb.debian.org/debian bullseye-updates main contrib non-free" | sudo tee ./squashfs-root/etc/apt/sources.list > /dev/null
#Disable mount backup check
sudo sed -i 's/^/#/' ./squashfs-root/usr/local/sbin/mount-backup
#Create modified squashfs filesystem
sudo mksquashfs ./squashfs-root ./filesystem.squashfs
#Move squashfs filesystem to debian folder
sudo mv ./filesystem.squashfs ./debian/live
#Modify grub config
sudo sed -i '13,30d' ./debian/boot/grub/grub.cfg
sudo sed -i 's/menuentry "Debian GNU\/Linux Live (kernel 5.10.0-20-amd64)" {/menuentry "hAbitti" --unrestricted {/' ./debian/boot/grub/grub.cfg
sudo sed -i 's/linux \/live\/vmlinuz-5.10.0-20-amd64 boot=live components splash quiet "${loopback}"/linux \/live\/vmlinuz-5.10.0-20-amd64 digabi=grub boot=live components nosplash debug config net.ifnames=0 union=overlay modules_load=i2c_hid,i2c-hid-acpi live-media-timeout=5 live-media-path=\/live panic=0 digabidata modprobe.blacklist=b44,b43,b43legacy,ssb,brcmsmac,bcma "${loopback}"/' ./debian/boot/grub/grub.cfg
#Modify isolinux menu.cfg
sudo sed -i 's/SAY "Booting Debian GNU\/Linux Live (kernel 5.10.0-20-amd64)..."/SAY "Booting hAbitti"/' ./debian/isolinux/menu.cfg
sudo sed -i 's/APPEND initrd=\/live\/initrd.img-5.10.0-20-amd64 boot=live components splash quiet/APPEND initrd=\/live\/initrd.img-5.10.0-20-amd64 boot=live components nosplash debug/' ./debian/isolinux/menu.cfg
sudo sed -i 's/Debian GNU\/Linux Live (kernel 5.10.0-20-amd64)/hAbitti/' ./debian/isolinux/menu.cfg
sudo sed -i 's/MENU title Main Menu/MENU title hAbitti/' ./debian/isolinux/menu.cfg
sudo sed -i '8,410d' ./debian/isolinux/menu.cfg
#Modify isolinux stdmenu.cfg
sudo sed -i 's/menu background splash.png/menu background ""/' ./debian/isolinux/stdmenu.cfg
#Build iso
sudo xorriso -outdev ./abitti-mod.iso -volid "d-live 11.6.0 st amd64" -padding 0 -compliance no_emul_toc -map ./debian / -chmod 0755 / -- -boot_image isolinux dir=/isolinux -boot_image any next -boot_image any efi_path=boot/grub/efi.img -boot_image isolinux partition_entry=gpt_basdat
echo -e "\e[32;1mdone\e[0m"