Files
ubicloud/demo/generate_env
Enes Cakir 87db291bcb Do not generate demo environment if it exists
If user has docker PostgreSQL container with existing demo environment,
overwriting environment causes mismatch between database password and
application's database password. If user has existing demo environment
file, we should not overwrite it.
2023-08-01 11:23:44 +02:00

23 lines
715 B
Bash
Executable File

#!/usr/bin/env sh
FILE="$(dirname "$0")/.env"
if [ -f "$FILE" ]; then
echo "$FILE environment file exists."
echo "Please remove it before generating a new one or use existing one."
exit 1
fi
POSTGRES_PASSWORD="$(head -c 12 /dev/random | base64 | tr -d =+/)"
CLOVER_SESSION_SECRET="$(head -c 64 /dev/random | base64)"
CLOVER_COLUMN_ENCRYPTION_KEY="$(head -c 32 /dev/random | base64)"
cat <<EOT > $(dirname "$0")/.env
RACK_ENV=development
POSTGRES_DB=clover
POSTGRES_PASSWORD="$POSTGRES_PASSWORD"
CLOVER_DATABASE_URL="postgres://postgres/clover?user=clover&password=${POSTGRES_PASSWORD}"
CLOVER_SESSION_SECRET="$CLOVER_SESSION_SECRET"
CLOVER_COLUMN_ENCRYPTION_KEY="$CLOVER_COLUMN_ENCRYPTION_KEY"
EOT