From 9928528ff6c924eca6204ce3fe9e6b27b77dde8c Mon Sep 17 00:00:00 2001 From: le Date: Tue, 11 May 2021 17:33:30 -0500 Subject: [PATCH] install dependecies script --- README.md | 8 +- app/package-lock.json | 6 +- app/package.json | 2 +- install-dependencies.sh | 158 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 169 insertions(+), 5 deletions(-) create mode 100755 install-dependencies.sh diff --git a/README.md b/README.md index b03fa88..3676726 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,12 @@ Another option: npm install --global --production windows-build-toolsnpm config set msvs_version 2015 --global ``` +## Linux Dependencies + +```bash +./install-dependencies.sh +``` + # Runing ## docker-compose @@ -46,4 +52,4 @@ In `./app/` there are scripts to test sawtooth, kafka and mongo. ## Suggestions Edit `up.sh` to only run the code that is required. -Edit `./docker-compose/docker-compose.yaml` so that only the required containers are run \ No newline at end of file +Edit `./docker-compose/docker-compose.yaml` so that only the required containers are run diff --git a/app/package-lock.json b/app/package-lock.json index 2355bcc..3fbf10f 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -504,9 +504,9 @@ } }, "node-rdkafka": { - "version": "2.9.1", - "resolved": "https://registry.npmjs.org/node-rdkafka/-/node-rdkafka-2.9.1.tgz", - "integrity": "sha512-C5EVDZlDG+5D8KXiz2zKwEiLWIGW5Z1mkVFRzp13T4mrbXz+ESyjrDSLIj7aoUIi5+T10H9p1wwLZJBh9ivjLg==", + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/node-rdkafka/-/node-rdkafka-2.10.1.tgz", + "integrity": "sha512-yRb9Y90ipef4X+S/UbvQedUNtKZONa9RR6hCpAaGD83NqUga/uxTofdRQG8bm7SEh/DNuaifIJjRzLcoG9nUSQ==", "requires": { "bindings": "^1.3.1", "nan": "^2.14.0" diff --git a/app/package.json b/app/package.json index a8fd3f2..d970f02 100644 --- a/app/package.json +++ b/app/package.json @@ -13,7 +13,7 @@ "dotenv": "^8.2.0", "lodash": "^4.17.20", "mongodb": "^3.6.2", - "node-rdkafka": "^2.9.1", + "node-rdkafka": "^2.10.1", "sawtooth-sdk": "^1.0.5", "underscore": "^1.11.0" }, diff --git a/install-dependencies.sh b/install-dependencies.sh new file mode 100755 index 0000000..17f95ba --- /dev/null +++ b/install-dependencies.sh @@ -0,0 +1,158 @@ +#!/bin/bash -x + + +#Script based on: +# https://medium.com/@eSizeDave/https-medium-com-esizedave-how-to-install-hyperledger-fabric-1-2-on-ubuntu-16-04-lts-ecdfa4dcec72 +# https://hyperledger-fabric.readthedocs.io/en/latest/prereqs.html + +if [[ "$EUID" -ne 0 ]]; then + echo "Must run with sudo" + exit +fi + +main(){ + + if [[ $1 = "--version" ]]; then + show_versions + exit 0 + fi + + apt-get update + + sudo apt-get install libtool pkg-config build-essential autoconf automake -y + + install_docker + install_docker_compose + #install_go + install_node + nvm install v10 + #apt-get install python build-essential -y + #install_fabric_samples + echo "lougout and login" +} + +usage () { + echo "$PROGNAME: usage: $PROGNAME [--version]" + return +} + + + +install_docker(){ + # Docker + # https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-docker-ce + + apt-get install \ + apt-transport-https \ + ca-certificates \ + curl \ + gnupg-agent \ + software-properties-common -y + + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - + + apt-key fingerprint 0EBFCD88 + + add-apt-repository \ + "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ + $(lsb_release -cs) \ + stable" + + + apt-get update + + apt-get install docker-ce docker-ce-cli containerd.io -y + + # https://docs.docker.com/install/linux/linux-postinstall/ + groupadd docker + usermod -aG docker $SUDO_USER + + # newgrp docker + sudo -u $SUDO_USER docker run hello-world + + docker --version +} + +install_docker_compose(){ + + # https://docs.docker.com/compose/install/ + + curl -L "https://github.com/docker/compose/releases/download/1.25.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + + chmod +x /usr/local/bin/docker-compose + + # https://docs.docker.com/compose/completion/ + curl -L https://raw.githubusercontent.com/docker/compose/1.25.3/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose + + docker-compose --version +} + +install_go(){ + + # https://golang.org/doc/install + + sudo -u $SUDO_USER curl https://dl.google.com/go/go1.13.7.linux-amd64.tar.gz -o go.tar.gz + + sudo -u $SUDO_USER sha256sum go.tar.gz + sudo -u $SUDO_USER tar -xvf go.tar.gz + mv go /usr/local + rm ./go.tar.gz + + sudo -u $SUDO_USER tee -a ~/.profile <<- '_EOF_' + + # GO Configuration + export GOPATH=$HOME/go + export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin + + _EOF_ + + export GOPATH=$HOME/go + export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin + + go version +} + +install_node(){ + # https://github.com/nvm-sh/nvm + + sudo -u $SUDO_USER sh -c 'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash' + + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm + [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + + nvm install 10 + nvm use node 10 + + node --version +} + +install_fabric_samples(){ + # https://hyperledger-fabric.readthedocs.io/en/release-1.4/install.html + curl -sSL https://bit.ly/2ysbOFE | bash -s -- 2.0.0 1.4.4 0.4.18 + mkidr -p /usr/local/hyperledger + mv ./fabric-samples /usr/local/hyperledger/ + + sudo -u $SUDO_USER tee -a ~/.profile <<- '_EOF_' + + # Fabric bins + export PATH=/usr/local/hyperledger/bin:$PATH + + _EOF_ + + export PATH=/usr/local/hyperledger/bin:$PATH +} + +show_versions(){ + echo "-----------------------------" + docker --version + docker-compose --version + go version + node --version + python --version + peer version + orderer version + fabric-ca-server version +} + +main "$@"