github.com/adnan-c/fabric_e2e_couchdb@v0.6.1-preview.0.20170228180935-21ce6b23cf91/orderer/sbft/local-deploy.sh (about)

     1  #!/bin/sh
     2  
     3  set -e
     4  
     5  dest=$1
     6  count=$2
     7  nodeidmax=$((count-1))
     8  
     9  if test -z "$count"
    10  then
    11      echo "usage: local-deploy.sh <destdir> <nreplica>" >&1
    12      exit 1
    13  fi
    14  
    15  
    16  fail=$((($count - 1)/3))
    17  
    18  mkdir $dest
    19  cd $dest
    20  
    21  certtool --generate-privkey --outfile key.pem 2>/dev/null
    22  mkdir data
    23  
    24  peerconf=""
    25  
    26  for n in $(seq 0 $nodeidmax)
    27  do
    28      cat > template$n.cfg <<EOF
    29  expiration_days = -1
    30  serial = $(date +"%N")
    31  signing_key
    32  encryption_key
    33  EOF
    34      certtool --generate-self-signed --load-privkey key.pem --outfile cert$n.pem --template template$n.cfg 2>/dev/null
    35      certtool -i --infile cert$n.pem --outder --outfile data/config.peers.:$((6100+$n)) 2>/dev/null
    36  
    37      peerconf=$(cat <<EOF
    38  ${peerconf}${peerconf:+,}
    39  {
    40    "address": ":$((6100+$n))",
    41    "cert": "cert${n}.pem"
    42  }
    43  EOF
    44  )
    45  done
    46  
    47  cat > config.json <<EOF
    48  {
    49    "consensus": {
    50  	"n" : $count,
    51  	"f" : $fail,
    52  	"batch_size_bytes" : 1000,
    53  	"batch_duration_nsec" : 1000000000,
    54  	"request_timeout_nsec" : 1000000000
    55   },
    56    "peers": [${peerconf}]
    57  }
    58  EOF
    59  
    60  for n in $(seq 0 $nodeidmax)
    61  do
    62      sbft -data-dir data$n -init config.json
    63      cat > run-$n.sh <<EOF
    64  #!/bin/sh
    65  sbft -addr :$((6100+$n)) -gaddr :$((7100+$n)) -cert cert$n.pem -key key.pem -data-dir data$n "\$@"
    66  EOF
    67      chmod +x run-$n.sh
    68  done