mtp20_assisted_linux.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/bash
  2. export base=$HOME/build/git/MTP20_ASSISTED
  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_assisted_${datestr}.zip
  35. go build -ldflags "-X 'main._VERSION_=$zipfile' -X 'main._GITHASH_=$githash'" -a -o bin/mtp20_assisted
  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. cp -r $src/static bin/static
  43. cd $src/bin/
  44. local rsync_ip=192.168.30.153
  45. local rsync_project=mtp2.0_release
  46. zip -r $zipfile ./
  47. rsync -avh $src/bin/${zipfile} $rsync_ip::build/$rsync_project/${zipfile}
  48. echo "Storage path: \\\\$rsync_ip\\share\\build\\$rsync_project\\$zipfile"
  49. echo "quick download: wget -c http://$rsync_ip/share/build/$rsync_project/$zipfile"
  50. rm -rf $src/bin
  51. }
  52. #######################main function#########################
  53. build $base
  54. if [ $? -ne 0 ]; then
  55. exit -1
  56. fi