Skip to content

Commit 45a33f5

Browse files
Release 1.0.107
1 parent 63e0f4c commit 45a33f5

File tree

3 files changed

+341
-1
lines changed

3 files changed

+341
-1
lines changed

setup-devbox.sh

Lines changed: 315 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,315 @@
1+
#!/bin/bash
2+
set -e
3+
4+
git=0
5+
cf=1
6+
jdk=2
7+
maven=3
8+
nodejs=4
9+
python2=5
10+
python3=6
11+
uaac=7
12+
jq=8
13+
predixcli=9
14+
mobilecli=10
15+
androidstudio=11
16+
docker=12
17+
vmware=13
18+
19+
declare -a install
20+
21+
function prefix_to_path() {
22+
if [[ ":$PATH:" != *":$1:"* ]]; then
23+
echo 'export PATH="$1${PATH:+":$PATH"}"' >> ~/.bash_profile
24+
source ~/.bash_profile
25+
fi
26+
}
27+
28+
function check_internet() {
29+
set +e
30+
echo ""
31+
echo "Checking internet connection..."
32+
curl "http://github.com" > /dev/null 2>&1
33+
if [ $? -ne 0 ]; then
34+
echo "Unable to connect to internet, make sure you are connected to a network and check your proxy settings if behind a corporate proxy. Please read this tutorial for detailed info about setting your proxy https://www.predix.io/resources/tutorials/tutorial-details.html?tutorial_id=1565"
35+
echo ""
36+
exit 1
37+
fi
38+
echo "OK"
39+
echo ""
40+
set -e
41+
}
42+
43+
function check_bash_profile() {
44+
# Ensure bash profile exists
45+
if [ ! -e ~/.bash_profile ]; then
46+
printf "#!/bin/bash\n" >> ~/.bash_profile
47+
fi
48+
}
49+
50+
function get_proxy_scripts() {
51+
VERIFY_PROXY_URL=https://raw.githubusercontent.com/PredixDev/predix-scripts/master/bash/common/proxy/verify-proxy.sh
52+
TOGGLE_PROXY_URL=https://raw.githubusercontent.com/PredixDev/predix-scripts/master/bash/common/proxy/toggle-proxy.sh
53+
ENABLE_XSL_URL=https://raw.githubusercontent.com/PredixDev/predix-scripts/master/bash/common/proxy/enable-proxy.xsl
54+
DISABLE_XSL_URL=https://raw.githubusercontent.com/PredixDev/predix-scripts/master/bash/common/proxy/disable-proxy.xsl
55+
56+
if [ -f "verify-proxy.sh" ]; then
57+
rm verify-proxy.sh
58+
fi
59+
if [ -f "toggle-proxy.sh" ]; then
60+
rm toggle-proxy.sh
61+
fi
62+
if [ -f "enable-proxy.xsl" ]; then
63+
rm enable-proxy.xsl
64+
fi
65+
if [ -f "disable-proxy.xsl" ]; then
66+
rm disable-proxy.xsl
67+
fi
68+
69+
if [ ! -f "verify-proxy.sh" ]; then
70+
curl -s -O $VERIFY_PROXY_URL
71+
fi
72+
if [ ! -f "toggle-proxy.sh" ]; then
73+
curl -s -O $TOGGLE_PROXY_URL
74+
fi
75+
if [ ! -f "enable-proxy.xsl" ]; then
76+
curl -s -O $ENABLE_XSL_URL
77+
fi
78+
if [ ! -f "disable-proxy.xsl" ]; then
79+
curl -s -O $DISABLE_XSL_URL
80+
fi
81+
}
82+
83+
84+
function install_everything() {
85+
install[git]=1
86+
install[cf]=1
87+
install[jdk]=1
88+
install[maven]=1
89+
install[nodejs]=1
90+
install[python2]=1
91+
install[python3]=1
92+
install[uaac]=0 # Install UAAC only if the --uaac flag is provided
93+
install[jq]=1
94+
install[yq]=1
95+
install[predixcli]=1
96+
install[mobilecli]=1
97+
install[androidstudio]=0 # Install Android Studio only if --androidstudio flag is provided
98+
install[docker]=1
99+
install[vmware]=0 # Install Android Studio only if --vmware flag is provided
100+
}
101+
102+
function install_nothing() {
103+
install[git]=0
104+
install[cf]=0
105+
install[jdk]=0
106+
install[maven]=0
107+
install[nodejs]=0
108+
install[python2]=0
109+
install[python3]=0
110+
install[uaac]=0
111+
install[jq]=0
112+
install[yq]=0
113+
install[predixcli]=0
114+
install[mobilecli]=0
115+
install[androidstudio]=0
116+
install[docker]=0
117+
install[vmware]=0
118+
}
119+
120+
function install_yq() {
121+
sudo pip install yq
122+
yq --version
123+
}
124+
125+
126+
function install_predixcli() {
127+
export DYLD_INSERT_LIBRARIES=;
128+
if which predix > /dev/null; then
129+
echo "Predix CLI already installed."
130+
predix -v
131+
PREDIX_VERSION=$(predix -v | awk -F" " '{print $3}')
132+
update_predixcli $PREDIX_VERSION
133+
else
134+
cli_url=$(curl -s -L https://api.github.com/repos/PredixDev/predix-cli/releases | jq -r ".[0].assets[0].browser_download_url")
135+
echo "Downloading latest Predix CLI: $cli_url"
136+
curl -L -O "$cli_url"
137+
mkdir -p predix-cli && tar -xf predix-cli.tar.gz -C predix-cli
138+
if [ -e predix-cli ]; then
139+
#tar -C is supposed to change directory but it doesn't sometimes
140+
cd predix-cli
141+
fi
142+
./install
143+
fi
144+
}
145+
146+
147+
function update_predixcli() {
148+
#echo "Predix CLI updgrade"$1
149+
existing_version=$1
150+
cli_version_name=$(curl -s -L https://api.github.com/repos/PredixDev/predix-cli/releases | jq -r ".[0].tag_name")
151+
cli_version_name=${cli_version_name:1}
152+
echo "Predix CLI already installed version."$existing_version
153+
echo "Predix CLI new installed version."$cli_version_name
154+
echo "checking for upgrade"
155+
if [[ "$existing_version" != *"$cli_version_name"* ]]; then
156+
echo "Upgrading Predix CLI to version" $cli_version_name
157+
cli_url=$(curl -s -L https://api.github.com/repos/PredixDev/predix-cli/releases | jq -r ".[0].assets[0].browser_download_url")
158+
echo "Downloading latest Predix CLI: $cli_url"
159+
curl -L -O "$cli_url"
160+
mkdir -p predix-cli && tar -xf predix-cli.tar.gz -C predix-cli
161+
if [ -e predix-cli ]; then
162+
#tar -C is supposed to change directory but it doesn't sometimes
163+
cd predix-cli
164+
fi
165+
./install
166+
fi
167+
168+
}
169+
170+
function install_mobilecli() {
171+
if which pm > /dev/null; then
172+
echo "Predix Mobile CLI already installed."
173+
pm
174+
else
175+
#cli_url=$(curl -g -s -L https://api.github.com/repos/PredixDev/predix-mobile-cli/releases | jq -r '.' )
176+
cli_url=$(curl -g -s -L https://api.github.com/repos/PredixDev/predix-mobile-cli/releases | jq -r '[ .[] | select(.prerelease==false) ] | .[0].assets[] | select(.name | contains("Mac")) | .browser_download_url' )
177+
cli_install_url="https://raw.githubusercontent.com/PredixDev/local-setup/master/mobile-cli-install"
178+
cli_install_root_url="https://raw.githubusercontent.com/PredixDev/local-setup/master/mobile-cli-root-install"
179+
#cli_install_url="https://raw.githubusercontent.com/PredixDev/local-setup/develop/mobile-cli-install.sh"
180+
echo "Downloading latest Predix Mobile CLI: $cli_url"
181+
curl -L "$cli_url" -o pm.zip
182+
mkdir -p mobile-cli && tar -xf pm.zip -C mobile-cli
183+
cd mobile-cli
184+
echo $cli_install_url
185+
curl -L -O "$cli_install_url"
186+
echo $cli_install_root_url
187+
curl -L -O "$cli_install_root_url"
188+
chmod +x mobile-cli-install
189+
chmod +x mobile-cli-root-install
190+
./mobile-cli-install
191+
fi
192+
}
193+
194+
function run_setup() {
195+
echo "--------------------------------------------------------------"
196+
echo "This script will install tools required for Predix development"
197+
echo "You may be asked to provide your password during the installation process"
198+
echo "--------------------------------------------------------------"
199+
echo ""
200+
if [ -z "$1" ]; then
201+
echo "Installing all the tools..."
202+
install_everything
203+
else
204+
echo "Installing only tools specified in parameters..."
205+
install_nothing
206+
while [ ! -z "$1" ]; do
207+
[ "$1" == "--git" ] && install[git]=1
208+
[ "$1" == "--cf" ] && install[cf]=1
209+
[ "$1" == "--jdk" ] && install[jdk]=1
210+
[ "$1" == "--maven" ] && install[maven]=1
211+
[ "$1" == "--nodejs" ] && install[nodejs]=1
212+
[ "$1" == "--python2" ] && install[python2]=1
213+
[ "$1" == "--python3" ] && install[python3]=1
214+
[ "$1" == "--uaac" ] && install[uaac]=1
215+
[ "$1" == "--jq" ] && install[jq]=1
216+
[ "$1" == "--yq" ] && install[yq]=1
217+
[ "$1" == "--predixcli" ] && install[predixcli]=1
218+
[ "$1" == "--mobilecli" ] && install[mobilecli]=1
219+
[ "$1" == "--androidstudio" ] && install[androidstudio]=1
220+
[ "$1" == "--docker" ] && install[docker]=1
221+
[ "$1" == "--vmware" ] && install[vmware]=1
222+
shift
223+
done
224+
install[jq]=1
225+
fi
226+
227+
check_internet
228+
check_bash_profile
229+
230+
if [ ${install[jq]} -eq 1 ]; then
231+
echo "jq already installed"
232+
fi
233+
234+
if [ ${install[yq]} -eq 1 ]; then
235+
install_yq
236+
fi
237+
238+
if [ ${install[git]} -eq 1 ]; then
239+
echo "git already installed"
240+
fi
241+
242+
if [ ${install[cf]} -eq 1 ]; then
243+
echo "cf already installed"
244+
fi
245+
246+
if [ ${install[jdk]} -eq 1 ]; then
247+
echo "jdk already installed"
248+
fi
249+
250+
if [ ${install[maven]} -eq 1 ]; then
251+
echo "maven already installed"
252+
fi
253+
254+
if [ ${install[nodejs]} -eq 1 ]; then
255+
echo "nodejs already installed"
256+
fi
257+
258+
if [ ${install[python3]} -eq 1 ]; then
259+
echo "python3 already installed"
260+
fi
261+
if [ ${install[python2]} -eq 1 ]; then
262+
echo "python2 already installed"
263+
fi
264+
265+
if [ ${install[uaac]} -eq 1 ]; then
266+
echo "uaac not supported"
267+
fi
268+
269+
if [ ${install[predixcli]} -eq 1 ]; then
270+
install_predixcli
271+
fi
272+
273+
if [ ${install[mobilecli]} -eq 1 ]; then
274+
echo "mobile cli already installed"
275+
fi
276+
277+
if [ ${install[androidstudio]} -eq 1 ]; then
278+
echo "android studio already installed"
279+
fi
280+
281+
if [ ${install[docker]} -eq 1 ]; then
282+
echo "docker already installed"
283+
fi
284+
285+
}
286+
287+
function check_status() {
288+
if [ $STATUS != 0 ]; then
289+
echo
290+
echo "install for $TOOL failed"
291+
read -p "Would you like to keep going? (y/n) > " -t 300 answer
292+
if [[ -z $answer ]]; then
293+
echo -n "Specify (yes/no)> "
294+
read answer
295+
fi
296+
if [[ ${answer:0:1} == "y" ]] || [[ ${answer:0:1} == "Y" ]]; then
297+
echo
298+
echo "Continuing to next tool installation"
299+
else
300+
echo
301+
echo "Exiting ..."
302+
exit 1
303+
fi
304+
fi
305+
}
306+
307+
308+
run_setup $@
309+
# Running Proxy Scripts
310+
echo
311+
echo "Pulling proxy scripts from predix-scripts"
312+
get_proxy_scripts
313+
echo
314+
echo "Running verify-proxy.sh"
315+
source verify-proxy.sh

setup-mac.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ function brew_install() {
107107
else
108108
echo "Installing $TOOL"
109109
brew install $TOOL
110+
111+
# Adding validation to check for installation failures
112+
STATUS=$?
113+
check_status
110114
fi
111115
}
112116

@@ -434,6 +438,27 @@ function run_setup() {
434438
fi
435439
}
436440

441+
function check_status() {
442+
if [ $STATUS != 0 ]; then
443+
echo
444+
echo "brew install for $TOOL failed"
445+
read -p "Would you like to keep going? (y/n) > " -t 300 answer
446+
if [[ -z $answer ]]; then
447+
echo -n "Specify (yes/no)> "
448+
read answer
449+
fi
450+
if [[ ${answer:0:1} == "y" ]] || [[ ${answer:0:1} == "Y" ]]; then
451+
echo
452+
echo "Continuing to next tool installation"
453+
else
454+
echo
455+
echo "Exiting ..."
456+
exit 1
457+
fi
458+
fi
459+
}
460+
461+
437462
run_setup $@
438463
# Running Proxy Scripts
439464
echo

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "local setup",
3-
"version": "1.0.106",
3+
"version": "1.0.107",
44
"private": true,
55
"dependencies": {},
66
"author": "rishabhtulsian"

0 commit comments

Comments
 (0)