Help with script to automount pendrives, etc.

I want to be able to easily mount and unmount my pendrives, and I want them to be automounted as soon as they are plugged in.

However:
The plasmoid Device Notifier does not automount.
The plasmoid device notifier with automount is not being developed anymore (AFAIK) and I haven’t been able to install it.
Whenever I mount a pendrive with the Device Notifier and write sth to it with thunderbird, I can’t unmount it afterwards.
I don’t know how to get ivam working.
Halevt is not in the repositories.

Therefore, I tried with the following messed up alternative:

**1) **I placed the following script in the autostart folder:



#! /bin/bash
rm -f /tmp/de-mounted.txt
while :
do

PRESENT=$(hal-device | grep "/dev/sdd")
MOUNTED=$(mount | grep "/dev/sdd")


function III
{

if  -f /tmp/de-mounted.txt ] ; then
	echo "Demounted"
		if  -z "$PRESENT" ] ; then
			rm -f /tmp/de-mounted.txt
			echo "Demounted removed"
		fi
fi

if  -z "$PRESENT" ] ; then
		echo "It is not there"
else
		echo "It is there"
		if  ! -f /tmp/de-mounted.txt ] ; then
				if  "$MOUNTED"  != "/dev/sdd on /media/pendrive type vfat (rw,iocharset=utf8)" ] ; then
				echo "It is not mounted .. mounting"
				sudo /bin/mount /dev/sdd /media/pendrive/ -o iocharset=utf8
				konqueror /media/pendrive 
				fi
		fi
fi

}

III
sleep 4
done

**2.) I created two icons in a panel:
** a)
An icon to mount the pendrive on demand with the following command:

MOUNTED=$(mount | grep "/dev/sdd") ; if  "$MOUNTED"  != "/dev/sdd on /media/pendrive type vfat (rw,iocharset=utf8)" ] ; then sudo /bin/mount /dev/sdd /media/pendrive/ -o iocharset=utf8 ; konqueror /media/pendrive; else kdialog --passivepopup "El pendrive ya está montado." ; konqueror /media/pendrive; fi 

** b)** An icon to unmount the pendrive and prevent the first script from remounting it endlessly:

sudo /bin/umount /dev/sdd ; touch /tmp/de-mounted.txt ; ISITMOUNTED=$(hal-device | grep "volume.mount_point = '/media/pendrive'  (string)") ; if  -z "$ISITMOUNTED" ] ; then kdialog --passivepopup "El pendrive está desmontado. Por favor extraigalo pa que no se derrita."; fi

All the sudo line have been added to sudoers.

As it is, everything works great. Or so I thought:
I can’t write to the pendrive!!!

Any help, please?
(I know that this method is a god **** mess, but it’s the only solution I could come up with.)

Hi
I would look at using ivman. Have a look at the man page after it’s
installed. It’s also a service so you you need to ensure it’s enabled
to start at bootup.


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.27.42-0.1-default
up 6 days 14:23, 4 users, load average: 0.24, 0.14, 0.10
GPU GeForce 8600 GTS Silent - CUDA Driver Version: 190.53

malcolmlewis:
Thanks for your reply.
Unfortunately, as far as I have been able to look into it, I will encounter the same issue concerning permissions as I have with my method. I’ll keep trying to understand it, though.