From 320122a62fb002f0279cbf0919b81755f0611d3a Mon Sep 17 00:00:00 2001
From: Thiago Abdo <tja14@inf.ufpr.br>
Date: Tue, 7 Jun 2016 11:27:39 -0300
Subject: [PATCH] [issue/3254] Fix local_accounts umount

Signed-off-by: Thiago Abdo <tja14@inf.ufpr.br>
---
 .../opt/openslx/scripts/local-accounts_insert-data.sh       | 6 ++++++
 .../opt/openslx/scripts/local-accounts_remove-udev.sh       | 6 ++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/server/modules/local-accounts/opt/openslx/scripts/local-accounts_insert-data.sh b/server/modules/local-accounts/opt/openslx/scripts/local-accounts_insert-data.sh
index bb018a38..d7d3973b 100755
--- a/server/modules/local-accounts/opt/openslx/scripts/local-accounts_insert-data.sh
+++ b/server/modules/local-accounts/opt/openslx/scripts/local-accounts_insert-data.sh
@@ -59,6 +59,12 @@ dev="$1"
 prepare_usb "$dev" #returns at $mountpath
 # will only continue if the device that triggered is a valid openslx device
 echo "$0: an openslx ready drive is mounted at: $mountpath"
+if [ ! -e "/home/openslx/usb_slx" ]; then
+    mkdir -p "/home/openslx/usb_slx";
+fi
+# Create a file that makes sure that this drive is a openslx users
+# to be used to umount it
+touch "/home/openslx/usb_slx/$dev"
 
 unset IFS
 users=$(cat "$mountpath/Openslx/.config");
diff --git a/server/modules/local-accounts/opt/openslx/scripts/local-accounts_remove-udev.sh b/server/modules/local-accounts/opt/openslx/scripts/local-accounts_remove-udev.sh
index bc0707db..a99f512f 100755
--- a/server/modules/local-accounts/opt/openslx/scripts/local-accounts_remove-udev.sh
+++ b/server/modules/local-accounts/opt/openslx/scripts/local-accounts_remove-udev.sh
@@ -12,11 +12,13 @@ remove (){
 #set -x
 
     user_drive="/dev/$1"
-
+    dev=$1
     #check if this is a openslx drive
     mountpath=$(mount | sed 's/ type.*//' | grep -w $dev | cut -d' ' -f3- | head -n1)
-    if [ -e "$mountpath/Openslx/.config" ]; then
+    #if [ -e "$mountpath/Openslx/.config" ]; then
+    if [ -e "/home/openslx/usb_slx/$dev"  ]; then
         echo "$0: /dev/$dev is an openslx ready drive"
+        rm "/home/openslx/usb_slx/$dev"
     else
         echo "$0: /dev/$dev is not ready to be used as an openslx drive"
         exit 2 # stops openslx users_pendrive execution for this dev
-- 
GitLab