Tuesday Jun 19, 2007

A "USB Drive" daemon for Sun Ray sessions

\*\*\*\* THIS VERSION OF usbdrived IS DEPRECATED - see \*\*\* http://blogs.sun.com/danielc/entry/a_usb_drive_daemon_for1


A lot of people ask me the age-old question: how can I see thumb drives (and others) attached to my Sun Ray on JDS/CDE/Windows? (it probably works unchanged for SLES and RHEL.)

The inelegant, user-unfriendly solution that is always there for you (JDS/CDE):
Without doing any further work, the answer is quite trivial: SRSS mounts the thumb drive on a non-trivial directory (non-trivial as in "not in your home directory") - namely at:

/tmp/SUNWut/mnt/<user-name>

(mounted disk names and #s appear here)

You can then access this via the file manager - for example, in JDS, (right-click) Launch -> Browse Documents (Nautilus) and point to this directory. Better yet - bookmark this directory under Nautilus as soon as you can!

However, the above is typically unacceptable for customer deployments, and until the time Solaris/JDS can handle this automatically, I've scripted a couple of workarounds. See next section.

The elegant solution: "USB Daemon (usbdrived)"
The following instructions will automate USB drive "show-up" so that when you insert a thumbdrive into your Sun Ray:
1) a file manager window (Nautilus) will automatically open up showing the top-level directory of the USB drive, and
2) a link is created on your desktop, called "USB Drive" (I just couldn't come up with a better name...)

Once you pull the drive out, the above disappear, so it's important to make sure that any copying process is done before pulling it out. (actually, the file manager window disappears only if its on the root level of your USB drive. If anyone can tell me how to close any Nautilus window that's open on sub-directories, please let me know!)

The instructions here also integrate the script with utaction so that disconnected users don't chew up unnecessary Sun Ray server resources.

HOW TO (Basic instructions for JDS):
These instructions assume that you'll install this for your user account. Extrapolate for server-wide deployment as required...

1) If you don't have one, create a bin directory in your home directory
- run this: mkdir $HOME/bin

2) copy usbdrived to your newly created "bin" and give it exec permissions
- run this: chmod +x $HOME/bin/usbdrived

[NOTE: THIS LINK IS DEPRECATED AND NOW POINTS TO BLOG ENTRY FOR V2!]

3) If you're running version 1.23 or better of utdiskadm, skip to step 6. To find out, this command will tell you the version number
- run this: head /opt/SUNWut/bin/utdiskadm | grep ident | awk '{ print $4 }'

4) If you're on version 1.22 or lower of utdiskadm you need to patch an 'alternate' version that includes a little fix: copy the standard utdiskadm to your bin directory (call it utdiskadm.fix) and change one line (because, under certain circusmtances, logname returns nothing...) - the script will probe for an up-to-date utdiskadm and ignore yours when the system has been patched as required!
- run this: cp /opt/SUNWut/bin/utdiskadm $HOME/bin/utdiskadm.fix
                vi $HOME/bin/utdiskadm.fix
                find the line UTUSERNAME="`logname`"
                change to UTUSERNAME=$USER
                :wq (save the file ;)

5) If you are \*not\* placing the updated utdiskadm.fix file in your bin directory, update your "usbdrived" script to reflect the location of utdiskadm.fix.

6) add a line to your .profile (bash/ksh/sh) or .login (csh) in your home directory that will enable the daemon on card insertion (change the path accordingly if the script is not in your bin directory)
- run this: echo '/opt/SUNWut/bin/utaction -c  "$HOME/bin/usbdrived start" -d  "$HOME/bin/usbdrived stop" -i &' >> $HOME/.profile   (or .login if csh)

7) Log out, log in... That's it. (or you can run the above line to test as a one-off until you log out).

Under CAM/CDE
If your are using CAM/CDE, make sure you edit the script and change the USEJDS variable to 0, so that:
1) Nautilus is not invoked automatically (though you can, but...)
2) The "USB Drive" link is created in the user's home dir and not the Desktop dir, which doesn't exist

You can then add a CAM menu entry to open dtfile on this, such as "Open My USB Drive". You do this anyway without usbdrived by following the earlier section, but it won't open in the exact mount, but rather in the parent folder. These instructions are particularly useful for the next section...

Under Windows
You need to run the daemon like above under either JDS or CDE (whatever it is you are using underneath) and make sure you start up uttsc with the appropriate -r option, e.g. -r disk:U="$HOME/Desktop/USB Drive" for JDS. This will let you browse the U: drive when there is something mounted, and it will allow for changing USB drives without disconnecting your Windows session, as usbdrived depends on utdiskadm to create the "USB Drive" link on demand.

Make sure that if you are using CAM with the Sun Ray Windows Connector, you make USEJDS=0 in the usbdrived script.

Limitations
This only allows for one USB drived at a time to show up and be managed. That's enough for now ;) 

About

Think Thin is a collection of bloggers that work with Oracle's Virtual Desktop portfolio of products.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today