2020-02-13 07:33:56 -05:00
|
|
|
#!/bin/bash
|
|
|
|
set -e -o pipefail
|
2015-02-06 12:01:50 -05:00
|
|
|
|
2020-01-28 01:16:23 -05:00
|
|
|
# generate secrets and defines them as environment variables
|
|
|
|
# https://github.com/phusion/baseimage-docker#centrally-defining-your-own-environment-variables
|
|
|
|
|
|
|
|
WEB_API_PASSWORD_FILE=/etc/container_environment/WEB_API_PASSWORD
|
2023-01-20 06:06:26 -05:00
|
|
|
STAGING_PASSWORD_FILE=/etc/container_environment/STAGING_PASSWORD # HTTP auth for history-v1
|
|
|
|
V1_HISTORY_PASSWORD_FILE=/etc/container_environment/V1_HISTORY_PASSWORD
|
2020-01-28 01:16:23 -05:00
|
|
|
CRYPTO_RANDOM_FILE=/etc/container_environment/CRYPTO_RANDOM
|
|
|
|
|
2023-01-20 06:06:26 -05:00
|
|
|
if [ ! -f "$WEB_API_PASSWORD_FILE" ] || [ ! -f "$STAGING_PASSWORD_FILE" ] || [ ! -f "$CRYPTO_RANDOM_FILE" ]; then
|
2020-01-28 01:16:23 -05:00
|
|
|
|
|
|
|
echo "generating random secrets"
|
|
|
|
|
|
|
|
SECRET=$(dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 -w 0 | rev | cut -b 2- | rev | tr -d '\n+/')
|
|
|
|
echo ${SECRET} > ${WEB_API_PASSWORD_FILE}
|
|
|
|
|
2023-01-20 06:06:26 -05:00
|
|
|
SECRET=$(dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 -w 0 | rev | cut -b 2- | rev | tr -d '\n+/')
|
|
|
|
echo ${SECRET} > ${STAGING_PASSWORD_FILE}
|
|
|
|
echo ${SECRET} > ${V1_HISTORY_PASSWORD_FILE}
|
|
|
|
|
2020-01-28 01:16:23 -05:00
|
|
|
SECRET=$(dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 -w 0 | rev | cut -b 2- | rev | tr -d '\n+/')
|
|
|
|
echo ${SECRET} > ${CRYPTO_RANDOM_FILE}
|
|
|
|
fi
|
|
|
|
|