-
Notifications
You must be signed in to change notification settings - Fork 0
/
sfamount
executable file
·52 lines (44 loc) · 1.18 KB
/
sfamount
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run via sudo"
exit 1
fi
if [ "$#" -ne 3 ]; then
echo "Usage: $0 MGBid sharename mountpoint"
exit 1
fi
MGBID=$1
SHARENAME=$2
MOUNTPOINT=$3
case $(basename $0) in
sfamount )
SERVER=cifs2.partners.org
if [[ $SHARENAME != *$ ]]; then
SHARENAME="${SHARENAME}\$"
fi
;;
rfamount )
SERVER=rfawin.partners.org
;;
* )
echo "Call me as sfamount or rfamount, please."
exit 1
;;
esac
if [ ! -d "$MOUNTPOINT" ]; then
echo "$MOUNTPOINT" must be an empty directory
exit 1
fi
if ls -1qA "$MOUNTPOINT" | grep -q . ; then
echo "$MOUNTPOINT" must be an empty directory
exit 1
fi
echo -e "\nIMPORTANT NOTE: ${SERVER} mounts are NOT accessible from compute nodes!\n"
echo -n "Going to mount //${SERVER}/${SHARENAME} on $(readlink -f $MOUNTPOINT) as $MGBID. OK? (y/n): "
read -r answer
if [ "$answer" != "${answer#[Yy]}" ] ;then
echo Please enter your MGB password...
mount -t cifs -o vers=3.0,sec=ntlmv2i,domain=PARTNERS,username="$MGBID",uid="$SUDO_USER" //${SERVER}/"$SHARENAME" "$MOUNTPOINT"
else
echo Aborted.
fi