Tossa olis scripti:
# Set some script variables
the_image=$1
image_name=`echo $the_image | sed -e 's/\.iso$//;s/\.img$//;s/\.nrg$//'`
if [ "$NAUTILUS_SCRIPT_CURRENT_URI" == "x-nautilus-desktop:///" ]; then
image_path=$HOME"/Desktop"
else
image_path=`echo "$NAUTILUS_SCRIPT_CURRENT_URI" | sed -e 's/^file:\/\///; s/%20/\ /g'`
fi
gui=`which zenity`
# Obtain password when required
gksudo -u root -k -m "Please enter your system password:" "sudo -v"
passresult=$?
# Mounter function
iso_mount()
{
if [ "$passresult" == "3" ]; then
exit 1
fi
if [ "$passresult" == "2" ]; then
$gui --info --title "ISO Mounter" --text "Cancelled!"
exit 0
fi
if [[ "$the_image" =~ "\.volume$" ]]; then
image_name=`echo "$image_name" | sed -e 's/\.volume$//'`
iso_umount
exit 0
fi
if ! [[ "$the_image" =~ "\.iso$" || "$the_image" =~ "\.img$" || "$the_image" =~ "\.nrg$" ]]; then
$gui --question --title "ISO Mounter" --text "Select, "Ok" if you're sure that $the_image is an image file."
if [ "$?" == "1" ]; then
$gui --info --title "ISO Mounter" --text "Cancelled!"
exit 1
fi
fi
sudo mkdir /media/"$image_name"
# Support for both normal .iso and Nero .nrg files (somewhat experimental for .nrg support - let me know if it works for you!)
if [[ "$the_image" =~ "\.nrg$" ]]; then
if sudo mount -o loop,offset=307200,users -t iso9660 "$image_path/$the_image" /media/"$image_name"; then
nautilus /media/"$image_name" --no-desktop
else
sudo rmdir /media/"$image_name"
$gui --error --title "ISO Mounter" --text "Nero image file, \"$the_image\" could NOT be mounted!"
exit 1
fi
else
if sudo mount -o loop,users -t iso9660 "$image_path/$the_image" /media/"$image_name"; then
nautilus /media/"$image_name" --no-desktop
else
sudo rmdir /media/"$image_name"
$gui --error --title "ISO Mounter" --text "ISO image file, \"$the_image\" could NOT be mounted!"
exit 1
fi
fi
}
# Unmounter function
iso_umount()
{
if [[ "$passresult" == "2" || "$passresult" == "3" ]]; then
exit 1
fi
if sudo umount "/media/$image_name"; then
$gui --info --text "Un-mounted /media/$image_name/."
sudo rmdir "/media/$image_name/"
else
if [[ `ls -l "/media/$image_name" | grep "total 0"` != "" ]]; then
if $gui --question --title "ISO Mounter" --text "Mount point, \"/media/$image_name\" was found un-mounted! Re-mount it?"; then
iso_mount
else
if sudo rmdir "/media/$image_name/"; then
$gui --info --text "Mount point, \"/media/$image_name\" removed!"
else
$gui --error --title "ISO Mounter" --text "Could NOT remove mount point, \"/media/$image_name!\""
fi
fi
else
$gui --error --title "ISO Mounter" --text "Could NOT un-mount $the_image!"
fi
fi
}
# Validate the prospective image file and decide whether to mount or un-mount it.
if [[ -d "$image_path/$the_image" ]]; then
$gui --error --title "ISO Mounter" --text "\"$image_path/$the_image\" is NOT an image file!"
exit 1
fi
if [[ -d "/media/$image_name" ]]; then
iso_umount
else
iso_mount
fi
exit 0
Itsellä käytössä ja hyvin toimii
Tuon kun asennat ja hiiren oikealla klikkaat .iso:a ja valitset scriptin niin kysyy s-sanan ja mounttaa .iso:n omaan kansioon.
Ja sama scripti unmounttaa kun klikkaat .isoa uudestaan