-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·24 lines (22 loc) · 1.24 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
if [ ! -z "$CONSUL_PREFIX" ]; then
if [ $1 = "web" ]; then
concourse_keys=(authorized_worker_keys session_signing_key tsa_host_key)
for i in ${concourse_keys[@]}; do
echo -e "{{key \"${CONSUL_PREFIX}/tls/${i}\"}}\n" > /tmp/key.ctmpl
/usr/local/bin/consul-template -template "/tmp/key.ctmpl:/concourse-keys/${i}" -once
done
CONCOURSE_DB_USER=`/usr/local/bin/envconsul -sanitize -pristine -upcase -once -prefix ${CONSUL_PREFIX}/${1} env | grep CONCOURSE_DB_USER | cut -c 19-`
CONCOURSE_DB_PASSWORD=`/usr/local/bin/envconsul -sanitize -pristine -upcase -once -prefix ${CONSUL_PREFIX}/${1} env | grep CONCOURSE_DB_PASSWORD | cut -c 23-`
export CONCOURSE_POSTGRES_DATA_SOURCE="postgres://${CONCOURSE_DB_USER}:${CONCOURSE_DB_PASSWORD}@${CONCOURSE_DB_ENDPOINT}?sslmode=disable"
elif [ $1 = "worker" ]; then
concourse_keys=(tsa_host_key_pub worker_key)
for i in ${concourse_keys[@]}; do
echo -e "{{key \"${CONSUL_PREFIX}/tls/${i}\"}}\n" > /tmp/key.ctmpl
/usr/local/bin/consul-template -template "/tmp/key.ctmpl:/concourse-keys/${i}" -once
done
fi
/usr/local/bin/envconsul -prefix $CONSUL_PREFIX/$1 -sanitize -upcase -once /usr/local/bin/concourse "$@"
else
/usr/local/bin/concourse "$@"
fi