Database configuration should be set properly when using sqlite. (#78)
This will fix the default settings for sqlite database when running mailman-core image.
This commit is contained in:
@@ -109,10 +109,17 @@ api_key: $HYPERKITTY_API_KEY
|
|||||||
MTA
|
MTA
|
||||||
===
|
===
|
||||||
|
|
||||||
[Exim4][2] is the recommended MTA for this image. The [recommended
|
You can use Postfix or [Exim][2] with this image to send emails. Mailman Core
|
||||||
configuration][3] to run exim for this image can be found on github repository.
|
can interact with any modern MTA which can deliver emails over LMTP. The
|
||||||
|
documentation for Mailman Core has configuration settigs for using them.
|
||||||
|
|
||||||
|
Only Exim and Postfix has been tested with these images and are supported as of
|
||||||
|
now. There _might_ be some limitations with using other MTAs in a containerized
|
||||||
|
environments. Contributions are welcome for anything additional needed to
|
||||||
|
support other MTAs.
|
||||||
|
|
||||||
|
To setup Exim or Posfix, checkout the [documentation][3].
|
||||||
|
|
||||||
[1]: https://github.com/maxking/docker-mailman
|
[1]: https://github.com/maxking/docker-mailman
|
||||||
[2]: http://www.exim.org
|
[2]: http://www.exim.org
|
||||||
[3]: https://github.com/maxking/docker-mailman#setting-up-your-mta
|
[3]: https://asynchronous.in/docker-mailman#setting-up-your-mta
|
||||||
|
|||||||
@@ -22,34 +22,13 @@ function wait_for_postgres () {
|
|||||||
>&2 echo "Postgres is up - continuing"
|
>&2 echo "Postgres is up - continuing"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Empty the config file.
|
||||||
# Check if $DATABASE_URL is defined, if not, use a standard sqlite database.
|
echo "# This file is autogenerated at container startup." > /etc/mailman.cfg
|
||||||
#
|
|
||||||
# If the $DATABASE_URL is defined and is postgres, check if it is available
|
|
||||||
# yet. Do not start the container before the postgresql boots up.
|
|
||||||
#
|
|
||||||
# TODO: If the $DATABASE_URL is defined and is mysql, check if the database is
|
|
||||||
# available before the container boots up.
|
|
||||||
#
|
|
||||||
# TODO: Check the database type and detect if it is up based on that. For now,
|
|
||||||
# assume that postgres is being used if DATABASE_URL is defined.
|
|
||||||
if [[ ! -v DATABASE_URL ]]; then
|
|
||||||
echo "DATABASE_URL is not defined. Using sqlite database..."
|
|
||||||
export DATABASE_URL=sqlite:///mailman.db
|
|
||||||
export DATABASE_TYPE='sqlite'
|
|
||||||
export DATABASE_CLASS='mailman.database.sqlite.SQLiteDatabase'
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
if [[ "$DATABASE_TYPE" = 'postgres' ]]
|
|
||||||
then
|
|
||||||
wait_for_postgres
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if $MM_HOSTNAME is set, if not, set it to a default value.
|
# Check if $MM_HOSTNAME is set, if not, set it to a default value.
|
||||||
# TODO: Factor this out to a function.
|
# TODO: Factor this out to a function.
|
||||||
if [[ ! -v MM_HOSTNAME ]]; then
|
if [[ ! -v MM_HOSTNAME ]]; then
|
||||||
export MM_HOSTNAME=mailman-core
|
export MM_HOSTNAME='172.19.199.2'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -v SMTP_HOST ]]; then
|
if [[ ! -v SMTP_HOST ]]; then
|
||||||
@@ -64,8 +43,46 @@ if [[ ! -v HYPERKITTY_URL ]]; then
|
|||||||
export HYPERKITTY_URL=http://mailman-web:8000/
|
export HYPERKITTY_URL=http://mailman-web:8000/
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
function setup_database () {
|
||||||
|
if [[ ! -v DATABASE_URL ]]
|
||||||
|
then
|
||||||
|
echo "Environemnt variable DATABASE_URL should be defined..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat >> /etc/mailman.cfg <<EOF
|
||||||
|
[database]
|
||||||
|
class: $DATABASE_CLASS
|
||||||
|
url: $DATABASE_URL
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Check if $DATABASE_URL is defined, if not, use a standard sqlite database.
|
||||||
|
#
|
||||||
|
# If the $DATABASE_URL is defined and is postgres, check if it is available
|
||||||
|
# yet. Do not start the container before the postgresql boots up.
|
||||||
|
#
|
||||||
|
# TODO: If the $DATABASE_URL is defined and is mysql, check if the database is
|
||||||
|
# available before the container boots up.
|
||||||
|
#
|
||||||
|
# TODO: Check the database type and detect if it is up based on that. For now,
|
||||||
|
# assume that postgres is being used if DATABASE_URL is defined.
|
||||||
|
if [[ ! -v DATABASE_URL ]]; then
|
||||||
|
echo "DATABASE_URL is not defined. Using sqlite database..."
|
||||||
|
else
|
||||||
|
setup_database
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [[ "$DATABASE_TYPE" = 'postgres' ]]
|
||||||
|
then
|
||||||
|
wait_for_postgres
|
||||||
|
fi
|
||||||
|
|
||||||
# Generate a basic mailman.cfg.
|
# Generate a basic mailman.cfg.
|
||||||
cat > /etc/mailman.cfg <<EOF
|
cat >> /etc/mailman.cfg <<EOF
|
||||||
[mta]
|
[mta]
|
||||||
incoming: mailman.mta.exim4.LMTP
|
incoming: mailman.mta.exim4.LMTP
|
||||||
outgoing: mailman.mta.deliver.deliver
|
outgoing: mailman.mta.deliver.deliver
|
||||||
@@ -85,10 +102,6 @@ hostname: $MM_HOSTNAME
|
|||||||
class: mailman_hyperkitty.Archiver
|
class: mailman_hyperkitty.Archiver
|
||||||
enable: yes
|
enable: yes
|
||||||
configuration: /etc/mailman-hyperkitty.cfg
|
configuration: /etc/mailman-hyperkitty.cfg
|
||||||
|
|
||||||
[database]
|
|
||||||
class: $DATABASE_CLASS
|
|
||||||
url: $DATABASE_URL
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Generate a basic configuration to use postfix.
|
# Generate a basic configuration to use postfix.
|
||||||
|
|||||||
Reference in New Issue
Block a user