pack.sh 4.3 KB

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