Commit 369341218c6d351c85fba946aba5733ee3d331f6
1 parent
8b9261cb
Exists in
master
and in
39 other branches
Added command to generate basic configs
Showing
4 changed files
with
80 additions
and
53 deletions
Show diff stats
colab/colab.template.yaml
| ... | ... | @@ -1,53 +0,0 @@ |
| 1 | - | |
| 2 | -DEBUG: false | |
| 3 | -TEMPLATE_DEBUG: false | |
| 4 | - | |
| 5 | -ADMINS: &admin | |
| 6 | - - | |
| 7 | - - John Foo | |
| 8 | - - john@example.com | |
| 9 | - - | |
| 10 | - - Mary Bar | |
| 11 | - - mary@example.com | |
| 12 | - | |
| 13 | -MANAGERS: *admin | |
| 14 | - | |
| 15 | -COLAB_FROM_ADDRESS: '"Colab" <noreply@example.com>' | |
| 16 | -SERVER_EMAIL: '"Colab" <noreply@example.com>' | |
| 17 | - | |
| 18 | -EMAIL_HOST: localhost | |
| 19 | -EMAIL_PORT: 25 | |
| 20 | -EMAIL_SUBJECT_PREFIX: '[colab]' | |
| 21 | - | |
| 22 | -SECRET_KEY: '{{ secret_key }}' | |
| 23 | - | |
| 24 | -SITE_URL: 'http://www.example.com/' | |
| 25 | - | |
| 26 | -ALLOWED_HOSTS: | |
| 27 | - - example.com | |
| 28 | - - example.org | |
| 29 | - - example.net | |
| 30 | - | |
| 31 | -CONVERSEJS_ENABLED: false | |
| 32 | - | |
| 33 | -CONVERSEJS_AUTO_REGISTER: 'xmpp.example.com' | |
| 34 | - | |
| 35 | -DATABASES: | |
| 36 | - default: | |
| 37 | - ENGINE: django.db.backends.postgresql_psycopg2 | |
| 38 | - HOST: localhost | |
| 39 | - NAME: colab | |
| 40 | - USER: colab | |
| 41 | - PASSWORD: colab | |
| 42 | - | |
| 43 | -ROBOTS_NOINDEX: false | |
| 44 | - | |
| 45 | -# Set to false to disable | |
| 46 | -RAVEN_DSN: 'http://public:secret@example.com/1' | |
| 47 | - | |
| 48 | -PROXIED_APPS: | |
| 49 | - gitlab: | |
| 50 | - upstream: 'http://localhost:8090/gitlab/' | |
| 51 | - trac: | |
| 52 | - upstream: 'http://localhost:5000/trac/' | |
| 53 | - |
colab/management/__init__.py
| 1 | 1 | |
| 2 | 2 | import os |
| 3 | + | |
| 3 | 4 | from django.core.management import ManagementUtility |
| 4 | 5 | |
| 6 | +from .initconfig import initconfig | |
| 7 | + | |
| 5 | 8 | |
| 6 | 9 | def execute_from_command_line(argv=None): |
| 7 | 10 | """ |
| ... | ... | @@ -12,3 +15,7 @@ def execute_from_command_line(argv=None): |
| 12 | 15 | |
| 13 | 16 | utility = ManagementUtility(argv) |
| 14 | 17 | utility.execute() |
| 18 | + | |
| 19 | + | |
| 20 | +def run_colab_config(argv=None): | |
| 21 | + initconfig() | ... | ... |
| ... | ... | @@ -0,0 +1,72 @@ |
| 1 | + | |
| 2 | +from django.utils.crypto import get_random_string | |
| 3 | + | |
| 4 | + | |
| 5 | +CONFIG_TEMPLATE = """ | |
| 6 | + | |
| 7 | +## Set to false in production | |
| 8 | +DEBUG: true | |
| 9 | +TEMPLATE_DEBUG: true | |
| 10 | + | |
| 11 | +## System admins | |
| 12 | +ADMINS: &admin | |
| 13 | + - | |
| 14 | + - John Foo | |
| 15 | + - john@example.com | |
| 16 | + - | |
| 17 | + - Mary Bar | |
| 18 | + - mary@example.com | |
| 19 | + | |
| 20 | +MANAGERS: *admin | |
| 21 | + | |
| 22 | +COLAB_FROM_ADDRESS: '"Colab" <noreply@example.com>' | |
| 23 | +SERVER_EMAIL: '"Colab" <noreply@example.com>' | |
| 24 | + | |
| 25 | +EMAIL_HOST: localhost | |
| 26 | +EMAIL_PORT: 25 | |
| 27 | +EMAIL_SUBJECT_PREFIX: '[colab]' | |
| 28 | + | |
| 29 | +SECRET_KEY: '{secret_key}' | |
| 30 | + | |
| 31 | +SITE_URL: 'http://www.example.com/' | |
| 32 | + | |
| 33 | +ALLOWED_HOSTS: | |
| 34 | + - example.com | |
| 35 | + - example.org | |
| 36 | + - example.net | |
| 37 | + | |
| 38 | +### Uncomment to enable Converse.js | |
| 39 | +# CONVERSEJS_ENABLED: True | |
| 40 | + | |
| 41 | +### Uncomment to enable auto-registration | |
| 42 | +# CONVERSEJS_AUTO_REGISTER: 'xmpp.example.com' | |
| 43 | + | |
| 44 | +## Database settings | |
| 45 | +DATABASES: | |
| 46 | + default: | |
| 47 | + ENGINE: django.db.backends.postgresql_psycopg2 | |
| 48 | + HOST: localhost | |
| 49 | + NAME: colab | |
| 50 | + USER: colab | |
| 51 | + PASSWORD: colab | |
| 52 | + | |
| 53 | +## Disable indexing | |
| 54 | +ROBOTS_NOINDEX: false | |
| 55 | + | |
| 56 | +### Log errors to Sentry instance | |
| 57 | +# RAVEN_DSN: 'http://public:secret@example.com/1' | |
| 58 | + | |
| 59 | +### Colab proxied apps | |
| 60 | +# PROXIED_APPS: | |
| 61 | +# gitlab: | |
| 62 | +# upstream: 'http://localhost:8090/gitlab/' | |
| 63 | +# trac: | |
| 64 | +# upstream: 'http://localhost:5000/trac/' | |
| 65 | + | |
| 66 | +""" | |
| 67 | + | |
| 68 | + | |
| 69 | +def initconfig(): | |
| 70 | + chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)' | |
| 71 | + secret_key = get_random_string(50, chars) | |
| 72 | + print(CONFIG_TEMPLATE.format(secret_key=secret_key)) | ... | ... |
setup.py
| ... | ... | @@ -21,6 +21,7 @@ setup( |
| 21 | 21 | include_package_data=True, |
| 22 | 22 | entry_points={'console_scripts': [ |
| 23 | 23 | 'colab-admin = colab.management:execute_from_command_line', |
| 24 | + 'colab-init-config = colab.management:initconfig', | |
| 24 | 25 | ]}, |
| 25 | 26 | zip_safe=False, |
| 26 | 27 | long_description=open('README.rst').read(), | ... | ... |