Merge pull request #8 from xcompass/configurable-params
Allow db host, name user and password to be configurable
This commit is contained in:
commit
6918117793
@ -23,7 +23,7 @@
|
|||||||
},
|
},
|
||||||
"SqlSettings": {
|
"SqlSettings": {
|
||||||
"DriverName": "postgres",
|
"DriverName": "postgres",
|
||||||
"DataSource": "postgres://mmuser:mmuser_password@db:DB_PORT/mattermost?sslmode=disable&connect_timeout=10",
|
"DataSource": "postgres://MM_USERNAME:MM_PASSWORD@DB_HOST:DB_PORT/MM_DBNAME?sslmode=disable&connect_timeout=10",
|
||||||
"DataSourceReplicas": [],
|
"DataSourceReplicas": [],
|
||||||
"MaxIdleConns": 10,
|
"MaxIdleConns": 10,
|
||||||
"MaxOpenConns": 10,
|
"MaxOpenConns": 10,
|
||||||
|
@ -1,17 +1,26 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
config=/mattermost/config/config.json
|
config=/mattermost/config/config.json
|
||||||
|
DB_HOST=${DB_HOST:-db}
|
||||||
|
DB_PORT_5432_TCP_PORT=${DB_PORT_5432_TCP_PORT:-5432}
|
||||||
|
MM_USERNAME=${MM_USERNAME:-mmuser}
|
||||||
|
MM_PASSWORD=${MM_PASSWORD:-mmuser_password}
|
||||||
|
MM_DBNAME=${MM_DBNAME:-mattermost}
|
||||||
echo -ne "Configure database connection..."
|
echo -ne "Configure database connection..."
|
||||||
if [ ! -f $config ]
|
if [ ! -f $config ]
|
||||||
then
|
then
|
||||||
cp /config.template.json $config
|
cp /config.template.json $config
|
||||||
|
sed -Ei "s/DB_HOST/$DB_HOST/" $config
|
||||||
sed -Ei "s/DB_PORT/$DB_PORT_5432_TCP_PORT/" $config
|
sed -Ei "s/DB_PORT/$DB_PORT_5432_TCP_PORT/" $config
|
||||||
|
sed -Ei "s/MM_USERNAME/$MM_USERNAME/" $config
|
||||||
|
sed -Ei "s/MM_PASSWORD/$MM_PASSWORD/" $config
|
||||||
|
sed -Ei "s/MM_DBNAME/$MM_DBNAME/" $config
|
||||||
echo OK
|
echo OK
|
||||||
else
|
else
|
||||||
echo SKIP
|
echo SKIP
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Wait until database is ready..."
|
echo "Wait until database is ready..."
|
||||||
until nc -z db $DB_PORT_5432_TCP_PORT
|
until nc -z $DB_HOST $DB_PORT_5432_TCP_PORT
|
||||||
do
|
do
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
export PGUSER=postgres
|
#!/bin/bash
|
||||||
psql <<- EOSQL
|
set -e
|
||||||
CREATE DATABASE mattermost;
|
|
||||||
CREATE USER mmuser WITH PASSWORD 'mmuser_password';
|
MM_USERNAME=${MM_USERNAME:-mmuser}
|
||||||
GRANT ALL PRIVILEGES ON DATABASE mattermost to mmuser;
|
MM_PASSWORD=${MM_PASSWORD:-mmuser_password}
|
||||||
|
MM_DBNAME=${MM_DBNAME:-mattermost}
|
||||||
|
|
||||||
|
psql -v ON_ERROR_STOP=1 --username "postgres" <<- EOSQL
|
||||||
|
CREATE DATABASE $MM_DBNAME;
|
||||||
|
CREATE USER $MM_USERNAME WITH PASSWORD '$MM_PASSWORD';
|
||||||
|
GRANT ALL PRIVILEGES ON DATABASE $MM_DBNAME to $MM_USERNAME;
|
||||||
EOSQL
|
EOSQL
|
||||||
|
Reference in New Issue
Block a user