redash/setup/generate_key.sh
Arik Fraimovich 935dc38360
Update setup files: (#2908)
* Remove use of newgrp
* Updated packer configuration
2018-10-08 09:41:15 +03:00

20 lines
671 B
Bash

#!/bin/sh
FLAG="/var/log/generate_secrets.log"
if [ ! -f $FLAG ]; then
COOKIE_SECRET=$(pwgen -1s 32)
POSTGRES_PASSWORD=$(pwgen -1s 32)
REDASH_DATABASE_URL="postgresql:\/\/postgres:$POSTGRES_PASSWORD@postgres\/postgres"
sed -i "s/REDASH_COOKIE_SECRET=.*/REDASH_COOKIE_SECRET=$COOKIE_SECRET/g" /opt/redash/env
sed -i "s/POSTGRES_PASSWORD=.*/POSTGRES_PASSWORD=$POSTGRES_PASSWORD/g" /opt/redash/env
sed -i "s/REDASH_DATABASE_URL=.*/REDASH_DATABASE_URL=$REDASH_DATABASE_URL/g" /opt/redash/env
#the next line creates an empty file so it won't run the next boot
echo "$(date) Updated secrets." >> $FLAG
else
echo "Secrets already set, skipping."
fi
exit 0