pack.sh 5.3 KB

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