forked from OpenGeoVis/PVGeo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstallMac.sh
108 lines (98 loc) · 3.03 KB
/
installMac.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
# FOR MAC OS X OPERATING SYSTEM
# ONLY RUN THIS SCRIPT ONCE (at time of installation)
# Use colors if connected to a terminal, and that terminal supports them.
if which tput >/dev/null 2>&1; then
ncolors=$(tput colors)
fi
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="$(tput setaf 3)"
BLUE="$(tput setaf 4)"
BOLD="$(tput bold)"
UND="$(tput smul)"
NORMAL="$(tput sgr0)"
else
RED=""
GREEN=""
YELLOW=""
BLUE=""
BOLD=""
NORMAL=""
fi
#### CHECK ARGS ####
if [ "$#" -ne 1 ]; then
printf "${RED}%s${NORMAL}\n" "Incorrect usage."
exit -1
fi
# The PVGeo Path from the argument
PVGeo="$1"
#### BEGIN INSTALLATION
pvplist="/Library/LaunchAgents/pvgeo.PV_PLUGIN_PATH.plist"
pyplist="/Library/LaunchAgents/pvgeo.PYTHONPATH.plist"
# check if the .plist files exits. Remove if so.
if [ -f ${pvplist} ]; then
printf "${YELLOW}%s${NORMAL}\n" "${pvplist} Currently exists. Overwiting..."
printf "${RED}%s${NORMAL}\n" "You will need to log out and back in after this script executes."
sudo rm -f $pvplist
fi
if [ -f ${pyplist} ]; then
printf "${YELLOW}%s${NORMAL}\n" "${pyplist} Currently exists. Overwiting..."
printf "${RED}%s${NORMAL}\n" "You will need to log out and back in after this script executes."
sudo rm -f $pyplist
fi
# Unsetting the PV_PLUGIN_PATH variable
printf "${RED}"
launchctl unsetenv PV_PLUGIN_PATH
printf "${NORMAL}"
printf "${GREEN}%s${NORMAL}\n" "Setting environmental variables immediate use..."
printf "${RED}"
launchctl setenv PV_PLUGIN_PATH ${PVGeo}/PVPlugins
launchctl setenv PYTHONPATH $PYTHONPATH:${PVGeo}/
printf "${NORMAL}"
# Write plst files to LaunchAgents so Paths are always set at login
printf "${GREEN}%s${NORMAL}\n" "Writing environmental variables to '/Library/LaunchAgents/'..."
cat << EOF | sudo tee ${pvplist}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>setenv.PV_PLUGIN_PATH</string>
<key>ProgramArguments</key>
<array>
<string>/bin/launchctl</string>
<string>setenv</string>
<string>PV_PLUGIN_PATH</string>
<string>${PVGeo}/plugins</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceIPC</key>
<false/>
</dict>
</plist>
EOF
cat << EOF | sudo tee ${pyplist}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>setenv.PYTHONPATH</string>
<key>ProgramArguments</key>
<array>
<string>/bin/launchctl</string>
<string>setenv</string>
<string>PYTHONPATH</string>
<string>${PYTHONPATH}:${PVGeo}/</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceIPC</key>
<false/>
</dict>
</plist>
EOF
printf "${GREEN}%s${NORMAL}\n" "All Finished! Any version of ParaView will launch with the PVGeo plugins and Python Module."