# !/bin/bash/

if [ $USER != root ]; then
  zenity --error --text "You must be root !
Try sudo !"
exit
  
fi
echo ""
echo "***********************************"
echo "**    Welcome at Mount_dd_v1.3   **"
echo "** created by David Van Boven    **"
echo "**         RCCU AALST            **"
echo "***********************************"
echo ""

while :
do
  INPUT_STRING=$(zenity  --list  --title "Mount DD" --text "What do you want to do ?
Make your choise :" --width 350 --height 290 --radiolist  --column "choise" --column "nr" --column "What ?" TRUE 1 Stop FALSE 2 "mount dd ro (also img and 00x)" FALSE 3 "mount dd rw (also img and 00x)" FALSE 4 "mounten iso ro" FALSE 5 unmount FALSE 6 about);
  case $INPUT_STRING in
#============================================Stoppen=================================
	1)    
		zenity --info --text "Good Bye ! "
                break
                ;;	

#=========================================mount_dd_ro========================================
	2) 
		zenity --info --text "*-*-*-MOUNT DD (read-only)-*-*-*
answer a few questions"
		paddd=$(zenity --title="Path to DD" --file-selection);
		cfUnits=$(fdisk -lu $paddd | egrep -i -w 'eenheid|units'| awk '{print $9}')
		txtfdisk=$(fdisk -lu $paddd | egrep -i -w 'dd[0-9]|img[0-9]|00[0-9]p[0-9]');
		targetDirectory=$(zenity --title="Path to existing empty directory" --file-selection --directory);
		cfStart=$(zenity --entry --text "$txtfdisk 
------------------------------------------------------------------------------

Give Start of partition (look at table - first figure): 
" --entry-text "");
		
		mount -r $paddd $targetDirectory -o loop,offset=$(($cfUnits*$cfStart))

		nautilus $targetDirectory
		
                ;;
#=========================================mount_dd_rw========================================	
	3) 
		zenity --info --text "*-*-*-MOUNT DD (read-write)-*-*-*
answer a few questions"
		paddd=$(zenity --title="Path to DD" --file-selection);
		cfUnits=$(fdisk -lu $paddd | egrep -i -w 'eenheid|units' | awk '{print $9}')
		txtfdisk=$(fdisk -lu $paddd | egrep -i -w 'dd[0-9]|img[0-9]|00[0-9]p[0-9]');
		targetDirectory=$(zenity --title="Path to existing empty directory" --file-selection --directory);
		cfStart=$(zenity --entry --text "$txtfdisk 
------------------------------------------------------------------------------

Give Start of partition (look at table - first figure): 
" --entry-text "");
		
		mount -rw $paddd $targetDirectory -o loop,offset=$(($cfUnits*$cfStart))

		nautilus $targetDirectory
		
                ;;
#=========================================mount_iso_ro========================================	
	4) 
		zenity --info --text "*-*-*-MOUNT ISO (read-only)-*-*-*
answer a few questions"
		padiso=$(zenity --title="Path to ISO" --file-selection);
		targetDirectory=$(zenity --title="Path to existing empty directory" --file-selection --directory);
			
		mount -r -t iso9660 $padiso $targetDirectory -o loop

		nautilus $targetDirectory
		
                ;;
#===============================================unmout_dd===============================
	5)  
     		mountinfo=$(mount | grep '^/dev/');
		zenity --info --text "*-*-*-UNMOUNT-*-*-*
list of mounted devices / make your choise : 
$mountinfo"
		dirumount=$(zenity --title="Path to directory to unmount" --file-selection --directory);
		umount $dirumount
		zenity --info --text "*** $dirumount is free ***"
		;;
  
#=========================================about===============================================

	6) 
		zenity --info --text "
       ***********************************
           Welcome at Gui_Mount_dd_v1.3
            created by David Van Boven      
                  RCCU AALST     
       ***********************************

This een small tool for mounting a raw image files. It mounts these extensions : .dd, .img, .00x.
As an extra it mounts normal ISO-files to.
It is free and if you wish you can edit it, but I would like it that you send me example of the edited file.
I like to learn something out of it. You can contact me at netsorcist@gmail.com.
Grtz, and have fun 
;-)
David
"
		;;		

#====================================foute invoer=============================================		
        *)
               zenity --info --text "Make your choise !!"
                ;;
  esac
done


