refactor this script into universal squashfs re-master tool
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 17 Sep 2010 21:53:19 +0000 (21:53 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 17 Sep 2010 21:53:19 +0000 (21:53 +0000)
- correctly handle permissions of mount points
- show message before dropping into chroot
- more sane mksquashfs if run for the first time

bin/squashfs-overlay.sh

index fade32b..74c2817 100755 (executable)
@@ -9,22 +9,28 @@ path=/srv/pxelator/tftp/debian_live/custom.squashfs
 if mount | egrep '/tmp/(base|export|changes)' ; then
        sudo umount -l /tmp/changes
        sudo umount -l /tmp/base
-       sudo umount -l /tmp/export
+       while sudo umount -l /tmp/export ; do
+               echo "again"
+       done
        echo "umounted"
        exit
 fi
 
 sudo apt-get install squashfs-tools
 
-sudo mount $from /tmp/base/ -o loop || exit
+mkdir /tmp/base
 
-mkdir /tmp/changes /tmp/base /tmp/export
+mount $from /tmp/base -o loop || exit
 
-sudo mount -t aufs -o br:/tmp/changes/:/tmp/base/ none /tmp/export/ || exit
+mkdir /tmp/changes /tmp/export
+stat --format='chmod -v %a /tmp/changes /tmp/export && chown -v %u:%g /tmp/changes /tmp/export' /tmp/base | sh -x
+sudo mount -t aufs -o br:/tmp/changes:/tmp/base none /tmp/export
 
+df -h /tmp/base /tmp/changes /tmp/export
 
-echo "Now modify your installation"
+echo "Now modify your installation, type exit to remaster into $path"
 sudo chroot /tmp/export || exit
 
-
-sudo mksquashfs /tmp/export/ $path.new && mv $path $path.old && mv $path.new $path && chmod 444 $path && ls -al $path
+sudo rm -fv $path.new
+sudo mksquashfs /tmp/export $path.new && mv $path $path.old
+mv $path.new $path && chmod 444 $path && ls -al $path