The changes are noted at the top of the attached patch.


Andrew

--- /usr/sbin/lbus_event_handler.sh.original	2006-04-08 15:35:05.000000000 -0600
+++ /usr/sbin/lbus_event_handler.sh	2007-04-11 13:25:01.000000000 -0600
@@ -22,6 +22,13 @@
 #    3)  Remove the .desktop file from the ~/Desktop directory so
 #        the Icon goes away
 #
+# CHANGES FROM UPSTREAM
+#  - LTSPFS target directory configurable for some systems that
+#    have problems with FUSE and NFS under /home.
+#  - Provide notifications using notify-send.
+#  - Try to better handle spaces in path names.
+#
+#
 
 ACTION=$1
 
@@ -40,6 +47,12 @@
 DRIVEDIR=${DRIVE_DIR:-Drives}
 ICON=${FOLDER_ICON:-gnome-fs-directory.svg}
 
+BASEDIR=/mnt/localdev/$USER
+#BASEDIR=${HOME}/${DRIVEDIR}
+
+LINKDIR=${HOME}/${DRIVEDIR} # for use with BASEDIR=/mnt/localdev/$USER
+#LINKDIR= # for use with BASEDIR=${HOME}/${DRIVEDIR}
+
 function create_icon {
   SHARENAME=$2
   cat <<-EOF  >${HOME}/Desktop/${SHARENAME}.desktop
@@ -62,8 +75,8 @@
 
   if [ -n "${HOME}" ]; then
 
-    if [ -d ${HOME}/${DRIVEDIR} ]; then
-      for drive in ${HOME}/${DRIVEDIR}/*; do
+    if [ -d $BASEDIR ]; then
+      for drive in $BASEDIR/*; do
         if [ -d ${drive} ]; then
           rmdir ${drive}
         fi
@@ -72,7 +85,7 @@
 
     if [ -d ${HOME}/Desktop ]; then
       for desktop in ${HOME}/Desktop/*.desktop; do
-        if [ -f ${desktop} ]; then
+        if [ -f ${desktop} ]; then # FIXME: this doesn't handle spaces well
           if grep -q lbus_event_handler ${desktop}; then
             rm -f ${desktop}
           fi
@@ -83,10 +96,25 @@
   fi
 }
 
+function is_empty_dir
+{
+  [[ -d "$1" && 1 -eq `find "$1" | wc -l` ]]
+  return $?
+}
+
+
 WS=${DISPLAY/:*/}
 
-if [ ! -d ${HOME}/${DRIVEDIR} ]; then
-  mkdir ${HOME}/${DRIVEDIR}
+if [ ! -d $BASEDIR ]; then
+  mkdir -p $BASEDIR
+fi
+
+if [ "$LINKDIR" != "" ]; then
+  if [ ! -d "$LINKDIR" ]; then
+    mkdir -p "$LINKDIR"
+    rm -f "$LINKDIR"
+    ln -s "$BASEDIR" "$LINKDIR"
+  fi
 fi
 
 case "${ACTION}" in
@@ -96,12 +124,29 @@
       SIZE=$4
       DESC=$5
       case "${DEVTYPE}" in
-          block)  mkdir "${HOME}/${DRIVEDIR}/${SHARENAME}"
+          block)  
+                  notify-send -i harddrive -t 5000 "FYI" "Adding device $5"
+
+                  # make the directory
+                  mkdir "${BASEDIR}/${SHARENAME}"
+                  if [[ "$?" -ne "0" ]];
+                  then
+                    notify-send -u critical -i harddrive -t 10000 "Error" "Error creating ${BASEDIR}/${SHARENAME}"
+                  else
+                    is_empty_dir "${BASEDIR}/${SHARENAME}"
+                    [[ "$?" -eq "1" ]] && notify-send -u critical -i harddrive -t 10000 "Error" "Directory ${BASEDIR}/${SHARENAME} should be empty"
+                  fi
+
+                  # mount the new device
                   /usr/sbin/ltspfs ${WS}:/tmp/drives/${SHARENAME} \
-                                   "${HOME}/${DRIVEDIR}/${SHARENAME}"
+                                   "${BASEDIR}/${SHARENAME}"
+                  ERR=$?
+                  [[ "$ERR" -ne "0" ]] && notify-send -u critical -i harddrive -t 10000 "FYI" "Error code $ERR while adding device $5"
+
+                  # create a shortcut icon
                   if [ -d ${HOME}/Desktop ]; then
                     create_icon "${DESC}" "${SHARENAME}" \
-                                "${HOME}/${DRIVEDIR}/${SHARENAME}"
+                                "${BASEDIR}/${SHARENAME}"
                   fi
                   ;;
        esac
@@ -113,8 +158,10 @@
       SIZE=$4
       DESC=$5
       case "${DEVTYPE}" in
-          block)  fusermount -u -z "${HOME}/${DRIVEDIR}/${SHARENAME}"
-                  rmdir "${HOME}/${DRIVEDIR}/${SHARENAME}"
+          block)  
+                  fusermount -u -z "${BASEDIR}/${SHARENAME}"
+                  notify-send -i harddrive -t 5000 "FYI" "Removing device $5"
+                  rmdir "${BASEDIR}/${SHARENAME}"
                   if [ -d ${HOME}/Desktop ]; then
                     rm -f "${HOME}/Desktop/${SHARENAME}.desktop"
                   fi

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_____________________________________________________________________
Ltsp-discuss mailing list.   To un-subscribe, or change prefs, goto:
      https://lists.sourceforge.net/lists/listinfo/ltsp-discuss
For additional LTSP help,   try #ltsp channel on irc.freenode.net

Reply via email to