Mac自动化部署Hyperledger Fabric环境shell脚本

https://github.com/mh4u/hyperledger-install4mac

#!/bin/sh
# by xx

#===============安装环境===============#
# 1.检查Docker是否安装
# https://store.docker.com/editions/community/docker-ce-desktop-mac

which "docker" >/dev/null
if [ $? -ne 0 ]; then
    #Docker下载地址https://store.docker.com/editions/community/docker-ce-desktop-mac
    #设置国内镜像https://registry.docker-cn.com
    echo "请先安装Docker"
    exit 1
fi

# 2.检查Go是否安装
which "go" >/dev/null
if [ $? -ne 0 ]; then
    # 安装Go,默认安装到/usr/local/Cellar/go/x.xx.x
    brew install go
    # 设置Go环境变量
    echo "# Go" >>~/.bash_profile
    echo "export GOPATH=\$HOME/Desktop/go" >>~/.bash_profile
    # echo "export GOROOT=/usr/local/Cellar/go" >>.bash_profile
    echo "export GOBIN=\$GOPAHT/bin" >>~/.bash_profile
    echo "export PATH=\$PATH:\$GOPATH:\$GOBIN" >>~/.bash_profile
    source ~/.bash_profile
fi

# 3.检查Node是否安装
which "node" >/dev/null
if [ $? -ne 0 ]; then
    # 安装nvm,在https://github.com/creationix/nvm#install-script中查看最新版本
    curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
    echo "# nvm" >>~/.bash_profile
    echo "export NVM_DIR=\"\$HOME/.nvm\"" >>~/.bash_profile
    echo "[ -s \"\$NVM_DIR/nvm.sh\" ] && \. \"\$NVM_DIR/nvm.sh\"" >>.bash_profile
    source ~/.bash_profile

    # 通过nvm安装node
    # Node.js version 9.x is not supported at this time.
    # version 8.9.x or greater
    nvm install 8.11.2
    # 更新npm
    npm i -g npm
    nvm use 8.11.2
fi

#===============安装Hyperleder fabric===============#
cd ~/Desktop
mkdir -p go/src/github.com/hyperledger
cd go/src/github.com/hyperledger
#下载fabric
git clone https://github.com/hyperledger/fabric.git
git checkout v1.1.0
#安装镜像
cd fabric/scripts
bash bootstrap.sh
cp -rf bin/ ./../examples/
cd ./../examples/e2e_cli/

# docker-compose是1.21版本会出现network e2ecli_default not found
# 解决办法是 将e2e_cli/base目录下的peer-base.yaml里网络名改成如下名称即可
#- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=e2e_cli_default
if [[ $(docker-compose -v) =~ "1.21" ]]; then
    #mac 下-i后要加上 ""
    sed -i "" 's/e2ecli_default/e2e_cli_default/' base/peer-base.yaml
fi

#清理容器
docker rm -f $(docker ps -aq)
#启动Hyperledger网络环境测试本地部署是否正确
./network_setup.sh up
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值