diff --git a/doc/getting_started/upgrade.rst b/doc/getting_started/upgrade.rst index 3ce3b85de..7d919b575 100644 --- a/doc/getting_started/upgrade.rst +++ b/doc/getting_started/upgrade.rst @@ -62,7 +62,13 @@ versions. To activate it, you need to: #. Define the ``MODOBOA_API_URL`` variable:: - MODOBOA_API_URL = 'http://api.modoboa.org/1/' + MODOBOA_API_URL = 'http://api.modoboa.org/1/' + +#. Run the following commands to define the hostname of your + instance:: + + $ cd + $ python manage.py set_default_site 1.1.7: manual learning for SpamAssassin ======================================= diff --git a/modoboa/core/commands/deploy.py b/modoboa/core/commands/deploy.py index b1bafba71..7b2883140 100644 --- a/modoboa/core/commands/deploy.py +++ b/modoboa/core/commands/deploy.py @@ -1,13 +1,16 @@ # coding: utf-8 -import sys +import getpass import os import shutil -import getpass +import sys + import subprocess -import dj_database_url from django.core import management from django.template import Context, Template + +import dj_database_url + from modoboa.lib.sysutils import exec_cmd from modoboa.core.commands import Command @@ -183,7 +186,7 @@ class DeployCommand(Command): allowed_host = parsed_args.domain[0] else: allowed_host = raw_input( - 'Under which domain do you want to deploy modoboa? ' + 'What will be the hostname used to access Modoboa? ' ) bower_components_dir = os.path.realpath( @@ -233,3 +236,7 @@ class DeployCommand(Command): self._exec_django_command( "manage_extensions", parsed_args.name, *parsed_args.extensions ) + + self._exec_django_command( + "set_default_site", parsed_args.name, allowed_host + ) diff --git a/modoboa/core/management/commands/set_default_site.py b/modoboa/core/management/commands/set_default_site.py new file mode 100644 index 000000000..03f703267 --- /dev/null +++ b/modoboa/core/management/commands/set_default_site.py @@ -0,0 +1,26 @@ +# coding: utf-8 +""" +A simple managemenent command to update the default site. + +See `https://docs.djangoproject.com/en/dev/ref/contrib/sites/`_. +""" + +from django.core.management.base import BaseCommand, CommandError + +from django.contrib.sites.models import Site + + +class Command(BaseCommand): + + """Management command to set the default site.""" + + help = 'Set default site (see django.contrib.sites)' + + def handle(self, *args, **options): + """Command entry point.""" + if not args: + raise CommandError("You must provide a hostname") + site = Site.objects.get(pk=1) + site.domain = args[0] + site.name = args[0] + site.save()