/ Published in: Bash
This is a simple script for testing changes in a live iso created with squashfs filesystem for the compression.
It will take the iso path as a parameter and it will open it up with unionfs to let you modify its content (into a chroot enviroment) and when you get out, it will create a new iso file with the new content.
It's pretty simple and easy stuff but useful for every day testing.
It will take the iso path as a parameter and it will open it up with unionfs to let you modify its content (into a chroot enviroment) and when you get out, it will create a new iso file with the new content.
It's pretty simple and easy stuff but useful for every day testing.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/bin/bash # variables sqhs_file_tmp="/tmp/filesystem.squashfs" # checks if [ `id -u` != 0 ]; then echo "ERROR: You need be a root." echo "Use: sudo $(basename $0)" exit fi if [ -z "$1" ]; then echo "ERROR: You must pass an iso name as argument" exit elif [ ! -f "$1" ]; then echo "ERROR: ${1} does not exist" exit else original_iso="$1" fi if [ ! -d "/tmp/master" ]; then mkdir /tmp/master fi if [ ! -d "/tmp/unionfs" ]; then mkdir /tmp/unionfs fi if [ ! -d "/tmp/changes" ]; then mkdir /tmp/changes else rm -f /tmp/changes/* fi if [ ! -d "/tmp/rw" ]; then mkdir /tmp/rw else rm -f /tmp/rw/* fi if [ ! -d "/tmp/ro" ]; then mkdir /tmp/ro fi # mount the iso file mount -o loop -t iso9660 $original_iso /mnt/ || ( echo "error: mount iso" && exit ) # mount the squashfs image mount -o loop -t squashfs /mnt/casper/filesystem.squashfs /tmp/ro || ( echo "error: mount squashfs" && exit ) # mount sources from squashfs image with unionfs mount -t unionfs -o dirs=/tmp/rw=rw:/tmp/ro=ro: unionfs /tmp/unionfs || ( echo "error: mount unionfs" && umount /tmp/unionfs && exit ) # prepare the chroot enviroment mount --bind /proc /tmp/unionfs/proc # enter into the sources with chroot chroot /tmp/unionfs /bin/bash # umount the chroot enviroment umount /tmp/unionfs/proc # regeneration of the squashfs image test -f $sqhs_file_tmp && rm -f $sqhs_file_tmp mksquashfs /tmp/unionfs $sqhs_file_tmp # mount the iso file content with unionfs mount -t unionfs -o dirs=/tmp/changes=rw:/mnt/=ro: unionfs /tmp/master || ( echo "error: mount master" && exit ) # copy the squashfs file to the right dir cp -f $sqhs_file_tmp /tmp/master/casper/ || ( echo "error: copying $sqhs_file_tmp" && exit ) # copy the kernel and initrd files to the right dir #cp -f /tmp/unionfs/boot/vmlinuz-2.6.20-15-generic /tmp/master/casper/vmlinuz || ( echo "error: copying vmlinuz" && exit ) #cp -f /tmp/unionfs/boot/initrd.img-2.6.20-15-generic /tmp/master/casper/initrd.gz || ( echo "error: copying initrd" && exit ) # create the new iso file mkisofs -r -V "Live test" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o /tmp/live-test.iso /tmp/master/ || ( echo "error: mkisofs" ) # umount iso stuff umount /tmp/master umount /mnt/