s3manager-web/deployments/cf/entrypoint.sh

32 lines
830 B
Bash
Raw Normal View History

2017-05-08 23:07:07 +02:00
#!/bin/bash
set -e -u
if [ -z "${PORT}" ]; then
echo "Error: No PORT found" >&2
exit 1
fi
if [ -z "${VCAP_SERVICES}" ]; then
echo "Error: No VCAP_SERVICES found" >&2
exit 1
fi
# S3
s3_credentials="$(echo "${VCAP_SERVICES}" | jq -r '.["dynstrg"][0].credentials // ""')"
if [ -z "${s3_credentials}" ]; then
echo "Error: Please bind an S3 service" >&2
exit 1
fi
s3_endpoint="$(echo "${s3_credentials}" | jq -r '.accessHost // ""')"
s3_endpoint=${s3_endpoint#'https://'}
2017-05-08 23:07:07 +02:00
s3_access_key_id="$(echo "${s3_credentials}" | jq -r '.accessKey // ""')"
s3_secret_access_key="$(echo "${s3_credentials}" | jq -r '.sharedSecret // ""')"
# Run binary
./s3manager \
-port "${PORT}" \
-endpoint "${s3_endpoint}" \
-access-key-id "${s3_access_key_id}" \
-secret-access-key "${s3_secret_access_key}" \
-v2-signing