2016-03-10 08:16:03 +01:00
|
|
|
#!/bin/sh
|
2016-03-10 07:32:05 +01:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2016-03-10 09:01:02 +01:00
|
|
|
exec 3>&1 # make stdout available as fd 3 for the result
|
|
|
|
exec 1>&2 # redirect all output to stderr for logging
|
|
|
|
|
|
|
|
source=$1
|
|
|
|
|
|
|
|
if [ -z "$source" ]; then
|
2016-03-21 23:38:36 +01:00
|
|
|
echo "usage: $0 </full/path/to/dir>"
|
2016-03-10 09:01:02 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-10-26 21:51:51 +02:00
|
|
|
source "$(dirname $0)/common.sh"
|
|
|
|
|
2016-03-10 09:57:41 +01:00
|
|
|
payload=`cat`
|
2018-10-26 21:51:51 +02:00
|
|
|
bucket=$(get_bucket)
|
2018-10-30 01:56:37 +01:00
|
|
|
prefix=$(get_prefix)
|
2021-03-25 01:57:12 +01:00
|
|
|
aws_options=$(echo "$payload" | jq -r '.source.aws_options // [] | join(" ")')
|
2018-10-26 21:51:51 +02:00
|
|
|
options=$(echo "$payload" | jq -r '.params.options // [] | join(" ")')
|
|
|
|
source_dir=$(echo "$payload" | jq -r '.params.source_dir // "."')
|
|
|
|
test -z "$source_dir" && { echo "Must supply params.source_dir" >&2; exit 1; }
|
|
|
|
|
|
|
|
export_aws_vars
|
2016-03-10 16:57:12 +01:00
|
|
|
|
2018-10-26 21:51:51 +02:00
|
|
|
cd $source/$source_dir
|
2018-10-31 21:38:41 +01:00
|
|
|
|
|
|
|
bucket_uri="s3://$bucket/$prefix"
|
|
|
|
echo "Uploading '$source_dir' to '$bucket_uri'..."
|
2021-03-25 01:57:12 +01:00
|
|
|
eval aws $aws_options s3 sync $source/$source_dir $bucket_uri $options
|
2018-10-26 21:51:51 +02:00
|
|
|
echo "Done."
|
2016-03-10 09:01:02 +01:00
|
|
|
|
2018-10-26 21:51:51 +02:00
|
|
|
emit_version
|