mtp2.0_QueryService_linux.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/bin/bash
  2. ###
  3. # @Author: deng.yinping deng.yinping@muchinfo.cn
  4. # @Date: 2022-11-22 09:48:32
  5. # @LastEditors: deng.yinping deng.yinping@muchinfo.cn
  6. # @LastEditTime: 2022-11-25 17:16:17
  7. # @FilePath: \MTP20_IF\res\sh\mtp2.0_queryservice_linux.sh
  8. # @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  9. ###
  10. export base=$HOME/build/git/MTP20_IF
  11. export GOROOT=/home/pub/go
  12. export GOPATH=/home/pub/gowebapi
  13. export GOBIN=$GOPATH/bin
  14. export GO111MODULE=on
  15. export GOPROXY=https://goproxy.cn
  16. export PATH=$PATH:$GOROOT/bin:$GOBIN
  17. export PKG_CONFIG_PATH=/home/pub/pkconfig
  18. export LD_LIBRARY_PATH=/home/pub/instantclient_11_2/
  19. function build()
  20. {
  21. local src=$1
  22. local oldpwd=`pwd`
  23. cd $src
  24. echo "Before switching: "
  25. git branch
  26. git reset --hard
  27. git clean -fdx
  28. git pull --rebase
  29. git checkout $branch_name
  30. echo "After switching: "
  31. git branch
  32. if [ $? -ne 0 ]; then
  33. echo "git update err:1"
  34. exit 1
  35. fi
  36. githash=`git log -n 1 --format=format:"%H"`
  37. cd $src
  38. #sh $HOME/build/scripts/xml_to_j2.sh queryservice $src/
  39. echo `go version`
  40. echo "go build begin:"`date "+%Y-%m-%d %H:%M:%S"`
  41. echo "path:"$src
  42. local datestr=`date +%Y%m%d%H%M%S`
  43. local zipfile=mtp2_queryservice_r20_${datestr}.zip
  44. go build -ldflags "-X 'main._VERSION_=$zipfile' -X 'main._GITHASH_=$githash'" -a -o bin/queryservice
  45. if [ $? -ne 0 ]; then
  46. echo "go build err: 2"
  47. exit 2
  48. fi
  49. echo "go build finish:"`date "+%Y-%m-%d %H:%M:%S"`
  50. mkdir -p bin/config
  51. cp -r $src/config/config.xml bin/config/
  52. cp -r $src/config/cfg.json bin/config/
  53. cp -r $src/config/config.j2 bin/config/
  54. cp -r $src/config/cfg.j2 bin/config/
  55. cp -r $src/config/pc_menu.json bin/config/
  56. cp -r $src/config/mobile_menu.json bin/config/
  57. cp -r $src/config/pcweb_menu bin/config/
  58. cp -r $src/config/mobile_menu bin/config/
  59. cd $src/bin/
  60. local rsync_ip=192.168.30.153
  61. local rsync_project=mtp2.0_release
  62. zip -r $zipfile ./
  63. rsync -avh $src/bin/${zipfile} $rsync_ip::build/$rsync_project/${zipfile}
  64. echo "Storage path: \\\\$rsync_ip\\share\\build\\$rsync_project\\$zipfile"
  65. echo "quick download: wget -c http://$rsync_ip/share/build/$rsync_project/$zipfile"
  66. rm -rf $src/bin
  67. }
  68. #######################main function#########################
  69. build $base
  70. if [ $? -ne 0 ]; then
  71. exit -1
  72. fi