<file_sep>#!/bin/bash

### https://github.com/adnanjee/hyperledger-fabric.git ###

### Download golang ###

echo "Downloading golang"

curl -O https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz

tar xvf go1.14.2.linux-amd64.tar.gz

### Moving go to /usr/local ###

sudo mv  go /usr/local

rm go1.14.2.linux-amd64.tar.gz


# If GOROOT already set then DO Not set it again
if [ -z $GOROOT ]
then
    echo "export GOROOT=/usr/local/go" >> ~/.profile
    echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.profile
    echo "export GOPATH=/home/$USER/gopath" >> ~/.profile
    echo "### Updated .profile with GOROOT/GOPATH/PATH ###"

    echo "export GOROOT=/usr/local/go" >> ~/.bashrc
    echo "export GOPATH=/home/$USER/gopath" >> ~/.bashrc
    echo "### Updated .profile with GOROOT/GOPATH/PATH ###"


else
    echo "### No Change made to .profile ###"
fi

. ~/.profile
. ~/.bashrc

echo "### Done ###"
<file_sep>#!/bin/bash

### https://github.com/adnanjee/hyperledger-fabric.git ###

export PATH=$PATH:$GOROOT/bin

. ~/.profile
. ~/.bashrc

echo "GOPATH=$GOPATH"
echo "GOROOT=$GOROOT"

echo "### Starting to Download Fabric ###"

curl -sSL https://bit.ly/2ysbOFE | bash -s -- 2.0.1 1.4.6 0.4.18

echo "### Copy the binaries from fabric-samples/bin to /usr/local/bin ###"

sudo cp fabric-samples/bin/*    /usr/local/bin

echo "### Copy the binaries from fabric-samples/bin to bin folder for future use ###"

mkdir -p ${PWD}/../bin
cp fabric-samples/bin/*    ${PWD}/../bin

# The sample chaincode is under the subfolder go and need to come under gopath/src subfolder

echo "### Setting up the src folder under $GOPATH /gopath/src ###"

mkdir -p $GOPATH/src

echo "### copying chaincodes from fabric-samples folder in gopath/src folder ###"

cp -r fabric-samples/chaincode/chaincode_example02/*    $GOPATH/src

# Move fabric-samples to hyperledger-1.3.0 directory

mv fabric-samples ${PWD}/../ 

# This downloads the shim code 

echo "### Setting up the HLF Shim ###"

mkdir -p  $GOPATH/src/github.com/hyperledger
go get -u --tags nopkcs11 github.com/hyperledger/fabric/core/chaincode/shim

. ~/.profile
. ~/.bashrc

echo "### Installaion is completed ###"
<file_sep>### https://github.com/adnanjee/hyperledger-fabric-1.4.git ###

### Installing Development Environment ###

echo "Installing Composer Cli Tools"

npm install -g composer-cli@0.20

echo "Installing Composer REST Server"

npm install -g composer-rest-server@0.20

echo "Installing Utility for Generating Application Assets"

npm install -g generator-hyperledger-composer@0.20

echo "Installing Yeoman"

npm install -g yo

echo "Installing Composer Playground"

npm install -g composer-playground@0.20

. ~/.profile
. ~/.bashrc

echo "Installaions Done"
<file_sep>#!/bin/bash

### https://github.com/adnanjee/hyperledger-fabric-1.4.git ###

# Installs the JQ Utility

sudo apt-get install -y jq
