2016-03-10 18:18:11 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2018-10-26 21:51:51 +02:00
|
|
|
source "$(dirname $0)/common.sh"
|
|
|
|
|
2016-03-10 18:18:11 +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(" ")')
|
2018-10-26 21:55:37 +02:00
|
|
|
skip_download=$(echo "$payload" | jq -r '.params.skip_download // false')
|
2018-10-26 21:51:51 +02:00
|
|
|
|
|
|
|
export_aws_vars
|
2016-03-10 18:18:11 +01:00
|
|
|
|
2017-02-21 22:09:45 +01:00
|
|
|
if [ "$skip_download" = "true" ]; then
|
2018-10-26 21:55:37 +02:00
|
|
|
echo "Skipping download from S3"
|
2017-02-21 22:09:45 +01:00
|
|
|
else
|
|
|
|
echo "Downloading from S3..."
|
2021-03-25 01:57:12 +01:00
|
|
|
eval aws $aws_options s3 sync "s3://$bucket/$prefix" $dest $options
|
2018-10-26 21:55:37 +02:00
|
|
|
echo "Done."
|
2017-02-21 22:09:45 +01:00
|
|
|
fi
|
2016-03-10 18:18:11 +01:00
|
|
|
|
2018-10-26 21:51:51 +02:00
|
|
|
emit_version
|