2021-01-22 16:45:43 +01:00
|
|
|
#!/bin/bash
|
|
|
|
set -eE
|
|
|
|
|
|
|
|
function clean() {
|
2021-04-16 11:57:56 +02:00
|
|
|
echo "==== CLEAN ===="
|
2021-01-22 16:45:43 +01:00
|
|
|
sudo umount "$WORKDIR/squashfs" || :
|
|
|
|
sudo umount /tmp/livecd || :
|
|
|
|
}
|
|
|
|
|
|
|
|
trap clean ERR
|
|
|
|
|
|
|
|
SPATH=$(cd $(dirname $0) && pwd)
|
|
|
|
if [ -z $1 ]; then
|
|
|
|
echo "Usage: prepare.sh <iso_path>"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
full_iso=$1
|
|
|
|
iso_wo_ext=${full_iso##*/}
|
|
|
|
iso_wo_ext=${iso_wo_ext%.iso}
|
|
|
|
|
|
|
|
WORKDIR="$SPATH/$iso_wo_ext"
|
|
|
|
|
|
|
|
echo "==== Prepare CD ===="
|
|
|
|
mkdir /tmp/livecd || :
|
2022-09-13 19:56:29 +02:00
|
|
|
fuseiso "$1" /tmp/livecd
|
2021-01-22 16:45:43 +01:00
|
|
|
|
|
|
|
mkdir -p "$WORKDIR"
|
2022-09-13 19:56:29 +02:00
|
|
|
# rsync --exclude=/casper/filesystem.squashfs -a /tmp/livecd/ "$WORKDIR/cd"
|
|
|
|
mkdir "$WORKDIR/squashfs"
|
|
|
|
squashfuse /tmp/livecd/casper/filesystem.squashfs "$WORKDIR/squashfs/"
|
2021-01-22 16:45:43 +01:00
|
|
|
|
2022-09-13 19:56:29 +02:00
|
|
|
echo "==== Copy squashfs contents to $WORKDIR/squashfs/squashfs-root ===="
|
|
|
|
nprocs=$(($(nproc)-1)) # leave 1 proc for use
|
|
|
|
unsquashfs -p$nprocs -no-xattrs /tmp/livecd/casper/filesystem.squashfs
|
2021-01-22 16:45:43 +01:00
|
|
|
|
|
|
|
# network access
|
2022-09-13 19:56:29 +02:00
|
|
|
cp /etc/resolv.conf /etc/hosts "$WORKDIR/squashfs/squashfs-root/etc/"
|
2021-01-22 16:45:43 +01:00
|
|
|
|
|
|
|
# mount proc, sys, opens a shell (for changes), and clean everything after
|
|
|
|
echo "==== CHROOT ===="
|
2022-09-13 19:56:29 +02:00
|
|
|
cat "$SPATH/tasks.sh" | chroot "$WORKDIR/squashfs/squashfs-root" /bin/bash
|
2021-01-22 16:45:43 +01:00
|
|
|
|
2021-01-26 18:58:12 +01:00
|
|
|
echo "==== Copy custom background ===="
|
2022-09-13 19:56:29 +02:00
|
|
|
sudo cp background/sele_ring_lis67.jpg "$WORKDIR/squashfs/squashfs-root/usr/share/backgrounds/linuxmint/sele_ring_lis67.jpg"
|
2021-01-26 18:58:12 +01:00
|
|
|
|
|
|
|
echo "==== Copy Firefox settings ===="
|
2022-09-13 19:56:29 +02:00
|
|
|
sudo cp "$SPATH/firefox/distribution.ini" "$WORKDIR/squashfs/squashfs-root/usr/lib/firefox/distribution/distribution.ini"
|
|
|
|
sudo cp "$SPATH/firefox/distribution.ini" "$WORKDIR/squashfs/squashfs-root/usr/share/ubuntu-system-adjustments/firefox/distribution.ini"
|
2021-01-26 18:58:12 +01:00
|
|
|
|
2022-09-13 19:56:29 +02:00
|
|
|
sudo cp "$SPATH/firefox/vendor-firefox.js" "$WORKDIR/squashfs/squashfs-root/usr/lib/firefox/browser/defaults/preferences/vendor-firefox.js"
|
|
|
|
sudo cp "$SPATH/firefox/vendor-firefox.js" "$WORKDIR/squashfs/squashfs-root/usr/share/ubuntu-system-adjustments/firefox/firefox.js"
|
2021-01-26 18:58:12 +01:00
|
|
|
|
|
|
|
echo "==== Disable Yahoo, enable Startpage on Firefox ===="
|
|
|
|
cd "$SPATH/firefox"
|
2022-09-13 19:56:29 +02:00
|
|
|
sudo zip "$WORKDIR/squashfs/squashfs-root/usr/lib/firefox/browser/omni.ja" defaults/settings/main/search-config.json
|
2021-01-26 18:58:12 +01:00
|
|
|
cd -
|
|
|
|
|
|
|
|
echo "==== Install extensions ===="
|
2022-09-13 19:56:29 +02:00
|
|
|
sudo cp "$SPATH/firefox/extensions/"* "$WORKDIR/squashfs/squashfs-root/usr/lib/firefox/distribution/extensions/"
|
2021-01-26 18:58:12 +01:00
|
|
|
|
2021-01-22 16:45:43 +01:00
|
|
|
echo "==== Mod ISOLINUX (BIOS) AND GRUB (EFI) ===="
|
2021-04-16 11:57:56 +02:00
|
|
|
if [[ -d isolinux ]]; then
|
|
|
|
# isolinux
|
|
|
|
chmod -R +w "$WORKDIR/cd/isolinux"
|
|
|
|
cp isolinux/* "$WORKDIR/cd/isolinux/"
|
|
|
|
fi
|
|
|
|
if [[ -d grub ]]; then
|
|
|
|
# grub
|
|
|
|
chmod -R +w "$WORKDIR/cd/boot/grub"
|
|
|
|
cp grub/* "$WORKDIR/cd/boot/grub/"
|
|
|
|
fi
|
2021-01-22 16:45:43 +01:00
|
|
|
|
|
|
|
# setup iso
|
|
|
|
echo "==== Setup ISO ===="
|
|
|
|
chmod +w "$WORKDIR/cd/casper/filesystem.manifest"
|
2022-09-13 19:56:29 +02:00
|
|
|
sudo chroot "$WORKDIR/squashfs/squashfs-root" dpkg-query -W --showformat='${Package} ${Version}\n' > "$WORKDIR/cd/casper/filesystem.manifest"
|
2021-01-22 16:45:43 +01:00
|
|
|
sudo cp "$WORKDIR/cd/casper/filesystem.manifest" "$WORKDIR/cd/casper/filesystem.manifest-desktop"
|
2022-09-13 19:56:29 +02:00
|
|
|
sudo mksquashfs "$WORKDIR/squashfs/squashfs-root" "$WORKDIR/cd/casper/filesystem.squashfs"
|
2021-01-22 16:45:43 +01:00
|
|
|
sudo rm "$WORKDIR/cd/MD5SUMS"
|
|
|
|
sudo chmod +w "$WORKDIR/cd"
|
|
|
|
sudo bash -c 'cd '"$WORKDIR"'/cd && find . -type f -exec md5sum {} +' > "$WORKDIR"/cd/MD5SUMS
|
|
|
|
|
|
|
|
# create iso
|
|
|
|
echo "==== Create ISO ===="
|
|
|
|
cd "$WORKDIR/cd"
|
|
|
|
# create a DVD-burnable ISO with BIOS (isolinux) and EFI (grub) support
|
|
|
|
sudo mkisofs -U -A "$iso_wo_ext-LIS67" -V "$iso_wo_ext-LIS67" -volset "$iso_wo_ext-LIS67" -J -joliet-long -r -v -T -o "$WORKDIR/$iso_wo_ext-lis67.iso" -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -e boot/grub/efi.img -no-emul-boot .
|
|
|
|
|
|
|
|
# convert iso to a bootable USB drive iso
|
|
|
|
sudo isohybrid --uefi "$WORKDIR/$iso_wo_ext-lis67.iso"
|
|
|
|
|
|
|
|
# umount & clean
|
|
|
|
echo "==== Clean ===="
|
|
|
|
sudo umount "$WORKDIR/squashfs"
|
|
|
|
sudo umount /tmp/livecd
|
|
|
|
sudo chown -R $USER: "$WORKDIR"
|
|
|
|
|
|
|
|
echo "Final ISO: $WORKDIR/$iso_wo_ext-lis67.iso"
|
|
|
|
echo "Done"
|