#!/bin/bash ubuntuiso=ubuntu-9.04-desktop-amd64.iso customiso=ubuntu-9.04-custom-amd64.iso kernel=2.6.28-11-generic clear echo Customize Ubuntu LiveCD echo echo Script by: Stephen Clark echo Based on documentation found at: echo https://help.ubuntu.com/community/LiveCDCustomization echo echo "For customizing Ubuntu 9.04 (Jaunty)" echo echo Press Ctrl C at any time to quit echo echo -n "Loading squashfs module... " modprobe squashfs echo Done echo echo -n "Extract iso contents? y/[n] " read ua if [ "$ua" = "y" ]; then if [ -e "edit" ]; then echo -n "Removing existing Desktop System... " rm -r edit echo Done fi mkdir edit if [ -e "extract-cd" ]; then echo -n "Removing existing CD contents... " rm -r extract-cd echo Done fi mkdir extract-cd if ! [ -e "mnt" ]; then mkdir mnt fi if ! [ -e "squashfs" ]; then mkdir squashfs fi echo -n "Extracting CD contents... " mount -o loop $ubuntuiso mnt rsync --exclude=/casper/filesystem.squashfs -a mnt/ extract-cd echo Done echo -n "Extracting Desktop System... " mount -t squashfs -o loop mnt/casper/filesystem.squashfs squashfs cp -a squashfs/* edit/ umount squashfs umount mnt echo Done fi echo # Place custom scripting here # Patch for MVSAS kernel echo -n "Install patch for Marvell SAS for $kernel kernel? y/[n] " read ua if [ "$ua" = "y" ]; then echo "installing patch for Marvell SAS..." too=edit/lib/modules/$kernel/kernel/drivers/scsi/mvsas.ko cp mvsas.ko $too echo Done echo echo -n "Rebuilding initrd... " chroot edit mount -t proc none /proc chroot edit mkinitramfs -o /initrd.gz $kernel chroot edit umount /proc mv edit/initrd.gz extract-cd/casper/ echo Done fi echo # Initialize networking and sources cp -fR /etc/resolv.conf edit/etc # Clean up rm edit/etc/resolv.conf # End of custom scripting # Putting the CD together echo -n "Recompile iso? [y]/n " read ua if [ "$ua" = "n" ]; then echo echo The End echo exit fi echo Compressing filesystem if [ -e "extract-cd/casper/filesystem.squashfs" ]; then rm extract-cd/casper/filesystem.squashfs fi mksquashfs edit extract-cd/casper/filesystem.squashfs echo echo -n "Removing old md5sum.txt and calculating new md5 sums... " rm extract-cd/md5sum.txt (cd extract-cd && find . -type f -print0 | xargs -0 md5sum > md5sum.txt) echo Done echo echo Creating iso if [ -f "$customiso" ]; then echo -n "Removing old custom iso... " rm $customiso echo Done echo fi cd extract-cd mkisofs -r -V "$IMAGE_NAME" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../$customiso . echo echo The End echo