Skip to content
Snippets Groups Projects
Commit e4ea32e2 authored by Thiago Abdo's avatar Thiago Abdo
Browse files

Merge branch 'master' of gitlab.c3sl.ufpr.br:cdn/users-openslx

parents a0633dd8 97a65848
No related branches found
No related tags found
No related merge requests found
......@@ -3,37 +3,40 @@ DIR_USB=/media/usb_drive/
DIR_OPENSLX=/Openslx/
user_name=`users | cut -f 1 -d ' '`
# prepares openslx partition to be used
# mounts partition if not mounted
# blocks program execution if it is not a openslx partition
# param $1 is the devpath to be mounted
# param $2 is the uuid of the partition
# return is done via the mountpath global variable, which is also used here
function prepare_usb {
# get the usb_drive's path
devpath=`readlink -f $usb_drives`
# check if the usb_drive is mounted
mount_msg=`mount | grep $devpath`
# if it is mounted, show the path
if [[ -n $mount_msg ]]; then
echo $mount_msg
mount_path=`mount | grep $devpath | cut -f 3 -d ' '`
counter=4
part_path=`mount | grep $devpath | cut -f 4 -d ' '`
while [ "$part_path" != "type" ];
do
mount_path=$mount_path"\ "$part_path
counter=$(($counter+1))
part_path=`mount | grep $devpath | cut -f $counter -d ' '`
done
echo $mount_path
echo $mount_path$DIR_OPENSLX
# If it is not mounted, mount it
# get the usb_drive's path
local devpath="/dev/"$1
mountpath=""
if [ ! 0 -eq $(mount | grep -q $devpath) ]; then
echo $0": Device $devpath is already mounted"
mountpath=$(mount | grep -w $devpath | cut -d' ' -f3)
else
echo "$devpath não está montado";
if [ ! -d "$DIR_USB" ]; then
mkdir /media/usb_drive
echo "não existe"
echo $0": Device $devpath is not mounted"
mkdir -p /media/openslx/$2
if $(mount $devpath /media/openslx/$2); then
echo $0": Device $devpath mounted successfully"
mountpath="/media/openslx/"$2
else
echo $0": Device $devpath could not be mounted"
exit 1
fi
fi
if [ -e "$mountpath/Openslx/config" ]; then
echo $0": $devpath is an openslx ready drive"
else
echo $0": $devpath is not ready to be used as an openslx drive"
if [ $mountpath = "/media/openslx/$2" ]; then
echo $0": umounting $devpath"
umount $devpath
fi
exit 2
fi
echo "Montando dispositivo..."
mount -o uid="$user_name" $devpath /media/usb_drive
mount_path=/media/usb_drive
fi
}
sleep 3
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment