upload.sh: Use awscli if s3cmd is not available. (#3114)

This commit is contained in:
Gian Merlino 2016-06-08 17:01:46 -07:00 committed by Fangjin Yang
parent 5998de7d5b
commit c2155e13bd
1 changed files with 14 additions and 4 deletions

View File

@ -14,15 +14,25 @@ DRUID_TAR=druid-$VERSION-bin.tar.gz
MYSQL_TAR=mysql-metadata-storage-$VERSION.tar.gz
S3PATH=s3://static.druid.io/artifacts/releases
if [ ! -z "`s3cmd ls "$S3PATH/$DRUID_TAR"`" ]; then
# Use s3cmd if available, otherwise try awscli
if command -v s3cmd >/dev/null 2>&1
then
s3ls="s3cmd ls"
s3cp="s3cmd put"
else
s3ls="aws s3 ls"
s3cp="aws s3 cp"
fi
if [ ! -z "`$s3ls "$S3PATH/$DRUID_TAR"`" ]; then
echo "ERROR: Refusing to overwrite $S3PATH/$DRUID_TAR" >&2
exit 2
fi
if [ ! -z "`s3cmd ls "$S3PATH/$MYSQL_TAR"`" ]; then
if [ ! -z "`$s3ls "$S3PATH/$MYSQL_TAR"`" ]; then
echo "ERROR: Refusing to overwrite $S3PATH/$MYSQL_TAR" >&2
exit 2
fi
s3cmd put distribution/target/$DRUID_TAR $S3PATH/$DRUID_TAR
s3cmd put distribution/target/$MYSQL_TAR $S3PATH/$MYSQL_TAR
$s3cp distribution/target/$DRUID_TAR $S3PATH/$DRUID_TAR
$s3cp distribution/target/$MYSQL_TAR $S3PATH/$MYSQL_TAR