home *** CD-ROM | disk | FTP | other *** search
- #!/bin/bash
- #knoppixFreedom.ripISO
- #extracts filesystem from knoppix.iso
-
- SOURCE=$1
- BASE=$(echo $1 | sed s/\.iso//)
- ENV="$BASE"_env
- MNT_PT="$BASE"_mnt
-
- [ ! -f "$SOURCE" ] && { echo "Usage: $0 SOURCE_ISO_FILE" >&2 ; exit 1; }
- [ ! -x /usr/bin/extract_compressed_fs ] && { echo "Need /usr/bin/extract_compressed_fs."; exit 1; }
- [ ! -x /bin/mount ] && { echo "Need /bin/mount" ; exit 1 ; }
-
- [ -f tmp.iso ] && { echo -n "tmp.iso exists! Remove file? [n]" ; read answer ;
- if [ "$answer" = "y" ]
- then rm tmp.iso || { echo "unable to remove tmp.iso" ; exit 1 ; }
- else exit 1
- fi }
- [ `whoami` != "root" ] && { echo "Need to be root to run $0" ; exit 1 ; }
-
- # Create Destination Directories
-
- [ -d "$BASE" ] && { echo -n "$BASE exists! Remove files? [n]"; read answer ;
- if [ "$answer" = "y" ]
- then rm -r "$BASE"
- else exit 1
- fi }
-
- echo "creating directory $BASE"
-
- mkdir "$BASE"
-
- [ -d "$ENV" ] && { echo -n "$ENV exists! Remove files? [n]" ; read answer ;
- if [ "$answer" = "y" ]
- then rm -r "$ENV"
- else exit 1
- fi }
-
- echo
- echo "creating directory $ENV"
-
- mkdir "$ENV"
-
- # Create temporary mount-directory
-
- [ -d "$MNT_PT" ] && { echo "temporary mount directory $MNT_PT exists!" >&2 ; exit 1; }
-
- mkdir "$MNT_PT" &&
-
- # Mount and copy CD-Image
-
- mount -t iso9660 -o ro,loop "$SOURCE" "$MNT_PT" &&
-
- echo
- echo "copying content of iso image"
- echo "this might take a while..."
-
- cp -a "$MNT_PT"/* "$BASE"
-
- umount "$SOURCE" &&
-
- # Extract compressed fs
-
- echo
- echo "extracting compressed file"
- echo "this might take a while..."
-
-
- extract_compressed_fs "$BASE"/KNOPPIX/KNOPPIX > tmp.iso 2>/dev/null &&
-
- # Mount & copy extracted fs
-
- mount -t iso9660 -o ro,loop tmp.iso "$MNT_PT" &&
-
- echo "copying entire knoppix file system..."
- echo "this takes a long time"
-
- cp -a $MNT_PT/* $ENV
-
- echo
- echo "writing sorting information into mkisofs.sort..."
- [ -f mkisofs.sort ] && [ ! -w mkisofs.sort ] && { echo "Warning: can not write to mkisofs.sort" ;
- echo " this could lead to a slow booting cd (see documentation)" ; }
- find $ENV/ -printf %p\\t-%A@\\n | sort -grk2 > mkisofs.sort
-
- #echo
- #echo "changing file attributes..."
- #find $ENV/ -type l -or \( -exec chmod a+r \{\} \; , -type d -exec chmod a+x \{\} \; \)
- echo
- echo "deleting temporary files..."
-
- umount tmp.iso
-
- rm tmp.iso
-
- rmdir "$MNT_PT"
-
-