prepare_plugins.sh 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #!/bin/bash
  2. #
  3. # Copyright 2021 EMQ Technologies Co., Ltd.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. set -e
  18. go build -o test/plugins/pub/zmq_pub test/plugins/pub/zmq_pub.go
  19. chmod +x test/plugins/pub/zmq_pub
  20. go build -o test/plugins/service/http_server test/plugins/service/server.go
  21. chmod +x test/plugins/service/http_server
  22. cd test
  23. rm -rf zmq.* Zmq.so
  24. FILE=../plugins/sources/Zmq.so
  25. if [ -f "$FILE" ]; then
  26. echo "$FILE exists, not requried to build plugin."
  27. else
  28. echo "$FILE does not exist, will build the plugin."
  29. go build -trimpath -modfile ../extensions.mod --buildmode=plugin -o ../plugins/sources/Zmq.so ../extensions/sources/zmq/zmq.go
  30. fi
  31. mv ../plugins/sources/Zmq.so .
  32. cp plugins/zmq.yaml .
  33. zip zmq.zip Zmq.so zmq.yaml
  34. rm -rf zmq.yaml Zmq.so
  35. rm -rf image.* Image.so
  36. FILE=../plugins/functions/Image.so
  37. if [ -f "$FILE" ]; then
  38. echo "$FILE exists, not requried to build plugin."
  39. else
  40. echo "$FILE does not exist, will build the plugin."
  41. go build -trimpath -modfile ../extensions.mod --buildmode=plugin -o ../plugins/functions/Image.so ../extensions/functions/image/*.go
  42. fi
  43. mv ../plugins/functions/Image.so .
  44. zip image.zip Image.so
  45. rm -rf Image.so
  46. # build tdengine plugins
  47. FILE=../plugins/sinks/Tdengine.so
  48. if [ -f "$FILE" ]; then
  49. echo "$FILE exists, not requried to build plugin."
  50. else
  51. echo "$FILE does not exist, will build the plugin."
  52. go build -trimpath -modfile ../extensions.mod --buildmode=plugin -o ../plugins/sinks/Tdengine.so ../extensions/sinks/tdengine/*.go
  53. fi
  54. mv ../plugins/sinks/Tdengine.so .
  55. zip tdengine.zip Tdengine.so
  56. rm -rf Tdengine.so
  57. # build sql plugins
  58. FILE=../plugins/sinks/Sql.so
  59. if [ -f "$FILE" ]; then
  60. echo "$FILE exists, not requried to build plugin."
  61. else
  62. echo "$FILE does not exist, will build the plugin."
  63. go build -trimpath -modfile ../extensions.mod --buildmode=plugin -o ../plugins/sinks/Sql.so ../extensions/sinks/sql/*.go
  64. fi
  65. mv ../plugins/sinks/Sql.so .
  66. zip sql.zip Sql.so
  67. rm -rf Sql.so
  68. rm -rf plugins/service/web/plugins/
  69. mkdir -p plugins/service/web/plugins/
  70. mv zmq.zip plugins/service/web/plugins/
  71. mv image.zip plugins/service/web/plugins/
  72. mv tdengine.zip plugins/service/web/plugins/
  73. mv sql.zip plugins/service/web/plugins/
  74. # prepare portable plugins
  75. cd ..
  76. mkdir test/temp
  77. mkdir test/temp/mirror
  78. cd sdk/go/example/mirror
  79. go build -o ../../../../test/temp/mirror/mirror .
  80. cd ../../../..
  81. cp sdk/go/example/mirror/mirror.json test/temp/mirror
  82. cp -r sdk/go/example/mirror/sources test/temp/mirror/
  83. cd test/temp/mirror
  84. zip -r ../../plugins/service/web/plugins/mirror.zip *
  85. cd ../../..
  86. cp -r sdk/python/example/pysam test/temp/pysam
  87. cp -r sdk/python/ekuiper test/temp/pysam/
  88. cd test/temp/pysam
  89. zip -r ../../plugins/service/web/plugins/pysam.zip *
  90. cd ../..
  91. rm -r temp
  92. pids=`ps aux | grep http_server | grep "./" | awk '{printf $2 " "}'`
  93. if [ "$pids" = "" ] ; then
  94. echo "No http mockup server was started"
  95. else
  96. for pid in $pids ; do
  97. echo "kill http mockup server " $pid
  98. kill -9 $pid
  99. done
  100. fi
  101. cd plugins/service/
  102. export BUILD_ID=dontKillMe
  103. echo "starting mock http server..."
  104. nohup ./http_server > http_server.out 2>&1 &