tools/toCOPY/mock_overlay/mount_wrappers/mock_tmpfs_umount.sh
Saul Wold 73c1d66677 Rename cgcs_overlay to mock_overlay
This helps to debrand (remove cgcs) from the tools area

Story: 2006387
Task: 36208
Change-Id: I357837a710207f8cec6409d1de99f443f8c50c84
Signed-off-by: Saul Wold <sgw@linux.intel.com>
2019-10-08 12:32:50 -07:00

63 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
MOUNT_POINT=$1
id $USER | grep '(cgts)\|751(mock)' > /dev/null
if [ $? -ne 0 ]
then
echo "Only members of group cgts may use this tool."
exit 1
fi
MY_UID=`id -u $USER`
if [ $? -ne 0 ]
then
echo "failed to determine UID."
exit 1
fi
MY_GID=`getent group cgts | cut -d: -f3`
if [ $? -ne 0 ]
then
echo "failed to determine GID."
exit 1
fi
# echo "USER=$USER"
# echo "UID=$UID"
# echo "MY_UID=$MY_UID"
# echo "MY_GID=$MY_GID"
if [ ! -d $MOUNT_POINT ]
then
echo "'$MOUNT_POINT' is not a directory"
exit 1
fi
echo "$MOUNT_POINT" | grep -e "/$USER/.*/mock" > /dev/null
if [ $? -ne 0 ]
then
echo "'$MOUNT_POINT' does not match pattern '/$USER/.*/mock'"
exit 1
fi
mount | grep "$USER" > /dev/null
if [ $? -ne 0 ]
then
echo "'$MOUNT_POINT' is not mounted by $USER"
exit 1
fi
# echo "umount $MOUNT_POINT"
for m in $(mount | grep "$USER" | grep "$MOUNT_POINT" | awk '{ print $3 }' | sort --reverse); do
umount $m
if [ $? -ne 0 ]
then
echo "failed to unmount '$m'"
exit 1
fi
done
echo "'$MOUNT_POINT' unmounted"
exit 0