forked from neocortix/ncscli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
installNcs.sh
executable file
·129 lines (108 loc) · 2.85 KB
/
installNcs.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/env bash
echo hello
targetVersion="3.(6|7|8|9)"
errMsg="python $targetVersion is not available in this environment"
# python3 is preferred over regular python
if hash python3 2>/dev/null; then
echo has python3
pyx="python3"
else
echo NO "python3"
if hash python 2>/dev/null; then
echo has python
pyx="python"
else
echo NO python
fi
fi
pyVersion="$($pyx -V 2>&1)"
#pyVersion="$(python3 -V 2>&1)"
#echo $pyVersion
if [[ $pyVersion =~ $targetVersion ]]
then
echo found $pyVersion
else
echo $errMsg
echo installing python3
sudo yum update
sudo yum install python3
if [ $? -eq 0 ]; then
echo installed python3
else
echo COULD NOT INSTALL python3
exit 1
fi
pyx="python3"
fi
# pip3 is preferred over regular pip
if hash pip3 2>/dev/null; then
echo has pip3
pipx="pip3"
else
echo NO pip3
if hash pip 2>/dev/null; then
echo has pip
pipx="pip"
else
echo NO pip
fi
fi
pipVersion="$($pyx -m pip --version 2>&1)"
if [[ $pipVersion =~ $targetVersion ]]
then
echo found $pipVersion
else
echo pipVersion $pipVersion
$pyx -c "import distutils.util"
if [ $? -eq 0 ]; then
echo has distutils
else
echo NO distutils
echo apt-installing distutils
sudo apt-get update
sudo apt-get install python3-distutils # would not work on redhat
fi
# try installing pip using get-pip
echo installing pip
curl -L https://bootstrap.pypa.io/get-pip.py > get-pip.py
$pyx get-pip.py --user --upgrade --no-cache-dir
# check whether it is installed now
pipVersion="$($pyx -m pip --version 2>&1)"
if [[ $pipVersion =~ $targetVersion ]]
then
echo found $pipVersion
else
echo pipVersion $pipVersion
echo pip for $errMsg
exit 1
fi
fi
# install ncscli distribution from pypi
$pyx -m pip install --user --upgrade --no-cache-dir ncscli
# install matplotlib for use by examples
$pyx -m pip install --user matplotlib
# install enlighten for use by examples
$pyx -m pip install --user enlighten
# install defusedxml for use by jmeter examples
$pyx -m pip install --user defusedxml
# install psutil for use by neoload checkAgents
$pyx -m pip install --user psutil
sitePackagesDir=$($pyx -m site --user-site)
examplesSrcDir=$sitePackagesDir/ncsexamples/
if [ -d "ncsexamples" ]; then
echo "leaving your ncsexamples dir unmodified"
echo \(upated examples may be found in $examplesSrcDir\)
else
# copy examples dir to a convenient editable location
echo copying $examplesSrcDir to ncsexamples
cp -p -r $examplesSrcDir ncsexamples
fi
# install rsync if it is not found
if hash rsync 2>/dev/null; then
echo has rsync
else
echo installing rsync
sudo apt-get -q update
sudo apt-get -q install rsync
fi
echo finished