usb mount script for sun rays
as you all know the sun ray ultrathin-clients support several types of devices connected to them, including serial and parallel devices, usb mass storage, pdas and so on. for a full list see the sun ray admin guide, chapter four. now when a usb mass storage device gets plugged in, the sun ray services mount it to /tmp/SUNWut/mnt/[username]/disk[integer]/. the user then needs to traverse the file system to get into the named directory which is applicable but quite a strange behavior for people who got used to windows (plug in usb-stick and it gets mounted as a lokal partition, then the user gets notified of it). because of this i have thought of a possibility to decrease user concerns and increase their positive experiences. yesterday i did a quick hack to check for mounted usb devices, link them to the users home directory and open a file browser to display the linked directory.
-
#!/bin/bash
-
###################################################################################
-
# Sun Ray USB Mount Script - /opt/SUNWut/bin/utusbmount.sh #
-
# Copyright 2007 Christian Stottmeister - http://www.stottmeister.com #
-
# #
-
# This program is free software; you can redistribute it and/or modify #
-
# it under the terms of the GNU General Public License as published by #
-
# the Free Software Foundation; either version 2 of the License, or #
-
# (at your option) any later version. #
-
# #
-
# This program is distributed in the hope that it will be useful, #
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
-
# GNU General Public License for more details. #
-
# #
-
# You should have received a copy of the GNU General Public License #
-
# along with this program; if not, write to the Free Software #
-
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA #
-
# #
-
# See http://www.fsf.org/licensing/licenses/gpl.txs for the full license text. #
-
# #
-
###################################################################################
-
-
# RECOGNIZE CONNECTED USB DEVICES OF THE CURRENT USER
-
usbdevices=`/opt/SUNWut/bin/utdiskadm -l`
-
-
# COUNT CONNECTED USB DEVICES OF THE CURRENT USER
-
# count the lines of `utdiskadm -l` output
-
usbdevicescount=`echo "$usbdevices" | wc -l`
-
# substract 2 lines because they are only headings
-
usbdevicescount=$(($usbdevicescount-2))
-
-
# RECOGNIZE DISK AND MOUNT PATH OF THE USB DEVICE
-
usbdisk=`echo "$usbdevices" | grep "disk"`
-
usbdisk=`echo "$usbdisk" | cut -f1 -s -d' '`
-
usbmountpath=/tmp/SUNWut/mnt/`/usr/xpg4/bin/id -u -n`/
-
-
# LINK THE USB DEVICE AND OPEN FILE BROWSER
-
# check if $usbmountpath exists and is a directory
-
if [ -e $usbmountpath -a -d $usbmountpath ]; then
-
# $usbmountpath is a directory and therefore exists
-
# link to usb device will be placed into userdir, named usbdisk*
-
linklocation=~/usb$usbdisk
-
# check if ~/usbdisk* exists
-
if [ ! -e $linklocation ]; then
-
ln -s $usbmountpath $linklocation
-
fi
-
nautilus $linklocation
-
fi
the script has a pitfall yet, because it supports only one usb device per user. so if the user connects two or more usb mass storage devices (should happen rarely) the scripts fails. i plan to code an option the select the desired device. perhaps some of my fellow readers want to supply this so i don't have to code it?
btw. using this script you have to unmount devices after usage of course. i will come up with the according script later.

February 26th, 2007 at 4:57 pm
[…] as promised here comes part two of the usb scripts for sun ray ultrathin-clients. this is yet simpler but fancier than the mount script because it uses zenity to display the result of the unmounting operation. PLAIN TEXT CODE: […]
September 3rd, 2007 at 6:04 pm
the script described here has been topped by another solution. please refer to http://www.stottmeister.com/blog/2007/09/03/usb-drive-deamon-for-sun-ray-environments/ to read about the usb drive deamon. thanks!
September 4th, 2007 at 9:46 am
usb drive deamon for sun ray environments…
okay, time for more updates. as months went by, my usb mount/unmount script has been used by several sun ray admins, who have written me uplifting mails. thanks for your replies, dudes! but meanwhile daniel cifuentes came up with the “usb drive d…