From f71a6d70b455fbb13b013173555ec189b4c56aa7 Mon Sep 17 00:00:00 2001 From: Bob Dill Date: Tue, 18 Dec 2018 06:52:52 -0700 Subject: [PATCH] update install scripts to support Ubuntu 18 --- common_OSX.sh | 5 ++-- common_Ubuntu.sh | 9 +++--- setup_OSX.sh | 12 ++++---- setup_Ubuntu_Part_1.sh | 65 ++++++++++++++++++++++++++++++++++++++---- setup_Ubuntu_Part_2.sh | 16 +++++++---- 5 files changed, 85 insertions(+), 22 deletions(-) diff --git a/common_OSX.sh b/common_OSX.sh index b28815f..7ae8671 100755 --- a/common_OSX.sh +++ b/common_OSX.sh @@ -4,6 +4,7 @@ RED='\033[1;31m' GREEN='\033[1;32m' RESET='\033[0m' + GREY='\033[2m' # indent text on echo function indent() { @@ -20,9 +21,9 @@ export OS=$OS # displays where we are, uses the indent function (above) to indent each line function showStep () { - echo -e "${YELLOW}=====================================================" | indent + echo -e "${GREY}=====================================================" | indent echo -e "${RESET}-----> $*" | indent - echo -e "${YELLOW}=====================================================${RESET}" | indent + echo -e "${GREY}=====================================================${RESET}" | indent } # Grab the current directory diff --git a/common_Ubuntu.sh b/common_Ubuntu.sh index fc3f420..deceebf 100755 --- a/common_Ubuntu.sh +++ b/common_Ubuntu.sh @@ -4,11 +4,12 @@ RED='\033[1;31m' GREEN='\033[1;32m' RESET='\033[0m' + GREY='\033[2m' # exit on error # Array of supported versions -declare -a versions=('trusty' 'xenial' 'yakkety'); +declare -a versions=('trusty' 'xenial' 'yakkety' 'bionic'); # check the version and extract codename of ubuntu if release codename not provided by user 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() { # displays where we are, uses the indent function (above) to indent each line function showStep () { - echo -e "${YELLOW}=====================================================" | indent + echo -e "${GREY}=====================================================" | indent echo -e "${RESET}-----> $*" | indent - echo -e "${YELLOW}=====================================================${RESET}" | indent + echo -e "${GREY}=====================================================${RESET}" | indent } # Grab the current directory @@ -55,7 +56,7 @@ function getCurrent() exit 1 fi if [[ ${UBUNTU_VERSION} != "xenial" ]]; then - showStep "Install Failed, need a Ubuntu 16 LTS. This is ${UBUNTU_VERSIO}" + showStep "Install Failed, need an Ubuntu 16 LTS or Ubuntu 18 LTS. This is ${UBUNTU_VERSION}" exit 1 fi } diff --git a/setup_OSX.sh b/setup_OSX.sh index 307da65..8eda0b6 100755 --- a/setup_OSX.sh +++ b/setup_OSX.sh @@ -4,6 +4,7 @@ RED='\033[1;31m' GREEN='\033[1;32m' RESET='\033[0m' + GREY='\033[2m' # indent text on echo function indent() { @@ -17,9 +18,9 @@ function indent() { # displays where we are, uses the indent function (above) to indent each line function showStep () { - echo -e "${YELLOW}=====================================================" | indent + echo -e "${GREY}=====================================================" | indent echo -e "${RESET}-----> $*" | indent - echo -e "${YELLOW}=====================================================${RESET}" | indent + echo -e "${GREY}=====================================================${RESET}" | indent } # Grab the current directory @@ -193,6 +194,10 @@ function install_hlf () dos2unix `ls *.sh` showStep "getting docker images for HyperLedger Fabric V1" export FABRIC_VERSION=hlfv1 + echo 'FABRIC_VERSION="hlfv1"' >> ~/.bash_profile + # the following line is here to ensure that the subsequent echos start on a new line. + echo ' ' >> ~/.bash_profile + echo 'FABRIC_VERSION is ${FABRIC_VERSION}' cd $HLF_INSTALL_PATH ./downloadFabric.sh showStep "installing platform specific binaries for OSX" @@ -209,9 +214,6 @@ function install_hlf () export PATH=$HLF_INSTALL_PATH/bin:$PATH export HLF_INSTALL_PATH=$HLF_INSTALL_PATH showStep "updating .bash_profile with new paths" - # ensure that the following lines start with a new line - echo " " >>~/.bash_profile - echo "export FABRIC_VERSION=hlfv1" >>~/.bash_profile echo "export HLF_INSTALL_PATH=${HLF_INSTALL_PATH}" >>~/.bash_profile echo "PATH=${HLF_INSTALL_PATH}/bin:"'$PATH' >>~/.bash_profile else diff --git a/setup_Ubuntu_Part_1.sh b/setup_Ubuntu_Part_1.sh index 4c507f2..80ff4c8 100755 --- a/setup_Ubuntu_Part_1.sh +++ b/setup_Ubuntu_Part_1.sh @@ -4,11 +4,12 @@ RED='\033[1;31m' GREEN='\033[1;32m' RESET='\033[0m' + GREY='\033[2m' # exit on error # Array of supported versions -declare -a versions=('trusty' 'xenial' 'yakkety'); +declare -a versions=('trusty' 'xenial' 'yakkety' 'bionic'); # check the version and extract codename of ubuntu if release codename not provided by user @@ -27,9 +28,9 @@ function indent() { # displays where we are, uses the indent function (above) to indent each line function showStep () { - echo -e "${YELLOW}=====================================================" | indent + echo -e "${GREY}=====================================================" | indent echo -e "${RESET}-----> $*" | indent - echo -e "${YELLOW}=====================================================${RESET}" | indent + echo -e "${GREY}=====================================================${RESET}" | indent } # Grab the current directory @@ -84,6 +85,37 @@ function checkaptget () } +# check to see if Python V2.7 is installed. Install it if it's not already there. +function checkPython2 () +{ + which python + if [ "$?" -ne 0 ]; then + showStep "No versions of Python installed. Installing Python 2.7" + sudo apt-get -y install python2.7 python-pip + RC=$? + if [[ $RC != 0 ]]; then + showStep "python 2.7 install exited with $RC" + exit $RC + fi + + else + PYTHON_VERSION=`python -c 'import sys; version=sys.version_info[:3]; print("{0}.{1}.{2}".format(*version))'` + PYTHON_CHECK=`python -c 'import sys; version=sys.version_info[:3]; print("{0}.{1}.{2}".format(*version))' | grep "2.7"` + showStep "python version is: ${PYTHON_VERSION}" + showStep "python check is: ${PYTHON_CHECK}" + if [[ ${PYTHON_CHECK} == "" ]]; then + showStep "python V2.7 not installed, installing it now." + sudo apt-get -y install python2.7 python-pip + RC=$? + if [[ $RC != 0 ]]; then + showStep "python 2.7 install exited with $RC" + exit $RC + fi + else + showStep "${GREEN}python V2.7 already installed, skipping install step." + fi + fi +} # check to see if nodeV8 is installed. install it if it's not already there. function check4node () { @@ -92,7 +124,7 @@ function check4node () if [ "$?" -ne 0 ]; then nodeV8Install else - NODE_VERSION=`node --version | grep "V8"` + NODE_VERSION=`node --version | grep "v8"` showStep "Node Version is ${NODE_VERSION}" if [[ ${NODE_VERSION} == "" ]]; then showStep "${RED}found node $? installed, but not V8. installing Node V8" @@ -119,6 +151,11 @@ function nodeV8Install() # Execute nvm installation script showStep "Executing nvm installation script" curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash + RC=$? + if [[ $RC != 0 ]]; then + showStep "nvm install exited with $RC" + exit $RC + fi showStep "Set up nvm environment without restarting the shell" export NVM_DIR="${HOME}/.nvm" @@ -127,6 +164,12 @@ function nodeV8Install() showStep "Installing nodeJS" nvm install 8.12.0 + RC=$? + if [[ $RC != 0 ]]; then + showStep "nvm lts install exited with $RC" + exit $RC + fi + showStep "Configure nvm to use version 8" nvm alias default 8.12.0 @@ -135,6 +178,11 @@ function nodeV8Install() # Install the latest version of npm showStep "Installing npm" npm install npm@latest -g + RC=$? + if [[ $RC != 0 ]]; then + showStep "npm install exited with $RC" + exit $RC + fi } # check to see if git is installed. install it if it's not already there. @@ -147,6 +195,11 @@ function check4git () sudo apt-add-repository -y ppa:git-core/ppa sudo apt-get update sudo apt-get install -y git + RC=$? + if [[ $RC != 0 ]]; then + showStep "git install exited with $RC" + exit $RC + fi else showStep "${GREEN}git already installed" fi @@ -237,7 +290,7 @@ function printHeader () { echo "" echo -e "${YELLOW}installation script for the Zero To Blockchain Series" | indent - echo -e "${RED}This is for Linux ONLY. It has been tested on Ubuntu 16.04 LTS" | indent + echo -e "${GREEN}This is for Linux ONLY. It has been tested on Ubuntu 16 LTS and on Ubuntu 18 LTS" | indent echo -e "${YELLOW}Other versions of Linux are not supported via this script. " | indent echo -e "${YELLOW}The following will be downloaded by this script" | indent echo -e "${YELLOW}dos2unix, to correct scripts from hyperledger and composer" | indent @@ -295,6 +348,8 @@ do getCurrent showStep "checking apt-get status" checkaptget + showStep "checking python V2.7" + checkPython2 showStep "checking git" check4git showStep "checking nodejs" diff --git a/setup_Ubuntu_Part_2.sh b/setup_Ubuntu_Part_2.sh index a81e894..767551b 100755 --- a/setup_Ubuntu_Part_2.sh +++ b/setup_Ubuntu_Part_2.sh @@ -5,11 +5,12 @@ RED='\033[1;31m' GREEN='\033[1;32m' RESET='\033[0m' + GREY='\033[2m' # exit on error # Array of supported versions -declare -a versions=('trusty' 'xenial' 'yakkety'); +declare -a versions=('trusty' 'xenial' 'yakkety' 'bionic'); # check the version and extract codename of ubuntu if release codename not provided by user 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() { # displays where we are, uses the indent function (above) to indent each line function showStep () { - echo -e "${YELLOW}=====================================================" | indent + echo -e "${GREY}=====================================================" | indent echo -e "${RESET}-----> $*" | indent - echo -e "${YELLOW}=====================================================${RESET}" | indent + echo -e "${GREY}=====================================================${RESET}" | indent } # Grab the current directory @@ -55,8 +56,11 @@ function getCurrent() showStep "Install Failed, need a 64 bit system. This is ${UBUNTU_ARCH}" exit 1 fi - if [[ ${UBUNTU_VERSION} != "xenial" ]]; then - showStep "Install Failed, need a Ubuntu 16 LTS. This is ${UBUNTU_VERSIO}" + # check version is supported + if echo ${versions[@]} | grep -q -w ${CODENAME}; then + echo "Installing Hyperledger Composer prereqs for Ubuntu ${CODENAME}" + else + echo "Error: Ubuntu ${CODENAME} is not supported" exit 1 fi } @@ -123,7 +127,7 @@ function printHeader () { echo "" echo -e "${YELLOW}installation script for the Zero To Blockchain Series" | indent - echo -e "${RED}This is for Linux ONLY. It has been tested on Ubuntu 16.04 LTS" | indent + echo -e "${RED}This is for Linux ONLY. It has been tested on Ubuntu 16 LTS and on Ubuntu 18 LTS" | indent echo -e "${YELLOW}Other versions of Linux are not supported via this script. " | indent echo -e "${YELLOW}The following will be downloaded by this script" | indent echo -e "${YELLOW}The script will finish by downloading the docker images for hyperledger${RESET}" | indent