DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2010-02-10 20:54:38

crs2027
Member
Registered: 2008-10-14
Posts: 46

mount iso

Greetings,

I would just like to post a script I made today for mounting an ISO.  I read through this thread http://dns323.kood.org/forum/viewtopic.php?id=2009 and thought I would create a script to do it all for me.

installation:
you will need to copy the script (mountiso.sh) and the moudules udk.ko + isofs.ko somewhere useful and set the correct paths for these modules in the script.  You can also set the mount point and if need be add a share to samba.

usage:

this should mount an iso

Code:

mountiso.sh /path/to/iso/file.iso

display current mounted iso

Code:

mountiso.sh

unmount current iso

Code:

mountiso.sh -u

the script

Code:

#!/ffp/bin/sh


# paths
#-------
MOUNTPOINT=/mnt/iso
MODULE_ISO=/mnt/HD_a2/isofs.ko
MODULE_UDF=/mnt/HD_a2/udf.ko
INSMOD="/ffp/sbin/insmod"


# get current iso info
#----------------------
CURRENT_MOUNT="$( mount | grep "$MOUNTPOINT" )";
LOOP_POS=""
ISO_POS=""
LOOP=""
CURRENT_ISO=""

if [ ! -z "$CURRENT_MOUNT" ]
then
  LOOP_POS=`expr "$CURRENT_MOUNT" : ".* on " - 4`
  ISO_POS=`expr "$LOOP_POS" + 4`
  LOOP=${CURRENT_MOUNT:0:$LOOP_POS}
  CURRENT_ISO="$( losetup | grep "$LOOP" )";
  CURRENT_ISO=${CURRENT_ISO:$ISO_POS:100 }
fi


# check command line params
#---------------------------
if [ -z "$1" ]
then
  
  if [ -z "$CURRENT_ISO" ] 
  then
    echo "- no iso -"
  else
    echo "$CURRENT_ISO"
  fi

  exit

fi

if [ "$1" == "-u" ]
then
 
  if [ -z "$CURRENT_ISO" ]
  then
    echo -e "\n error: no ISO currently mounted\n"
    exit
  fi

  umount -l "$MOUNTPOINT"
  sleep 1
  losetup -d "$LOOP" 

  CHECK_ISO="$( mount | grep "$MOUNTPOINT" )";

  if [ -z "$CHECK_ISO" ]
  then
    echo -e "\n iso unmounted success\n"
  else
    echo -e "\n error: iso failed to unmount\n"
  fi

  exit

fi


# check the iso path
#--------------------
if [ ! -e "$1" ]
then
  echo -e "\n error: iso file not found\n"
  exit
fi


# install UFD module if required
#--------------------------------
MOD_UDF="$( cat /proc/filesystems | grep udf )";

if [ -z "$MOD_UDF" ]
then

  echo "** install udf module" 
  $INSMOD "$MODULE_UDF"

fi

MOD_UDF="$( cat /proc/filesystems | grep udf )";

if [ -z "$MOD_UDF" ]
then

  echo -e "\n error: install udf module failed\n"
  exit

fi


# install ISO module if required
#--------------------------------
MOD_ISO="$( cat /proc/filesystems | grep iso9660 )";

if [ -z "$MOD_ISO" ]
then

  echo "** install iso module" 
  $INSMOD "$MODULE_ISO"

fi

MOD_ISO="$( cat /proc/filesystems | grep iso9660 )";

if [ -z "$MOD_ISO" ]
then

  echo -e "\n error: install iso module failed\n"
  exit

fi


# create the mount point
#------------------------
if [ ! -d "$MOUNTPOINT" ]
then
  mkdir "$MOUNTPOINT"
fi

if [ ! -d "$MOUNTPOINT" ]
then
  echo -e "\n error: mkdir $MOUNTPOINT failed\n"
  exit
fi


# unmount previous iso if required
#----------------------------------
if [ ! -z "$CURRENT_ISO" ]
then
  umount -l "$MOUNTPOINT"
  losetup -d "$LOOP"
fi


# mount the iso
#---------------
mount "$1" "$MOUNTPOINT"

CHECK_ISO="$( mount | grep "$MOUNTPOINT" )";

if [ -z "$CHECK_ISO" ]
then
  echo -e "\n error: could not mount $1\n"
else
  echo -e "\n iso mounted: $1\n"
fi

Probably does need some changes, but it works for me smile

All that is left is to link this in to a web interface for easy access...

Please report any bugs or suggestions!


Attachments:
Attachment Icon mountiso.zip, Size: 66,211 bytes, Downloads: 251

Offline

 

#2 2010-02-13 01:03:04

KyleK
Member
From: Dresden, Germany
Registered: 2007-12-05
Posts: 1178

Re: mount iso

Very nice, I was just looking for something like this.

I've tested with a UDF ISO and it works like a charm.

Thanks!

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB