Skip to content

Commit f71a6d7

Browse files
author
Bob Dill
committed
update install scripts to support Ubuntu 18
1 parent bd8402e commit f71a6d7

5 files changed

+85
-22
lines changed

common_OSX.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
RED='\033[1;31m'
55
GREEN='\033[1;32m'
66
RESET='\033[0m'
7+
GREY='\033[2m'
78

89
# indent text on echo
910
function indent() {
@@ -20,9 +21,9 @@ export OS=$OS
2021
# displays where we are, uses the indent function (above) to indent each line
2122
function showStep ()
2223
{
23-
echo -e "${YELLOW}=====================================================" | indent
24+
echo -e "${GREY}=====================================================" | indent
2425
echo -e "${RESET}-----> $*" | indent
25-
echo -e "${YELLOW}=====================================================${RESET}" | indent
26+
echo -e "${GREY}=====================================================${RESET}" | indent
2627
}
2728

2829
# Grab the current directory

common_Ubuntu.sh

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
RED='\033[1;31m'
55
GREEN='\033[1;32m'
66
RESET='\033[0m'
7+
GREY='\033[2m'
78

89
# exit on error
910

1011
# Array of supported versions
11-
declare -a versions=('trusty' 'xenial' 'yakkety');
12+
declare -a versions=('trusty' 'xenial' 'yakkety' 'bionic');
1213

1314
# check the version and extract codename of ubuntu if release codename not provided by user
1415
lsb_release -a || (echo "Error: Release information not found, run script passing Ubuntu version codename as a parameter"; exit 1)
@@ -35,9 +36,9 @@ function indent() {
3536
# displays where we are, uses the indent function (above) to indent each line
3637
function showStep ()
3738
{
38-
echo -e "${YELLOW}=====================================================" | indent
39+
echo -e "${GREY}=====================================================" | indent
3940
echo -e "${RESET}-----> $*" | indent
40-
echo -e "${YELLOW}=====================================================${RESET}" | indent
41+
echo -e "${GREY}=====================================================${RESET}" | indent
4142
}
4243

4344
# Grab the current directory
@@ -55,7 +56,7 @@ function getCurrent()
5556
exit 1
5657
fi
5758
if [[ ${UBUNTU_VERSION} != "xenial" ]]; then
58-
showStep "Install Failed, need a Ubuntu 16 LTS. This is ${UBUNTU_VERSIO}"
59+
showStep "Install Failed, need an Ubuntu 16 LTS or Ubuntu 18 LTS. This is ${UBUNTU_VERSION}"
5960
exit 1
6061
fi
6162
}

setup_OSX.sh

+7-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
RED='\033[1;31m'
55
GREEN='\033[1;32m'
66
RESET='\033[0m'
7+
GREY='\033[2m'
78

89
# indent text on echo
910
function indent() {
@@ -17,9 +18,9 @@ function indent() {
1718
# displays where we are, uses the indent function (above) to indent each line
1819
function showStep ()
1920
{
20-
echo -e "${YELLOW}=====================================================" | indent
21+
echo -e "${GREY}=====================================================" | indent
2122
echo -e "${RESET}-----> $*" | indent
22-
echo -e "${YELLOW}=====================================================${RESET}" | indent
23+
echo -e "${GREY}=====================================================${RESET}" | indent
2324
}
2425

2526
# Grab the current directory
@@ -193,6 +194,10 @@ function install_hlf ()
193194
dos2unix `ls *.sh`
194195
showStep "getting docker images for HyperLedger Fabric V1"
195196
export FABRIC_VERSION=hlfv1
197+
echo 'FABRIC_VERSION="hlfv1"' >> ~/.bash_profile
198+
# the following line is here to ensure that the subsequent echos start on a new line.
199+
echo ' ' >> ~/.bash_profile
200+
echo 'FABRIC_VERSION is ${FABRIC_VERSION}'
196201
cd $HLF_INSTALL_PATH
197202
./downloadFabric.sh
198203
showStep "installing platform specific binaries for OSX"
@@ -209,9 +214,6 @@ function install_hlf ()
209214
export PATH=$HLF_INSTALL_PATH/bin:$PATH
210215
export HLF_INSTALL_PATH=$HLF_INSTALL_PATH
211216
showStep "updating .bash_profile with new paths"
212-
# ensure that the following lines start with a new line
213-
echo " " >>~/.bash_profile
214-
echo "export FABRIC_VERSION=hlfv1" >>~/.bash_profile
215217
echo "export HLF_INSTALL_PATH=${HLF_INSTALL_PATH}" >>~/.bash_profile
216218
echo "PATH=${HLF_INSTALL_PATH}/bin:"'$PATH' >>~/.bash_profile
217219
else

setup_Ubuntu_Part_1.sh

+60-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
RED='\033[1;31m'
55
GREEN='\033[1;32m'
66
RESET='\033[0m'
7+
GREY='\033[2m'
78

89
# exit on error
910

1011
# Array of supported versions
11-
declare -a versions=('trusty' 'xenial' 'yakkety');
12+
declare -a versions=('trusty' 'xenial' 'yakkety' 'bionic');
1213

1314

1415
# check the version and extract codename of ubuntu if release codename not provided by user
@@ -27,9 +28,9 @@ function indent() {
2728
# displays where we are, uses the indent function (above) to indent each line
2829
function showStep ()
2930
{
30-
echo -e "${YELLOW}=====================================================" | indent
31+
echo -e "${GREY}=====================================================" | indent
3132
echo -e "${RESET}-----> $*" | indent
32-
echo -e "${YELLOW}=====================================================${RESET}" | indent
33+
echo -e "${GREY}=====================================================${RESET}" | indent
3334
}
3435

3536
# Grab the current directory
@@ -84,6 +85,37 @@ function checkaptget ()
8485

8586
}
8687

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+
}
87119
# check to see if nodeV8 is installed. install it if it's not already there.
88120
function check4node ()
89121
{
@@ -92,7 +124,7 @@ function check4node ()
92124
if [ "$?" -ne 0 ]; then
93125
nodeV8Install
94126
else
95-
NODE_VERSION=`node --version | grep "V8"`
127+
NODE_VERSION=`node --version | grep "v8"`
96128
showStep "Node Version is ${NODE_VERSION}"
97129
if [[ ${NODE_VERSION} == "" ]]; then
98130
showStep "${RED}found node $? installed, but not V8. installing Node V8"
@@ -119,6 +151,11 @@ function nodeV8Install()
119151
# Execute nvm installation script
120152
showStep "Executing nvm installation script"
121153
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
122159

123160
showStep "Set up nvm environment without restarting the shell"
124161
export NVM_DIR="${HOME}/.nvm"
@@ -127,6 +164,12 @@ function nodeV8Install()
127164

128165
showStep "Installing nodeJS"
129166
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+
130173
showStep "Configure nvm to use version 8"
131174
nvm alias default 8.12.0
132175

@@ -135,6 +178,11 @@ function nodeV8Install()
135178
# Install the latest version of npm
136179
showStep "Installing npm"
137180
npm install npm@latest -g
181+
RC=$?
182+
if [[ $RC != 0 ]]; then
183+
showStep "npm install exited with $RC"
184+
exit $RC
185+
fi
138186

139187
}
140188
# check to see if git is installed. install it if it's not already there.
@@ -147,6 +195,11 @@ function check4git ()
147195
sudo apt-add-repository -y ppa:git-core/ppa
148196
sudo apt-get update
149197
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
150203
else
151204
showStep "${GREEN}git already installed"
152205
fi
@@ -237,7 +290,7 @@ function printHeader ()
237290
{
238291
echo ""
239292
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
241294
echo -e "${YELLOW}Other versions of Linux are not supported via this script. " | indent
242295
echo -e "${YELLOW}The following will be downloaded by this script" | indent
243296
echo -e "${YELLOW}dos2unix, to correct scripts from hyperledger and composer" | indent
@@ -295,6 +348,8 @@ do
295348
getCurrent
296349
showStep "checking apt-get status"
297350
checkaptget
351+
showStep "checking python V2.7"
352+
checkPython2
298353
showStep "checking git"
299354
check4git
300355
showStep "checking nodejs"

setup_Ubuntu_Part_2.sh

+10-6
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
RED='\033[1;31m'
66
GREEN='\033[1;32m'
77
RESET='\033[0m'
8+
GREY='\033[2m'
89

910
# exit on error
1011

1112
# Array of supported versions
12-
declare -a versions=('trusty' 'xenial' 'yakkety');
13+
declare -a versions=('trusty' 'xenial' 'yakkety' 'bionic');
1314

1415
# check the version and extract codename of ubuntu if release codename not provided by user
1516
lsb_release -a || (echo "Error: Release information not found, run script passing Ubuntu version codename as a parameter"; exit 1)
@@ -36,9 +37,9 @@ function indent() {
3637
# displays where we are, uses the indent function (above) to indent each line
3738
function showStep ()
3839
{
39-
echo -e "${YELLOW}=====================================================" | indent
40+
echo -e "${GREY}=====================================================" | indent
4041
echo -e "${RESET}-----> $*" | indent
41-
echo -e "${YELLOW}=====================================================${RESET}" | indent
42+
echo -e "${GREY}=====================================================${RESET}" | indent
4243
}
4344

4445
# Grab the current directory
@@ -55,8 +56,11 @@ function getCurrent()
5556
showStep "Install Failed, need a 64 bit system. This is ${UBUNTU_ARCH}"
5657
exit 1
5758
fi
58-
if [[ ${UBUNTU_VERSION} != "xenial" ]]; then
59-
showStep "Install Failed, need a Ubuntu 16 LTS. This is ${UBUNTU_VERSIO}"
59+
# check version is supported
60+
if echo ${versions[@]} | grep -q -w ${CODENAME}; then
61+
echo "Installing Hyperledger Composer prereqs for Ubuntu ${CODENAME}"
62+
else
63+
echo "Error: Ubuntu ${CODENAME} is not supported"
6064
exit 1
6165
fi
6266
}
@@ -123,7 +127,7 @@ function printHeader ()
123127
{
124128
echo ""
125129
echo -e "${YELLOW}installation script for the Zero To Blockchain Series" | indent
126-
echo -e "${RED}This is for Linux ONLY. It has been tested on Ubuntu 16.04 LTS" | indent
130+
echo -e "${RED}This is for Linux ONLY. It has been tested on Ubuntu 16 LTS and on Ubuntu 18 LTS" | indent
127131
echo -e "${YELLOW}Other versions of Linux are not supported via this script. " | indent
128132
echo -e "${YELLOW}The following will be downloaded by this script" | indent
129133
echo -e "${YELLOW}The script will finish by downloading the docker images for hyperledger${RESET}" | indent

0 commit comments

Comments
 (0)