-
Notifications
You must be signed in to change notification settings - Fork 28
/
shareConnectGroupCheck.sh
37 lines (32 loc) · 1.07 KB
/
shareConnectGroupCheck.sh
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
#!/bin/bash
# Created by David Acland - Amsys
#
# Use at your own risk. Amsys will accept
# no responsibility for loss or damage
# caused by this script.
username="$3"
if [ -z "$username" ]; then # Checks if the variable is empty (user running script from Self Service)
username="$USER"
fi
echo "User: $username"
protocol="$4" # This is the protocol to connect with (afp | smb)
echo "Protocol: $4"
serverName="$5" # This is the address of the server, e.g. my.fileserver.com
echo "Server: $5"
shareName="$6" # This is the name of the share to mount
echo "Sharename: $6"
group="$7" # This is the name of the group the user needs to be a member of to mount the share
echo "Group: $7"
# Check that the user is in the necessary group
groupCheck=`dseditgroup -o checkmember -m $username "$group" | grep -c "yes"`
if [ "${groupCheck}" -ne 1 ]; then
exit 1
fi
# Mount the drive
mount_script=`/usr/bin/osascript > /dev/null << EOT
tell application "Finder"
activate
mount volume "$protocol://${serverName}/${shareName}"
end tell
EOT`
exit 0