ojuso-map/bin/mixin-secrets
2017-05-21 01:52:01 +02:00

32 lines
742 B
Bash
Executable File

#!/bin/bash
#
# Generates a fancy docker-compose.yml based on the template by
# mixing in production secrets.
#
# Olivia Mackintosh <livvy@base.nu>
THISDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
TEMPLATE=${THISDIR}/../environment.template
TARGET=${THISDIR}/../environment
if [ -z "$DATABASE_PASSWORD" ]; then
echo "Error: Please set \$DATABASE_PASSWORD"
exit 1
fi
if [ -z "$SMTP_PASSWORD" ]; then
echo "Error: Please set \$SMTP_PASSWORD"
exit 1
fi
if [ -z "$SECRET_KEY" ]; then
echo "Error: Please set \$SECRET_KEY"
exit 1
fi
# Make sure only root can access and then
# sub in the environment variables.
sudo chown root:root $TARGET
sudo chmod 660 $TARGET
envsubst < $TEMPLATE | sudo tee $TARGET