mtp20_access_linux.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. export base=$HOME/build/git/MTP20_IF
  3. export GOROOT=/home/pub/go
  4. export GOPATH=/home/pub/gowebapi
  5. export GOBIN=$GOPATH/bin
  6. export GO111MODULE=on
  7. export GOPROXY=https://goproxy.cn
  8. export PATH=$PATH:$GOROOT/bin:$GOBIN
  9. export PKG_CONFIG_PATH=/home/pub/pkconfig
  10. export LD_LIBRARY_PATH=/home/pub/instantclient_11_2/
  11. function build()
  12. {
  13. local src=$1
  14. local oldpwd=`pwd`
  15. cd $src
  16. echo "Before switching: "
  17. git branch
  18. git reset --hard
  19. git clean -fdx
  20. git pull --rebase
  21. git checkout $branch_name
  22. echo "After switching: "
  23. git branch
  24. if [ $? -ne 0 ]; then
  25. echo "git update err:1"
  26. exit 1
  27. fi
  28. githash=`git log -n 1 --format=format:"%H"`
  29. cd $src
  30. echo `go version`
  31. echo "go build begin:"`date "+%Y-%m-%d %H:%M:%S"`
  32. echo "path:"$src
  33. local datestr=`date +%Y%m%d%H%M%S`
  34. local zipfile=mtp20_access_${datestr}.zip
  35. go build -ldflags "-X 'main._VERSION_=$zipfile' -X 'main._GITHASH_=$githash'" -a -o bin/MTP20Access
  36. if [ $? -ne 0 ]; then
  37. echo "go build err: 2"
  38. exit 2
  39. fi
  40. echo "go build finish:"`date "+%Y-%m-%d %H:%M:%S"`
  41. cp -r $src/config.yaml bin/
  42. cd $src/bin/
  43. local rsync_ip=192.168.30.153
  44. local rsync_project=mtp2.0_release
  45. zip -r $zipfile ./
  46. rsync -avh $src/bin/${zipfile} $rsync_ip::build/$rsync_project/${zipfile}
  47. echo "Storage path: \\\\$rsync_ip\\share\\build\\$rsync_project\\$zipfile"
  48. echo "quick download: wget -c http://$rsync_ip/share/build/$rsync_project/$zipfile"
  49. rm -rf $src/bin
  50. }
  51. #######################main function#########################
  52. build $base
  53. if [ $? -ne 0 ]; then
  54. exit -1
  55. fi