Last active
November 27, 2019 18:12
-
-
Save morkai/ed2a240d6d426bbab8cf7233a4a3a082 to your computer and use it in GitHub Desktop.
Custom Ubuntu Image Builder scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
mount -t proc none /proc | |
mount -t sysfs none /sys | |
mount -t devpts none /dev/pts | |
export HOME=/root | |
export LC_ALL=C | |
dbus-uuidgen > /var/lib/dbus/machine-id | |
dpkg-divert --local --rename --add /sbin/initctl | |
ln -s /bin/true /sbin/initctl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
apt autoremove -y | |
apt clean -y | |
rm -rf /tmp/* ~/.bash_history /enter.sh /leave.sh | |
rm /var/lib/dbus/machine-id | |
rm /sbin/initctl | |
dpkg-divert --rename --remove /sbin/initctl | |
umount /proc || umount -lf /proc | |
umount /sys | |
umount /dev/pts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DIST=bionic | |
NAME=Custom | |
FILE=output.iso | |
KEY=$CUSTOM_ISO_KEY | |
PASS=$CUSTOM_ISO_PASSPHRASE | |
rm $FILE | |
cd extract | |
apt-ftparchive packages ./pool/main/ > dists/stable/main/binary-amd64/Packages | |
apt-ftparchive packages ./pool/restricted/ > dists/stable/restricted/binary-amd64/Packages | |
apt-ftparchive packages ./pool/extras/ > dists/stable/extras/binary-amd64/Packages | |
gzip -c dists/stable/main/binary-amd64/Packages | tee dists/stable/main/binary-amd64/Packages.gz > /dev/null | |
gzip -c dists/stable/restricted/binary-amd64/Packages | tee dists/stable/restricted/binary-amd64/Packages.gz > /dev/null | |
gzip -c dists/stable/extras/binary-amd64/Packages | tee dists/stable/extras/binary-amd64/Packages.gz > /dev/null | |
apt-ftparchive -c ../apt-ftparchive/release.conf generate ../apt-ftparchive/apt-ftparchive-deb.conf | |
apt-ftparchive -c ../apt-ftparchive/release.conf generate ../apt-ftparchive/apt-ftparchive-udeb.conf | |
apt-ftparchive -c ../apt-ftparchive/release.conf generate ../apt-ftparchive/apt-ftparchive-extras.conf | |
apt-ftparchive -c ../apt-ftparchive/release.conf release dists/stable > dists/stable/Release | |
rm dists/stable/Release.gpg | |
echo $PASS | gpg --pinentry-mode loopback --batch --yes --passphrase-fd 0 --default-key "$KEY" --output dists/stable/Release.gpg -ba dists/stable/Release | |
find . -type f -print0 | xargs -0 md5sum > md5sum.txt | |
cd ../ | |
umount edit/dev | |
chmod +w extract/install/filesystem.manifest | |
chroot edit dpkg-query -W --showformat='${Package} ${Version}\n' | tee extract/install/filesystem.manifest | |
rm extract/install/filesystem.squashfs extract/install/filesystem.size | |
printf $(du -sx --block-size=1 edit | cut -f1) | tee extract/install/filesystem.size | |
mksquashfs edit extract/install/filesystem.squashfs -b 1048576 | |
cd extract | |
rm md5sum.txt | |
find -type f -print0 | sudo xargs -0 md5sum | grep -v isolinux/boot.cat | tee md5sum.txt | |
genisoimage -D -r -V "$NAME" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../$FILE . | |
cd .. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cp /etc/resolv.conf edit/etc/ | |
cp _enter.sh edit/enter.sh | |
cp _leave.sh edit/leave.sh | |
chmod +x edit/enter.sh edit/leave.sh | |
mount --bind /dev/ edit/dev | |
chroot edit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment