This repository has been archived by the owner on May 2, 2024. It is now read-only.
forked from GSA-TTS/cg-logshipper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.profile
executable file
·23 lines (18 loc) · 1.72 KB
/
.profile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh
# Uses jq to:
# - extract New Relic config from VCAP_SERVICES and set env vars
# - extract S3 bucket params from a bound service in VCAP_SERVICES and set env vars
# - Save user/password for HTTP auth to a file for nginx basic auth.
export NEW_RELIC_LICENSE_KEY="$(echo "$VCAP_SERVICES" | jq --raw-output '."user-provided" | .[] | select(.tags[] | contains("newrelic-creds")) | .credentials.NEW_RELIC_LICENSE_KEY')"
export NEW_RELIC_LOGS_ENDPOINT="$(echo "$VCAP_SERVICES" | jq --raw-output '."user-provided" | .[] | select(.tags[] | contains("newrelic-creds")) | .credentials.NEW_RELIC_LOGS_ENDPOINT')"
export BUCKET_NAME="$(echo "$VCAP_SERVICES" | jq --raw-output '."s3" | .[] | select(.tags[] | contains("logshipper-s3")) | .credentials.bucket')"
export AWS_DEFAULT_REGION="$(echo "$VCAP_SERVICES" | jq --raw-output '."s3" | .[] | select(.tags[] | contains("logshipper-s3")) | .credentials.region')"
export AWS_ACCESS_KEY_ID="$(echo "$VCAP_SERVICES" | jq --raw-output '."s3" | .[] | select(.tags[] | contains("logshipper-s3")) | .credentials.access_key_id')"
export AWS_SECRET_ACCESS_KEY="$(echo "$VCAP_SERVICES" | jq --raw-output '."s3" | .[] | select(.tags[] | contains("logshipper-s3")) | .credentials.secret_access_key')"
HTTP_USER="$(echo "$VCAP_SERVICES" | jq --raw-output '."user-provided" | .[] | select(.tags[] | contains("logshipper-creds")) | .credentials.HTTP_USER')"
HTTP_PASS="$(echo "$VCAP_SERVICES" | jq --raw-output '."user-provided" | .[] | select(.tags[] | contains("logshipper-creds")) | .credentials.HTTP_PASS')"
HTTP_PASS_CRYPT="$(openssl passwd ${HTTP_PASS})"
echo "${HTTP_USER}:${HTTP_PASS_CRYPT}" > /home/vcap/app/http_creds
chmod 600 /home/vcap/app/http_creds
# Add HTTPS_PROXY (example):
export HTTPS_PROXY=$PROXYROUTE