USB Keychain Drive
Dave Basener
dbasener at aurora.edu
Thu Oct 7 19:41:49 UTC 2004
Hi,
I have a FC2 system and I use KDE. I wrote a simple kdialog script to
do mount and unmount of a usb drive when I click an icon on the K panel.
The dialog is a toggle. If the usb drive is not mounted, it mounts it.
If it is mounted it unmounts it. It gives you a status when done and
detects a couple of error conditions and gives you a choice of responses
to those errors. (I know there is a minor bug in it somewhere because
every now and then it gives me no response.) (Uses bash and kdialog.)
Here is the script:
===============================================
#!/bin/bash
#
# Dave Basener - Aurora University
#
STATFILE=/tmp/mnt.stat
mount /mnt/stick >$STATFILE 2>&1
mountResp=$?
if [[ $mountResp == 32 ]]
then
umount /mnt/stick >/dev/null 2>&1
umountResp=$?
if [[ $umountResp == 2 ]]
then
kdialog --error "Could not mount nor unmount the memory stick"
exit 32
elif [[ $umountResp == 0 ]]
then
kdialog --msgbox "Memory unmounted - OK to remove"
fi
else
# OK it's mounted, but did it mount properly
if [[ -s "$STATFILE" ]]
then
# there is a message in the stat file - ask what to do
kdialog --warningyesno "Device mounted, but mount
returned:\n$(cat $STATFILE)\n\nUnmount device?"
diaResp=$?
# if unmount requested, simply recurse
[[ $diaResp -eq 0 ]] && mountStick
else
# It mounted properly - give ACK
kdialog --msgbox "USB Memory mounted - "
fi
fi
==================================
Brian McGrew wrote:
>Hello:
>
>I have a USB Keychain drive that I want to be able to insert and remove on a whim. I want to be able to either 1) have the kernel auto mount the drive (like windows does) and dismount the drive with a right click or something or 2) have a link on my desktop to mount and dismount it.
>
>Is anyone doing this, are there specific packages that I should look for, or can I do this automatically? We're running RedHat 7.3 with the 2.4.20 kernel.
>
>Thanks,
>
>-brian
>
>Brian D. McGrew { brian at doubledimension.com || brian at visionpro.com }
>---
>
>
>>YOU! Off my planet!
>>
>>
>
>
>
--
"... be the change you wish to see in the world." - Gandhi
David Basener http://www.aurora.edu/~dbasener
System Administrator Dave.Basener at aurora.edu
Aurora University 630 844 4889
More information about the redhat-list
mailing list