4
4
RED=' \033[1;31m'
5
5
GREEN=' \033[1;32m'
6
6
RESET=' \033[0m'
7
+ GREY=' \033[2m'
7
8
8
9
# exit on error
9
10
10
11
# Array of supported versions
11
- declare -a versions=(' trusty' ' xenial' ' yakkety' );
12
+ declare -a versions=(' trusty' ' xenial' ' yakkety' ' bionic ' );
12
13
13
14
14
15
# check the version and extract codename of ubuntu if release codename not provided by user
@@ -27,9 +28,9 @@ function indent() {
27
28
# displays where we are, uses the indent function (above) to indent each line
28
29
function showStep ()
29
30
{
30
- echo -e " ${YELLOW } =====================================================" | indent
31
+ echo -e " ${GREY } =====================================================" | indent
31
32
echo -e " ${RESET} -----> $* " | indent
32
- echo -e " ${YELLOW } =====================================================${RESET} " | indent
33
+ echo -e " ${GREY } =====================================================${RESET} " | indent
33
34
}
34
35
35
36
# Grab the current directory
@@ -84,6 +85,37 @@ function checkaptget ()
84
85
85
86
}
86
87
88
+ # check to see if Python V2.7 is installed. Install it if it's not already there.
89
+ function checkPython2 ()
90
+ {
91
+ which python
92
+ if [ " $? " -ne 0 ]; then
93
+ showStep " No versions of Python installed. Installing Python 2.7"
94
+ sudo apt-get -y install python2.7 python-pip
95
+ RC=$?
96
+ if [[ $RC != 0 ]]; then
97
+ showStep " python 2.7 install exited with $RC "
98
+ exit $RC
99
+ fi
100
+
101
+ else
102
+ PYTHON_VERSION=` python -c ' import sys; version=sys.version_info[:3]; print("{0}.{1}.{2}".format(*version))' `
103
+ PYTHON_CHECK=` python -c ' import sys; version=sys.version_info[:3]; print("{0}.{1}.{2}".format(*version))' | grep " 2.7" `
104
+ showStep " python version is: ${PYTHON_VERSION} "
105
+ showStep " python check is: ${PYTHON_CHECK} "
106
+ if [[ ${PYTHON_CHECK} == " " ]]; then
107
+ showStep " python V2.7 not installed, installing it now."
108
+ sudo apt-get -y install python2.7 python-pip
109
+ RC=$?
110
+ if [[ $RC != 0 ]]; then
111
+ showStep " python 2.7 install exited with $RC "
112
+ exit $RC
113
+ fi
114
+ else
115
+ showStep " ${GREEN} python V2.7 already installed, skipping install step."
116
+ fi
117
+ fi
118
+ }
87
119
# check to see if nodeV8 is installed. install it if it's not already there.
88
120
function check4node ()
89
121
{
@@ -92,7 +124,7 @@ function check4node ()
92
124
if [ " $? " -ne 0 ]; then
93
125
nodeV8Install
94
126
else
95
- NODE_VERSION=` node --version | grep " V8 " `
127
+ NODE_VERSION=` node --version | grep " v8 " `
96
128
showStep " Node Version is ${NODE_VERSION} "
97
129
if [[ ${NODE_VERSION} == " " ]]; then
98
130
showStep " ${RED} found node $? installed, but not V8. installing Node V8"
@@ -119,6 +151,11 @@ function nodeV8Install()
119
151
# Execute nvm installation script
120
152
showStep " Executing nvm installation script"
121
153
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
154
+ RC=$?
155
+ if [[ $RC != 0 ]]; then
156
+ showStep " nvm install exited with $RC "
157
+ exit $RC
158
+ fi
122
159
123
160
showStep " Set up nvm environment without restarting the shell"
124
161
export NVM_DIR=" ${HOME} /.nvm"
@@ -127,6 +164,12 @@ function nodeV8Install()
127
164
128
165
showStep " Installing nodeJS"
129
166
nvm install 8.12.0
167
+ RC=$?
168
+ if [[ $RC != 0 ]]; then
169
+ showStep " nvm lts install exited with $RC "
170
+ exit $RC
171
+ fi
172
+
130
173
showStep " Configure nvm to use version 8"
131
174
nvm alias default 8.12.0
132
175
@@ -135,6 +178,11 @@ function nodeV8Install()
135
178
# Install the latest version of npm
136
179
showStep " Installing npm"
137
180
npm install npm@latest -g
181
+ RC=$?
182
+ if [[ $RC != 0 ]]; then
183
+ showStep " npm install exited with $RC "
184
+ exit $RC
185
+ fi
138
186
139
187
}
140
188
# check to see if git is installed. install it if it's not already there.
@@ -147,6 +195,11 @@ function check4git ()
147
195
sudo apt-add-repository -y ppa:git-core/ppa
148
196
sudo apt-get update
149
197
sudo apt-get install -y git
198
+ RC=$?
199
+ if [[ $RC != 0 ]]; then
200
+ showStep " git install exited with $RC "
201
+ exit $RC
202
+ fi
150
203
else
151
204
showStep " ${GREEN} git already installed"
152
205
fi
@@ -237,7 +290,7 @@ function printHeader ()
237
290
{
238
291
echo " "
239
292
echo -e " ${YELLOW} installation script for the Zero To Blockchain Series" | indent
240
- echo -e " ${RED } This is for Linux ONLY. It has been tested on Ubuntu 16.04 LTS" | indent
293
+ echo -e " ${GREEN } This is for Linux ONLY. It has been tested on Ubuntu 16 LTS and on Ubuntu 18 LTS" | indent
241
294
echo -e " ${YELLOW} Other versions of Linux are not supported via this script. " | indent
242
295
echo -e " ${YELLOW} The following will be downloaded by this script" | indent
243
296
echo -e " ${YELLOW} dos2unix, to correct scripts from hyperledger and composer" | indent
295
348
getCurrent
296
349
showStep " checking apt-get status"
297
350
checkaptget
351
+ showStep " checking python V2.7"
352
+ checkPython2
298
353
showStep " checking git"
299
354
check4git
300
355
showStep " checking nodejs"
0 commit comments