-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathshared-space-link-shared-space.sh
68 lines (55 loc) · 1.77 KB
/
shared-space-link-shared-space.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
###################################################################
#
# Enable users to add shared server spaces for multiple
# Schools via Self Service.
#
# Date: Thu 21 Dec 2017 15:16:22 GMT
# Version: 0.1.3
# Creator: dsavage
#
##################################################################
# College or support unit (chss, cmvm, csce, sg)
unit=$4
#unit="chss"
# Subject area or group
subject=$5
#subject="div"
user_name=`ls -l /dev/console | awk '{print $3}'`
smb_mount="smb://${user_name}@$unit.datastore.ed.ac.uk/$unit/$subject"
smb_path="smb://$unit.datastore.ed.ac.uk/$unit/$subject"
share="/Volumes/${subject}"
mount_volume() {
script_args="mount volume \"${smb_mount}\""
# If the home volume is unavailable take 2 attempts at (re)mounting it
tries=0
while ! [ -d /Volumes/${subject} ] && [ ${tries} -lt 2 ];
do
tries=$((${tries}+1))
sudo -u ${user_name} | osascript -e "${script_args}"
sleep 5
done
}
# Adds the entry to the sidebar
add_FavoriteItems() {
if [ -d /Volumes/${subject} ]; then
python - <<EOF
import sys
sys.path.append('/usr/local/python')
from FinderSidebarEditor import FinderSidebar # Import the module
sidebar = FinderSidebar() # Create a Finder sidebar instance to act on.
sidebar.add("$share") # Add 'Utilities' favorite to sidebar
EOF
else
mount_volume
python - <<EOF
import sys
sys.path.append('/usr/local/python')
from FinderSidebarEditor import FinderSidebar # Import the module
sidebar = FinderSidebar() # Create a Finder sidebar instance to act on.
sidebar.add("$share") # Add 'Utilities' favorite to sidebar
EOF
fi
}
add_FavoriteItems
exit 0;