Create a superuser if environment variables are defined. (#93)

Create a superuser if environment variables are defined.
This commit is contained in:
Abhilash Raj
2017-07-26 03:23:00 -07:00
committed by GitHub
parent 2af47047bc
commit 77b260a2ac
3 changed files with 19 additions and 0 deletions

View File

@@ -115,6 +115,10 @@ These are the settings that you MUST change before deploying:
- `HYPERKITTY_API_KEY`: Hyperkitty's API Key, should be set to the same value as
set for the mailman-core.
- `MAILMAN_ADMIN_USER`: The username for the admin user to be created by default.
- `MAILMAN_ADMIN_EMAIL`: The email for the admin user to be created by default.
For more details on how to configure this image, please look at [Mailman-web's
Readme](web/README.md)

View File

@@ -17,6 +17,10 @@ These are the settings that you MUST change before deploying:
- `HYPERKITTY_API_KEY`: Hyperkitty's API Key, should be set to the same value as
set for the mailman-core.
- `MAILMAN_ADMIN_USER`: The username for the admin user to be created by default.
- `MAILMAN_ADMIN_EMAIL`: The email for the admin user to be created by default.
These are the settings that are set to sane default and you do not need to
change them unless you know what you want.

View File

@@ -89,6 +89,17 @@ python manage.py collectstatic --noinput
# this command will upgrade the database.
python manage.py migrate
# If MAILMAN_ADMIN_USER and MAILMAN_ADMIN_EMAIL is defined create a new
# superuser for Django. There is no password setup so it can't login yet unless
# the password is reset.
if [[ -v MAILMAN_ADMIN_USER ]] && [[ -v MAILMAN_ADMIN_EMAIL ]];
then
echo "Creating admin user..."
python manage.py createsuperuser --noinput --username "$MAILMAN_ADMIN_USER" --email "$MAILMAN_ADMIN_EMAIL"
fi
# Create a mailman user with the specific UID and GID and do not create home
# directory for it. Also chown the logs directory to write the files.
chown mailman:mailman /opt/mailman-web-data -R