pack.sh 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #!/bin/bash
  2. project=meidi
  3. channel=mychannel
  4. docker_peer_images="hyperledger/fabric-peer:x86_64-1.0.0-alpha"
  5. docker_couchdb_images="hyperledger/fabric-couchdb:x86_64-1.0.0-alpha"
  6. docker_orderer_images="docker.io/hyperledger/fabric-orderer:x86_64-1.0.0-alpha"
  7. docker_ccenv_images="docker.io/hyperledger/fabric-ccenv:x86_64-1.0.0-alpha"
  8. docker_baseos_images="docker.io/hyperledger/fabric-baseos:x86_64-0.3.0"
  9. rm -rf "$project"_*
  10. function create_cli() {
  11. rm -rf "$projec"_cli
  12. mkdir -p "$project"_cli
  13. echo "docker pull $docker_peer_images" >> "$project"_cli/download-dockerimages.sh
  14. echo "docker tag $docker_peer_images hyperledger/fabric-peer" >> "$project"_cli/download-dockerimages.sh
  15. echo "CHANNEL_NAME=$channel ./docker-compose -f docker-compose-cli.yaml up -d " >> "$project"_cli/start.sh
  16. echo "docker logs -f cli" >> "$project"_cli/start.sh
  17. chmod u+x "$project"_cli/download-dockerimages.sh
  18. chmod u+x "$project"_cli/start.sh
  19. mkdir -p "$project"_cli/scripts
  20. cp -rf examples "$project"_cli
  21. cp -rf crypto "$project"_cli
  22. cp -rf scripts "$project"_cli
  23. cp -rf docker-compose "$project"_cli
  24. cp -rf docker-compose-cli.yaml "$project"_cli
  25. tar -cvf "$project"_cli.tar "$project"_cli
  26. gzip "$project"_cli.tar
  27. rm -rf "$project"_cli
  28. }
  29. function create_orderer() {
  30. while read -s -n1 -p "Are you want to generateCfgTrx channel.tx and orderer.block ? [y|n]" input
  31. do
  32. case $input in
  33. Y|y)
  34. echo "generateCfgTrx"
  35. CURRENT_DIR=$PWD
  36. source generateCfgTrx.sh $channel
  37. cd $CURRENT_DIR
  38. break;;
  39. N|n)
  40. echo "skip generateCfgTrx"
  41. break;;
  42. *)
  43. echo "input error";;
  44. esac
  45. done
  46. rm -rf "$project"_orderer
  47. mkdir -p "$project"_orderer
  48. echo "docker pull $docker_orderer_images" >> "$project"_orderer/download-dockerimages.sh
  49. echo "docker tag $docker_orderer_images hyperledger/fabric-orderer" >> "$project"_orderer/download-dockerimages.sh
  50. echo "CHANNEL_NAME=$channel ./docker-compose -f docker-compose-orderer0.yaml up -d " >> "$project"_orderer/start.sh
  51. chmod u+x "$project"_orderer/download-dockerimages.sh
  52. chmod u+x "$project"_orderer/start.sh
  53. mkdir -p "$project"_orderer/crypto
  54. cp -rf crypto/orderer "$project"_orderer/crypto
  55. cp -rf docker-compose "$project"_orderer
  56. cp -rf docker-compose-orderer0.yaml "$project"_orderer
  57. tar -cvf "$project"_orderer0.tar "$project"_orderer
  58. gzip "$project"_orderer0.tar
  59. rm -rf "$project"_orderer
  60. }
  61. function create_peer() {
  62. rm -rf $project
  63. mkdir -p $project
  64. for N in 0 1 2 3 ; do
  65. rm -rf $project
  66. mkdir -p $project
  67. echo "CHANNEL_NAME=$channel ./docker-compose -f docker-compose-peer"$N".yaml up -d " >> $project/start.sh
  68. echo "sleep 2" >> $project/start.sh
  69. echo "curl -X PUT http://127.0.0.1:5984/_users" >> $project/start.sh
  70. echo "curl -X PUT http://127.0.0.1:5984/_replicator" >> $project/start.sh
  71. echo "curl -X PUT http://127.0.0.1:5984/_global_changes" >> $project/start.sh
  72. echo "docker pull $docker_peer_images" >> $project/download-dockerimages.sh
  73. echo "docker tag $docker_peer_images hyperledger/fabric-peer" >> $project/download-dockerimages.sh
  74. echo "docker pull $docker_couchdb_images" >> $project/download-dockerimages.sh
  75. echo "docker tag $docker_couchdb_images hyperledger/fabric-couchdb" >> $project/download-dockerimages.sh
  76. echo "docker pull $docker_ccenv_images" >> $project/download-dockerimages.sh
  77. echo "docker tag $docker_ccenv_images hyperledger/fabric-ccenv" >> $project/download-dockerimages.sh
  78. echo "docker pull $docker_baseos_images" >> $project/download-dockerimages.sh
  79. chmod u+x $project/start.sh
  80. chmod u+x $project/download-dockerimages.sh
  81. mkdir -p ./$project/peer-base
  82. mkdir -p ./$project/crypto/peer/peer$N/localMspConfig
  83. cp -rf docker-compose $project
  84. cp -rf docker-compose-peer"$N".yaml $project
  85. cp -rf peer-base/peer-base.yaml $project/peer-base/peer-base.yaml
  86. cp -rf crypto/peer/peer$N/localMspConfig/* $project/crypto/peer/peer$N/localMspConfig/
  87. tar -cvf "$project"_peer$N.tar $project
  88. gzip "$project"_peer$N.tar
  89. rm -rf $project
  90. done
  91. rm -rf $project
  92. }
  93. create_orderer
  94. create_cli
  95. create_peer