prepare_plugins.sh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #!/bin/bash
  2. #
  3. # Copyright 2021-2022 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. go build -o test/plugins/sql/create_table test/plugins/sql/create_table.go
  23. chmod +x test/plugins/sql/create_table
  24. cd test
  25. rm -rf zmq.* Zmq.so
  26. FILE=../plugins/sources/Zmq.so
  27. if [ -f "$FILE" ]; then
  28. echo "$FILE exists, not requried to build plugin."
  29. else
  30. echo "$FILE does not exist, will build the plugin."
  31. go build -trimpath -modfile ../extensions.mod --buildmode=plugin -o ../plugins/sources/Zmq.so ../extensions/sources/zmq/zmq.go
  32. fi
  33. mv ../plugins/sources/Zmq.so .
  34. cp ../extensions/sources/zmq/zmq.yaml .
  35. zip zmq.zip Zmq.so zmq.yaml
  36. rm -rf zmq.yaml Zmq.so
  37. rm -rf image.* Image.so
  38. FILE=../plugins/functions/Image.so
  39. if [ -f "$FILE" ]; then
  40. echo "$FILE exists, not requried to build plugin."
  41. else
  42. echo "$FILE does not exist, will build the plugin."
  43. go build -trimpath -modfile ../extensions.mod --buildmode=plugin -o ../plugins/functions/Image.so ../extensions/functions/image/*.go
  44. fi
  45. mv ../plugins/functions/Image.so .
  46. zip image.zip Image.so
  47. rm -rf Image.so
  48. # build tdengine plugins
  49. FILE=../plugins/sinks/Tdengine.so
  50. if [ -f "$FILE" ]; then
  51. echo "$FILE exists, not requried to build plugin."
  52. else
  53. echo "$FILE does not exist, will build the plugin."
  54. go build -trimpath -modfile ../extensions.mod --buildmode=plugin -o ../plugins/sinks/Tdengine.so ../extensions/sinks/tdengine/*.go
  55. fi
  56. mv ../plugins/sinks/Tdengine.so .
  57. zip tdengine.zip Tdengine.so
  58. rm -rf Tdengine.so
  59. # build sql plugins
  60. FILE=../plugins/sinks/Sql.so
  61. if [ -f "$FILE" ]; then
  62. echo "$FILE exists, not required to build plugin."
  63. else
  64. echo "$FILE does not exist, will build the plugin."
  65. go build -trimpath -modfile ../extensions.mod --buildmode=plugin -o ../plugins/sinks/Sql.so ../extensions/sinks/sql/*.go
  66. fi
  67. mv ../plugins/sinks/Sql.so .
  68. zip sql.zip Sql.so
  69. rm -rf Sql.so
  70. FILE=../plugins/sources/Sql.so
  71. if [ -f "$FILE" ]; then
  72. echo "$FILE exists, not required to build plugin."
  73. else
  74. echo "$FILE does not exist, will build the plugin."
  75. go build -trimpath -modfile ../extensions.mod --buildmode=plugin -o ../plugins/sources/Sql.so ../extensions/sources/sql/*.go
  76. fi
  77. mv ../plugins/sources/Sql.so .
  78. cp ../extensions/sources/sql/sql.yaml .
  79. zip sqlSrc.zip Sql.so sql.yaml
  80. rm -rf Sql.so
  81. rm -rf plugins/service/web/plugins/
  82. mkdir -p plugins/service/web/plugins/
  83. mv zmq.zip plugins/service/web/plugins/
  84. mv image.zip plugins/service/web/plugins/
  85. mv tdengine.zip plugins/service/web/plugins/
  86. mv sql.zip plugins/service/web/plugins/
  87. mv sqlSrc.zip plugins/service/web/plugins/
  88. # prepare portable plugins
  89. cd ..
  90. mkdir test/temp
  91. mkdir test/temp/mirror
  92. cd sdk/go/example/mirror
  93. go build -o ../../../../test/temp/mirror/mirror .
  94. cd ../../../..
  95. cp sdk/go/example/mirror/mirror.json test/temp/mirror
  96. cp -r sdk/go/example/mirror/sources test/temp/mirror/
  97. cd test/temp/mirror
  98. zip -r ../../plugins/service/web/plugins/mirror.zip *
  99. cd ../../..
  100. cp -r sdk/python/example/pysam test/temp/pysam
  101. cp -r sdk/python/ekuiper test/temp/pysam/
  102. cd test/temp/pysam
  103. zip -r ../../plugins/service/web/plugins/pysam.zip *
  104. cd ../..
  105. rm -r temp
  106. pids=`ps aux | grep http_server | grep "./" | awk '{printf $2 " "}'`
  107. if [ "$pids" = "" ] ; then
  108. echo "No http mockup server was started"
  109. else
  110. for pid in $pids ; do
  111. echo "kill http mockup server " $pid
  112. kill -9 $pid
  113. done
  114. fi
  115. cd plugins/service/
  116. export BUILD_ID=dontKillMe
  117. echo "starting mock http server..."
  118. nohup ./http_server > http_server.out 2>&1 &