home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2005 September / NessusLiveCD.iso / KNOPPIX / src_freedom / knoppixFreedom.ripISO < prev    next >
Encoding:
Text File  |  2005-05-10  |  2.3 KB  |  98 lines

  1. #!/bin/bash
  2. #knoppixFreedom.ripISO
  3. #extracts filesystem from knoppix.iso
  4.  
  5. SOURCE=$1
  6. BASE=$(echo $1 | sed s/\.iso//)
  7. ENV="$BASE"_env
  8. MNT_PT="$BASE"_mnt
  9.  
  10. [ ! -f "$SOURCE" ] && { echo "Usage: $0 SOURCE_ISO_FILE" >&2 ; exit 1; }
  11. [ ! -x /usr/bin/extract_compressed_fs ] && { echo "Need /usr/bin/extract_compressed_fs."; exit 1; }
  12. [ ! -x /bin/mount ] && { echo "Need /bin/mount" ; exit 1 ; }
  13.  
  14. [ -f tmp.iso ] && { echo -n "tmp.iso exists! Remove file? [n]" ; read answer ;
  15.     if [ "$answer" = "y" ]  
  16.     then  rm tmp.iso || { echo "unable to remove tmp.iso" ; exit 1 ; }  
  17.     else  exit 1  
  18.     fi  }
  19. [  `whoami` != "root" ] && { echo "Need to be root to run $0" ; exit 1 ; }
  20.  
  21. # Create Destination Directories
  22.  
  23. [ -d "$BASE" ] && { echo -n "$BASE exists! Remove files? [n]"; read answer ; 
  24.     if [ "$answer" = "y" ] 
  25.     then  rm -r "$BASE"  
  26.     else  exit 1  
  27.     fi  }
  28.  
  29. echo "creating directory $BASE"
  30.  
  31. mkdir "$BASE"
  32.  
  33. [ -d "$ENV" ] && { echo -n "$ENV exists! Remove files? [n]" ; read answer ;
  34.     if [ "$answer" = "y" ]  
  35.     then  rm -r "$ENV"  
  36.     else  exit 1  
  37.     fi  }
  38.  
  39. echo
  40. echo "creating directory $ENV"
  41.  
  42. mkdir "$ENV"
  43.  
  44. # Create temporary mount-directory
  45.  
  46. [ -d "$MNT_PT" ] && { echo "temporary mount directory $MNT_PT exists!" >&2 ; exit 1; }
  47.  
  48. mkdir "$MNT_PT" &&
  49.  
  50. # Mount and copy CD-Image
  51.  
  52. mount -t iso9660 -o ro,loop "$SOURCE" "$MNT_PT" &&
  53.  
  54. echo
  55. echo "copying content of iso image"
  56. echo "this might take a while..."
  57.  
  58. cp -a "$MNT_PT"/* "$BASE" 
  59.  
  60. umount "$SOURCE" &&
  61.  
  62. # Extract compressed fs
  63.  
  64. echo
  65. echo "extracting compressed file"
  66. echo "this might take a while..."
  67.  
  68.  
  69. extract_compressed_fs "$BASE"/KNOPPIX/KNOPPIX > tmp.iso 2>/dev/null &&
  70.  
  71. # Mount & copy extracted fs
  72.  
  73. mount -t iso9660 -o ro,loop tmp.iso "$MNT_PT" &&
  74.  
  75. echo "copying entire knoppix file system..."
  76. echo "this takes a long time"
  77.  
  78. cp -a $MNT_PT/* $ENV
  79.  
  80. echo
  81. echo "writing sorting information into mkisofs.sort..."
  82. [ -f mkisofs.sort ] && [ ! -w mkisofs.sort ] && { echo "Warning: can not write to mkisofs.sort" ; 
  83.     echo "         this could lead to a slow booting cd (see documentation)" ; } 
  84. find $ENV/ -printf %p\\t-%A@\\n | sort -grk2 > mkisofs.sort
  85.  
  86. #echo
  87. #echo "changing file attributes..."
  88. #find $ENV/ -type l -or \( -exec chmod a+r \{\} \; , -type d -exec chmod a+x \{\} \; \)
  89. echo
  90. echo "deleting temporary files..."
  91.  
  92. umount tmp.iso 
  93.  
  94. rm tmp.iso
  95.  
  96. rmdir "$MNT_PT" 
  97.  
  98.