release.sh 1.2 KB
Newer Older
1 2
set -e

B
Bomin Zhang 已提交
3
# releash.sh  -c [armv6l | arm64 | amd64 | 386] 
4 5 6
#             -o [linux | darwin | windows]  

# set parameters by default value
B
Bomin Zhang 已提交
7
cpuType=amd64    # [armv6l | arm64 | amd64 | 386]
8
osType=linux   # [linux | darwin | windows]
9

B
Bomin Zhang 已提交
10
declare -A archMap=(["armv6l"]="arm" ["arm64"]="arm64" ["amd64"]="x64" ["386"]="x86")
11 12 13 14 15 16 17 18 19 20 21 22
while getopts "h:c:o:" arg
do
  case $arg in
    c)
      #echo "cpuType=$OPTARG"
      cpuType=$(echo $OPTARG)
      ;;
    o)
      #echo "osType=$OPTARG"
      osType=$(echo $OPTARG)
      ;;
    h)
B
Bomin Zhang 已提交
23
      echo "Usage: `basename $0` -c [armv6l | arm64 | amd64 | 386] -o [linux | darwin | windows]"
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
      exit 0
      ;;
    ?) #unknown option 
      echo "unknown argument"
      exit 1
      ;;
  esac
done


startdir=$(pwd)
scriptdir=$(dirname $(readlink -f $0))
cd ${scriptdir}/cmd/alert
version=$(grep 'const version =' main.go | awk '{print $NF}')
version=${version%\"}
B
Bomin Zhang 已提交
39
version=${version:1}
40 41 42 43 44 45 46

echo "cpuType=${cpuType}"
echo "osType=${osType}"
echo "version=${version}"

GOOS=${osType} GOARCH=${cpuType} go build

B
Bomin Zhang 已提交
47
tar -I 'gzip -9' -cf ${startdir}/TDengine-alert-${version}-${osType^}-${archMap[${cpuType}]}.tar.gz alert alert.cfg install_driver.sh driver/