Skip to content

Instantly share code, notes, and snippets.

@ckeyer
Created October 6, 2016 03:58
Show Gist options
  • Save ckeyer/abdb1460d098b20fa68fe1cc67916e1d to your computer and use it in GitHub Desktop.
Save ckeyer/abdb1460d098b20fa68fe1cc67916e1d to your computer and use it in GitHub Desktop.
#!/bin/bash
###
### Centos 7 x64
###
set -ex;
yum update -y;
yum install -y make gcc gcc-c++ snappy snappy-devel zlib zlib-devel bzip2 bzip2-devel vim git unzip wget;
# Install Docker.
if which docker 2>/dev/null; then
echo "docker already exists"
else
tee /etc/yum.repos.d/docker.repo <<-'EOF'
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF
yum install -y docker-engine
systemctl enable docker.service
systemctl start docker
fi
# Install Golang
if which go 2>/dev/null; then
echo "go already exists"
else
export GOROOT=/usr/local/go
export GOPATH=/opt/gopath
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
cd /usr/local
wget https://storage.googleapis.com/golang/go1.7.linux-amd64.tar.gz
tar zxf go1.7.linux-amd64.tar.gz
rm -f go1.7.linux-amd64.tar.gz
fi
### install protoc-gen-go go-bindata
which protoc-gen-go | go get github.com/golang/protobuf/protoc-gen-go
which go-bindata | go get github.com/ckeyer/go-bindata/...
### install RocksDB
if [ -f /lib64/librocksdb.so.4.1 ]; then
echo "/lib64/librocksdb.so.4.1 already exists"
else
cd /tmp
wget https://github.com/facebook/rocksdb/archive/v4.1.tar.gz
tar zxf v4.1.tar.gz
rm -f v4.1.tar.gz
cd rocksdb-4.1
PORTABLE=1 make shared_lib
INSTALL_PATH=/usr/local make install-shared
ldconfig
ln -s /usr/local/lib/librocksdb.so.4.1.0 /lib64/librocksdb.so.4.1
rm -rf /tmp/*
fi
### Install protoc
if which protoc 2>/dev/null; then
echo "protoc already exists"
else
cd /usr
wget https://github.com/google/protobuf/releases/download/v3.0.2/protoc-3.0.2-linux-x86_64.zip
unzip protoc-3.0.2-linux-x86_64.zip
rm -f protoc-3.0.2-linux-x86_64.zip
fi
### Fabric
if [ ! -d $GOPATH/src/github.com/hyperledger/fabric ]; then
mkdir -p $GOPATH/src/github.com/hyperledger
fi
cd $GOPATH/src/github.com/hyperledger
if [ -d fabric ]; then
rm -rf fabric
fi
git clone https://github.com/ckeyer/fabric.git
cd fabric
go build -o obc-peer peer/main.go
go build -o obc-ca membersrvc/server.go
./obc-ca &
# CORE_SECURITY_ENROLLID=test_vp0
# CORE_SECURITY_ENROLLSECRET=MwYpmSRjupbT
# CORE_PEER_DISCOVERY_ROOTNODE=104.236.230.10:30303 \
# CORE_PEER_PKI_ECA_PADDR=104.236.230.10:5000 \
CORE_PEER_ID=vp0 \
CORE_PBFT_GENERAL_BYZANTINE=true \
CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=pbft \
CORE_PBFT_GENERAL_BATCHSIZE=1 \
CORE_PBFT_GENERAL_N=4 \
CORE_PBFT_GENERAL_K=2 \
./obc-peer node start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment