pack.sh 5.2 KB

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