#!/bin/bash # this script is used to generate the binary of benchmark/txgen # TODO: add error and parameter checking declare -A SRC SRC[benchmark]=benchmark.go SRC[txgen]=client/txgen/main.go BINDIR=bin BUCKET=unique-bucket-bin GOOS=linux GOARCH=amd64 function usage { ME=$(basename $0) cat< $BINDIR/md5sum.txt } function upload { AWSCLI=aws if [ -n "$PROFILE" ]; then AWSCLI+=" --profile $PROFILE" fi for bin in "${!SRC[@]}"; do [ -e $BINDIR/$bin ] && $AWSCLI s3 cp $BINDIR/$bin s3://$BUCKET/$bin --acl public-read done [ -e $BINDIR/md5sum.txt ] && $AWSCLI s3 cp $BINDIR/md5sum.txt s3://$BUCKET/md5sum.txt --acl public-read } ################################ MAIN FUNCTION ############################## while getopts "hp:a:o:b:" option; do case $option in h) usage ;; p) PROFILE=$OPTARG ;; a) GOARCH=$OPTARG ;; o) GOOS=$OPTARG ;; b) BUCKET=$OPTARG ;; esac done mkdir -p $BINDIR shift $(($OPTIND-1)) ACTION=${1:-build} case "$ACTION" in "build") build_only ;; "upload") upload ;; *) usage ;; esac