On Thu, 11 Mar 2010 14:27:29 +0200
Alexey Vatchenko <[email protected]> wrote:
> Hi!
> I wrote a little utility to easily mount plugged removable disks.
> It's a kind of plugin for hotplugd(8).
>
[...]
Since we're on the subject, maybe I should share my attach script.
It mounts the newly inserted device at the next free /mnt/umassN
which must of course exist. It starts an xterm with the cwd set
to the mount point and unmounts the device when the xterm closes.
Anyone else with more fancy scripts that would like to share?
$ cat /etc/hotplug/attach
#!/bin/sh
cls="$1"
dev="$2"
if [ ${cls} = "2" ]; then
# Find free mount point in /mnt/umass?.
for mnt in /mnt/umass?; do
! mount | grep ${mnt} > /dev/null && break;
done
if ! mount | grep ${mnt}; then
# Use first successfully mounted partition.
for dev in /dev/${dev}[a-p]; do
if mount ${dev} ${mnt}; then
# Launch xterm and umount when closed.
DISPLAY=:0.0 sudo -i -u tpfaff "cd ${mnt} && xterm"
umount ${mnt}
break
fi
done
fi
fi
exit 0