github.com/adnan-c/fabric_e2e_couchdb@v0.6.1-preview.0.20170228180935-21ce6b23cf91/devenv/setupRHELonZ.sh (about)

     1  #!/bin/bash
     2  
     3  # Development on Z is done on the native OS, not in Vagrant. This script can be 
     4  # used to set things up in RHEL on Z, similar to devenv/setup.sh which does the 
     5  # same for Vagrant. 
     6  # See https://github.com/hyperledger/fabric/blob/master/docs/dev-setup/install.md
     7  #
     8  # To get started:
     9  #       sudo su
    10  #       yum install git
    11  #       mkdir -p $HOME/git/src/github.com/hyperledger
    12  #       cd $HOME/git/src/github.com/hyperledger
    13  #       git clone http://gerrit.hyperledger.org/r/fabric
    14  #       source fabric/devenv/setupRHELonZ.sh
    15  #       make peer unit-test behave
    16  
    17  if [ xroot != x$(whoami) ]
    18  then
    19     echo "You must run as root (Hint: sudo su)"
    20     exit
    21  fi
    22  
    23  if [ -n -d $HOME/git/src/github.com/hyperledger/fabric ]
    24  then
    25      echo "Script fabric code is under $HOME/git/src/github.com/hyperledger/fabric "
    26      exit
    27  fi
    28  
    29  #TODO: should really just open a few ports..
    30  iptables -I INPUT 1 -j ACCEPT
    31  sysctl vm.overcommit_memory=1
    32  
    33  ##################
    34  # Install Docker
    35  cd /tmp
    36  wget ftp://ftp.unicamp.br/pub/linuxpatch/s390x/redhat/rhel7.2/docker-1.10.1-rhel7.2-20160408.tar.gz
    37  tar -xvzf docker-1.10.1-rhel7.2-20160408.tar.gz
    38  cp docker-1.10.1-rhel7.2-20160408/docker /bin
    39  rm -rf docker docker-1.10.1-rhel7.2-20160408.tar.gz
    40  
    41  #TODO: Install on boot
    42  nohup docker daemon -g /data/docker -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock&
    43  
    44  ###################################
    45  # Crosscompile and install GOLANG
    46  cd $HOME
    47  git clone http://github.com/linux-on-ibm-z/go.git
    48  cd go
    49  git checkout release-branch.go1.6
    50  
    51  cat > crosscompile.sh <<HEREDOC
    52  cd /tmp/home/go/src	
    53  yum install -y git wget tar gcc bzip2
    54  export GOROOT_BOOTSTRAP=/usr/local/go
    55  GOOS=linux GOARCH=s390x ./bootstrap.bash
    56  HEREDOC
    57  
    58  docker run --privileged --rm -ti -v $HOME:/tmp/home brunswickheads/openchain-peer /bin/bash /tmp/home/go/crosscompile.sh
    59  
    60  export GOROOT_BOOTSTRAP=$HOME/go-linux-s390x-bootstrap
    61  cd $HOME/go/src
    62  ./all.bash
    63  export PATH=$HOME/go/bin:$PATH
    64  
    65  rm -rf $HOME/go-linux-s390x-bootstrap 
    66  
    67  ################
    68  #ROCKSDB BUILD
    69  
    70  cd /tmp
    71  yum install -y gcc-c++ snappy snappy-devel zlib zlib-devel bzip2 bzip2-devel
    72  git clone https://github.com/facebook/rocksdb.git
    73  cd  rocksdb
    74  git checkout tags/v4.1
    75  echo There were some bugs in 4.1 for x/p, dev stream has the fix, living dangereously, fixing in place
    76  sed -i -e "s/-march=native/-march=zEC12/" build_tools/build_detect_platform
    77  sed -i -e "s/-momit-leaf-frame-pointer/-DDUMBDUMMY/" Makefile
    78  make shared_lib && INSTALL_PATH=/usr make install-shared && ldconfig
    79  cd /tmp
    80  rm -rf /tmp/rocksdb
    81  
    82  ################
    83  # PIP
    84  yum install python-setuptools
    85  curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
    86  python get-pip.py
    87  pip install --upgrade pip
    88  pip install behave nose docker-compose
    89  
    90  ################
    91  #grpcio package
    92  
    93  git clone https://github.com/grpc/grpc.git
    94  cd grpc
    95  pip install -rrequirements.txt
    96  git checkout tags/release-0_13_1
    97  sed -i -e "s/boringssl.googlesource.com/github.com\/linux-on-ibm-z/" .gitmodules
    98  git submodule sync
    99  git submodule update --init
   100  cd third_party/boringssl
   101  git checkout s390x-big-endian
   102  cd ../..
   103  GRPC_PYTHON_BUILD_WITH_CYTHON=1 pip install .
   104  
   105  # updater-server, update-engine, and update-service-common dependencies (for running locally)
   106  pip install -I flask==0.10.1 python-dateutil==2.2 pytz==2014.3 pyyaml==3.10 couchdb==1.0 flask-cors==2.0.1 requests==2.4.3 pyOpenSSL==16.2.0 sha3==0.2.1
   107  cat >> ~/.bashrc <<HEREDOC
   108        export PATH=$HOME/go/bin:$PATH
   109        export GOROOT=$HOME/go
   110        export GOPATH=$HOME/git
   111  HEREDOC
   112  
   113  source ~/.bashrc
   114  
   115  # Build the actual hyperledger peer
   116  cd $GOPATH/src/github.com/hyperledger/fabric
   117  make clean peer