Skip to content

Commit

Permalink
update install scripts to support Ubuntu 18
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob Dill committed Dec 18, 2018
1 parent bd8402e commit f71a6d7
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 22 deletions.
5 changes: 3 additions & 2 deletions common_OSX.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
RED='\033[1;31m'
GREEN='\033[1;32m'
RESET='\033[0m'
GREY='\033[2m'

# indent text on echo
function indent() {
Expand All @@ -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
Expand Down
9 changes: 5 additions & 4 deletions common_Ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
}
12 changes: 7 additions & 5 deletions setup_OSX.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
RED='\033[1;31m'
GREEN='\033[1;32m'
RESET='\033[0m'
GREY='\033[2m'

# indent text on echo
function indent() {
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand Down
65 changes: 60 additions & 5 deletions setup_Ubuntu_Part_1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 ()
{
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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

Expand All @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
16 changes: 10 additions & 6 deletions setup_Ubuntu_Part_2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f71a6d7

Please sign in to comment.