2016-03-10 18:18:11 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# http://concourse.ci/implementing-resources.html#in:-fetch-a-given-resource.
|
|
|
|
|
|
|
|
# https://github.com/concourse/git-resource/blob/6fcfbd4/assets/out#L4-L16
|
|
|
|
set -e
|
|
|
|
set -x
|
|
|
|
|
|
|
|
exec 3>&1 # make stdout available as fd 3 for the result
|
|
|
|
exec 1>&2 # redirect all output to stderr for logging
|
|
|
|
|
|
|
|
dest=$1
|
|
|
|
|
|
|
|
if [ -z "$dest" ]; then
|
|
|
|
echo "usage: $0 <path/to/volume>"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
#######################################
|
|
|
|
|
|
|
|
# parse incoming config data
|
|
|
|
payload=`cat`
|
|
|
|
bucket=$(echo "$payload" | jq -r '.source.bucket')
|
|
|
|
|
|
|
|
|
|
|
|
echo "Downloading from S3..."
|
|
|
|
|
|
|
|
# http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-environment
|
|
|
|
export AWS_ACCESS_KEY_ID=$(echo "$payload" | jq -r '.source.access_key_id')
|
|
|
|
export AWS_SECRET_ACCESS_KEY=$(echo "$payload" | jq -r '.source.secret_access_key')
|
|
|
|
|
|
|
|
aws s3 sync "s3://$bucket" $dest
|
|
|
|
|
|
|
|
echo "...done."
|
|
|
|
|
|
|
|
|
2016-03-10 18:35:56 +01:00
|
|
|
source "$(dirname $0)/emit.sh" >&3
|