"Downs, Peter A." <[EMAIL PROTECTED]> writes:
I'm using SRSS 3.1 on Solaris 10 sparc
...
I wrote a wrapper around /opt/SUNWut/lib/utdomount to create an icon to
on a users GNOME desktop after USB insertion and delete the Icon after
USB removal.
Thanks! Here's a few comments and suggestions. My tests are on
Solaris/x86.
1. The code to translate the device name
name=`basename $dev | sed -e 's/s2//'`
won't work with my Lexar Jump drive where the device can end
"disk1p1". (I'm a USB idiot, and I don't know the full story on
names.)
2. I've changed USB to be directory of links rather than a link in an
attempt to support multiple USB devices. There are corresponding
changes in filenames.
This makes unmounting less pleasant due to the form of the -p option
although it is possible to find the name from the argument. I used a
stupid approach that simply checks for existence. I don't know that
this is robust.
3. utdomount runs as root. Further, the setuid in
chown root:sys /opt/SUNWut/lib/utdomount
chmod 4755 /opt/SUNWut/lib/utdomount
won't do anything for a shell script utdomount. Running as root will
usually not work if home directories are NFS mounted. I've split the
script so that most runs as the user.
This is a hack, and more scrutiny is certainly required. I'll include
it only to show what I tested. Thanks again.
### SUNWut/lib/utdomount ################################################
#!/bin/sh
# Shell wrapper around /opt/SUNWut/lib/utdomount
# Adapted from 2005/08/23, Peter Downs, <[EMAIL PROTECTED]>
/opt/SUNWut/lib/utdomount.orig "$@"
cmdopt=$*
id=""
while [ $# -gt 0 ]; do
arg=$1
case $arg in
-i)
shift
id=$1
;;
*)
shift
;;
esac
done
if [ "$id" != "" ]; then
user=`getent passwd $id | cut -d: -f1`
if [ "$user" != "" ]; then
su $user -c "/usr/local/sbin/utdomount.sh $cmdopt"
fi
fi
### /usr/local/sbin/utdomount.sh #########################################
#!/bin/sh
while [ $# -gt 0 ]; do
arg=$1
case $arg in
-b)
shift
dev=$1
;;
-i)
shift
id=$1
;;
-m)
shift
action=mount
;;
-u)
shift
action=unmount
;;
*)
shift
;;
esac
done
user=`getent passwd $id | cut -d: -f1`
HOME=`getent passwd $id | cut -d: -f6`
name=`basename $dev | sed -e 's/s2//' -e 's/p1$//'`
icon="$HOME/Desktop/usb_$name.desktop"
case $action in
mount)
# Create icon
mpath="/tmp/SUNWut/mnt/$user/$name"
cat > "$icon" <<EOM
[Desktop Entry]
Encoding=UTF-8
Name=Removable USB Device $name
Exec=nautilus $mpath
TryExec=nautilus
Icon=gnome-dev-removable
Terminal=false
Type=Application
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=nautilus
X-GNOME-Bugzilla-Component=general
EOM
if [ ! -d $HOME/USB ]; then
mkdir $HOME/USB
fi
ln -s $mpath $HOME/USB/
;;
unmount)
for n in 1 2 3 4 ; do
if [ ! -h /tmp/SUNWut/mnt/$user/disk$n ]; then
rm "$HOME/Desktop/usb_disk$n.desktop"
rm "$HOME/USB/disk$n"
fi
done
;;
esac
_______________________________________________
SunRay-Users mailing list
[email protected]
http://www.filibeto.org/mailman/listinfo/sunray-users