Skip to content

Commit

Permalink
feature: Added generate-compose script.
Browse files Browse the repository at this point in the history
  • Loading branch information
sundargs2000 committed Apr 30, 2021
1 parent 43438bf commit 67ce848
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
12 changes: 12 additions & 0 deletions .config
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! /bin/bash

# Mandatory settings
SETTING_EXTERNAL_HOST='localhost.localdomain'
SETTING_ZULIP_ADMINISTRATOR='[email protected]'

# Optional secrets config
POSTGRES_PASSWORD='REPLACE_WITH_SECURE_POSTGRES_PASSWORD'
MEMCACHED_PASSWORD='REPLACE_WITH_SECURE_MEMCACHED_PASSWORD'
RABBITMQ_DEFAULT_PASS='REPLACE_WITH_SECURE_RABBITMQ_PASSWORD'
REDIS_PASSWORD='REPLACE_WITH_SECURE_REDIS_PASSWORD'
SECRETS_secret_key='REPLACE_WITH_SECURE_SECRET_KEY'
4 changes: 2 additions & 2 deletions docker-compose.yml → docker-compose.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ services:
SECRETS_memcached_password: 'REPLACE_WITH_SECURE_MEMCACHED_PASSWORD'
SECRETS_redis_password: 'REPLACE_WITH_SECURE_REDIS_PASSWORD'
SECRETS_secret_key: 'REPLACE_WITH_SECURE_SECRET_KEY'
SETTING_EXTERNAL_HOST: 'localhost.localdomain'
SETTING_ZULIP_ADMINISTRATOR: '[email protected]'
SETTING_EXTERNAL_HOST: 'REPLACE_WITH_EXTERNAL_HOST'
SETTING_ZULIP_ADMINISTRATOR: 'REPLACE_WITH_ADMIN_EMAIL'
SETTING_EMAIL_HOST: '' # e.g. smtp.example.com
SETTING_EMAIL_HOST_USER: '[email protected]'
SETTING_EMAIL_PORT: '587'
Expand Down
45 changes: 45 additions & 0 deletions scripts/generate-compose.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#! /bin/bash
source .config

compose=`cat ./docker-compose.yml.in`

compose="${compose//REPLACE_WITH_EXTERNAL_HOST/$SETTING_EXTERNAL_HOST}";
compose="${compose//REPLACE_WITH_ADMIN_EMAIL/$SETTING_ZULIP_ADMINISTRATOR}";

if [ $POSTGRES_PASSWORD == "REPLACE_WITH_SECURE_POSTGRES_PASSWORD" ];
then
compose="${compose//REPLACE_WITH_SECURE_POSTGRES_PASSWORD/$(tr -dc 'abcdef1234567890' </dev/urandom | head -c 32 ; echo)}";
else
compose="${compose//REPLACE_WITH_SECURE_POSTGRES_PASSWORD/$POSTGRES_PASSWORD}";
fi;

if [ $MEMCACHED_PASSWORD == "REPLACE_WITH_SECURE_MEMCACHED_PASSWORD" ];
then
compose="${compose//REPLACE_WITH_SECURE_MEMCACHED_PASSWORD/$(tr -dc 'abcdef1234567890' </dev/urandom | head -c 32 ; echo)}";
else
compose="${compose//REPLACE_WITH_SECURE_MEMCACHED_PASSWORD/$MEMCACHED_PASSWORD}";
fi;

if [ $RABBITMQ_DEFAULT_PASS == "REPLACE_WITH_SECURE_RABBITMQ_PASSWORD" ];
then
compose="${compose//REPLACE_WITH_SECURE_RABBITMQ_PASSWORD/$(tr -dc 'abcdef1234567890' </dev/urandom | head -c 32 ; echo)}";
else
compose="${compose//REPLACE_WITH_SECURE_RABBITMQ_PASSWORD/$RABBITMQ_DEFAULT_PASS}";
fi;

if [ $REDIS_PASSWORD == "REPLACE_WITH_SECURE_REDIS_PASSWORD" ];
then
compose="${compose//REPLACE_WITH_SECURE_REDIS_PASSWORD/$(tr -dc 'abcdef1234567890' </dev/urandom | head -c 32 ; echo)}";
else
compose="${compose//REPLACE_WITH_SECURE_REDIS_PASSWORD/$REDIS_PASSWORD}";
fi;

if [ $SECRETS_secret_key == "REPLACE_WITH_SECURE_SECRET_KEY" ];
then
compose="${compose//REPLACE_WITH_SECURE_SECRET_KEY/$(tr -dc 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' </dev/urandom | head -c 64 ; echo)}";
else
compose="${compose//REPLACE_WITH_SECURE_SECRET_KEY/$SECRETS_secret_key}";
fi;


echo "$compose" > "docker-compose.yml"

0 comments on commit 67ce848

Please sign in to comment.