#!/bin/sh # Created by Nick Hudson # If this breaks something dont come bitchin' at me # This will help with mounting and moving stuff # around on an Ubuntu Live CD. # You must be root to do this # You will need squashfs for this script to work # This was mostly written by hand some parts came from # Ubuntu Wiki and the Gnome Live CD Project # . config.conf export REMOVELIST export ADDLIST export ISO set -x banner Use at your own risk banner Mounting and Copying Files to Disk # Check for root [ `id -u` -eq 0 ] || error you must be root. # Check for squashfs [ `lsmod |grep squashfs |awk '{print $3}'` == 0 ] || error try installing with modprobe squashfs # Check that the iso was specified if [ -e $1 ] ; then banner you did not specify an iso banner please enter the name of the iso echo -ne ":" read ${ISO} export ISO fi # Mount live cd banner Mounting CD mkdir -p ${ISOMNT} #mount -t iso9660 -o loop $1 ${ISOMNT} mount -o loop $1 ${ISOMNT} # Make sure work directory is created for dir in ${WORK} ${LIVENAME} ${WORK}/old ${WORK}/new do if [ ! -d $dir ] then banner Creating directory structure mkdir -p $dir || error Unable to create $dir fi done # Copy contents of image to disk banner Copying files to disk cd ${WORK} cp -a ${ISOMNT}/. ${LIVENAME} chmod -R u+w ${LIVENAME} umount ${ISOMNT} # Removing windows apps rm -fr ${WORK}/${LIVENAME}/programs # Mount compressed filesystem banner Mounting compressed filesystem mount -t squashfs -o loop,ro ${WORK}/${LIVENAME}/casper/filesystem.squashfs ${WORK}/old # Creating image for compressed filesystem dd if=/dev/zero of=${WORK}/ubuntu-fs.ext2 bs=1M count=2147 mke2fs -q ${WORK}/ubuntu-fs.ext2 # Mount fs on new mount point banner Mounting new fs mount -o loop ${WORK}/ubuntu-fs.ext2 ${WORK}/new # Copying compressed filesystem banner Copying compressed filesystem cp -a ${WORK}/old/. ${WORK}/new umount ${WORK}/old # chrooting into new system banner Moving into a chroot cp /etc/resolv.conf ${WORK}/new/etc/ cp ${BRAND}/sources.list ${WORK}/new/etc/apt/ mount -t proc -o bind /proc ${WORK}/new/proc # Updating new chroot ${CHROOT} apt-get update banner Removing packages not needed ${CHROOT} apt-get -y remove ${REMOVELIST} #${CHROOT} apt-get -y --quiet upgrade banner Adding packages we want ${CHROOT} apt-get -y --quiet install ${ADDLIST} #${CHROOT} dpkg -i -R /var/cache/apt/archives/ 1>&2 2>/dev/null ${CHROOT} apt-get clean ${CHROOT} apt-get autoclean ${CHROOT} dpkg-query -W --showformat='${Package} ${Version}\n' > ${WORK}/${LIVENAME}/casper/filesystem.manifest sudo umount ${WORK}/new/proc sudo rm ${WORK}/new/etc/resolv.conf # Add branding to image banner Branding Live CD # Splash screen branding cp ${BRAND}/gnome-splash1.png ${WORK}/new/usr/share/pixmaps/splash/ ${CHROOT} chmod 644 ${WORK}/new/usr/share/pixmaps/splash/gnome-splash1.png ${CHROOT} gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --type string --set /apps/gnome-session/options/splash_image "/usr/share/pixmaps/splash/gnome-splash1.png" # Background branding #rm -fr ${WORK}/new/usr/share/backgrounds/ cp ${BRAND}/gnome-background.jpg ${WORK}/new/usr/share/backgrounds/ ${CHROOT} chmod 644 /usr/share/backgrounds/gnome-background.jpg ${CHROOT} gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --type string --set /desktop/gnome/background/picture_filename "/usr/share/backgrounds/gnome-background.jpg" # Setting "foot" icon in Gnome Panel cp ${BRAND}/balu-foot.png ${WORK}/new/usr/share/pixmaps/ ${CHROOT} chmod /new/usr/share/pixmaps/balu-foot.png for i in `find ${WORK}/new/usr/share -name distributor-logo.png`; do cp $i $i.bak ; cp ${WORK}/new/usr/share/pixmaps/balu-foot.png $i; done for i in `find ${WORK}/new/usr/share -name start-here.png`; do cp $i $i.bak ; cp ${WORK}/new/usr/share/pixmaps/balu-foot.png $i; done for i in `find ${WORK}/new/usr/share -name distributor*.svg`; do cp $i $i.bak cp ${BRAND}/balu-foot.svg $i; done # Set up a different Theme #${CHROOT} gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --type string --set /desktop/gnome/interface/gtk_theme "IndustrialTango" #${CHROOT} gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --type string --set /desktop/gnome/interface/icon_theme "Tango" # Home branding cp -r ${BRAND}/home ${WORK}/new/home/ubuntu cp ${BRAND}/bookmarks.html ${WORK}/new/etc/firefox/profile/ # Branding grub menu cp ${BRAND}/splash.pcx ${LIVENAME}/isolinux/splash.pcx cp ${BRAND}/isolinux.txt ${LIVENAME}/isolinux/isolinux.txt cp ${BRAND}/isolinux.cfg ${LIVENAME}/isolinux/isolinux.cfg # Setting perms for user ${CHROOT} chown -R 999:999 /home/ubuntu # Clear free disk space banner Clearing disk space dd if=/dev/zero of=${WORK}/new/dummyfile rm ${WORK}/new/dummyfile # Build compressed fs - Go get some [beer,coffee,tea] banner Building compressed fs rm ${WORK}/${LIVENAME}/casper/filesystem.squashfs cd ${WORK}/new mksquashfs . ${WORK}/${LIVENAME}/casper/filesystem.squashfs banner Unmounting Live CD fs cd ${WORK} umount ${WORK}/new # Crate new Live CD banner Creating new Live CD cd ${WORK}/${LIVENAME} find . -type f -print0 | xargs -0 md5sum | tee md5sum.txt # Now build ISO banner Building ISO image cd ${WORK} mkisofs -o balu-livecd-`date +%F`.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -r -V "BALUG Live Linux CD" -cache-inodes -J -l ${WORK}/${LIVENAME} if [ -d ${ISOMOUNT} ] ; then rm ${ISOMOUNT} fi #remove tmp folder rm -rf ${TMP_DIR} echo "Burn ${WORK}/balu-livecd-`date +%F`.iso or run it in qemu or vmware" echo "To run in qemu do this: qemu -cdrom cdname.iso -boot -d"