usb unmount script for sun rays
Monday, February 26th, 2007as 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.
-
#!/bin/bash
-
###################################################################################
-
# Sun Ray USB UnMount Script - /opt/SUNWut/bin/utusbumount.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' '`
-
-
# LINK THE USB DEVICE AND OPEN FILE BROWSER
-
# link to usb device will be placed into userdir, named usbdisk*
-
linklocation=~/usb$usbdisk
-
# try to eject the device
-
/opt/SUNWut/bin/utdiskadm -r $usbdisk
-
# check exit code of utdiskadm
-
if [ "$?" -eq "0" ]; then
-
# check if ~/usbdisk* exists
-
if [ -e $linklocation ]; then
-
# remove the link to /tmp/SUNWut/mnt/ *
-
rm $linklocation
-
fi
-
if [ -e /usr/bin/zenity ]; then
-
/usr/bin/zenity --info --title="USB UnMounting succeeded" --text="You can physically unmount the USB device now."
-
fi
-
exit 0
-
else
-
if [ -e /usr/bin/zenity ]; then
-
/usr/bin/zenity --error --title="USB UnMounting failed" --text="Something went wrong while unmounting $usbdisk."
-
else
-
echo ERROR. USB UnMounting of $usbdisk failed!
-
fi
-
exit 1
-
fi
so this is what you should get after executing the script:

of course there is an appropriate dialog if something fails.
by the way i have recognized that the scripts do work only if executed in a terminal. to make sure that it is run in a terminal use the checkbox in the starters' preferences dialog. to be true i don't know why this is necessary.
please let me know if you find some errors while using this script. i'ld love to know if it helps you in your sun ray environment. leaving a comment would be nice. thanks!
