2017-05-19 00:45:31 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2017-05-22 23:11:00 +00:00
|
|
|
# Generates a fancy environment varibale file based a template by
|
|
|
|
# mixing in production secrets from locally set variables.
|
2017-05-19 00:45:31 +00:00
|
|
|
#
|
|
|
|
# Olivia Mackintosh <livvy@base.nu>
|
|
|
|
|
|
|
|
THISDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
2017-05-20 23:52:01 +00:00
|
|
|
TEMPLATE=${THISDIR}/../environment.template
|
|
|
|
TARGET=${THISDIR}/../environment
|
2017-05-19 00:45:31 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2017-05-20 23:52:01 +00:00
|
|
|
if [ -z "$SECRET_KEY" ]; then
|
|
|
|
echo "Error: Please set \$SECRET_KEY"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-05-22 23:11:00 +00:00
|
|
|
if [ -z "$WEBLATE_ADMIN_PASSWORD" ]; then
|
|
|
|
echo "Error: Please set \$WEBLATE_ADMIN_PASSWORD"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-05-20 23:52:01 +00:00
|
|
|
# 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
|