<commit_before>#######
Upgrade
#######

Modoboa
*******

.. warning::

   The new version you are going to install may need to modify your
   database. Before you start, make sure to backup everything!

Most of the time, upgrading your installation to a newer Modoboa
version only requires a few actions. In every case, you will need to
apply the general procedure first and then check if the version you
are installing requires specific actions.

In case you use a dedicated user and/or a virtualenv, do not forget to
use them:

.. sourcecode:: bash

   > sudo -u <modoboa_user> -i
   > source <virtuenv_path>/bin/activate

Then, run the following commands:

.. sourcecode:: bash

   > pip install modoboa==<VERSION>
   > cd <modoboa_instance_dir>
   > python manage.py migrate
   > python manage.py collectstatic
   > python manage.py check --deploy

Once done, check if the version you are installing requires
:ref:`specific_upgrade_instructions`.

Finally, restart your web server.

Sometimes, you might need to upgrade postfix map files too. To do so,
just run the ``generate_postfix_maps`` command on the same directory
than the one used for installation (:file:`/etc/postfix` by default).

Make sure to use root privileges and run the following command:

.. sourcecode:: bash

   > python manage.py generate_postfix_maps --destdir <directory>

Then, reload postfix.

Extensions
**********

If a new version is available for an extension you're using, it is
recommanded to install it. Upgrading an extensions is pretty and the
procedure is almost the same than the one used for Modoboa.

In case you use a dedicated user and/or a virtualenv, do not forget to
use them:

.. sourcecode:: bash

   > sudo -i <modoboa_user>
   > source <virtuenv_path>/bin/activate

Then, run the following commands:

.. sourcecode:: bash

   > pip install <EXTENSION>==<VERSION>
   > cd <modoboa_instance_dir>
   > python manage.py migrate
   > python manage.py collectstatic
   > python manage.py check --deploy

Finally, restart your web server.

It is a generic upgrade procedure which will be enough most of the
time but it is generally a good idea to check the associated
documentation.

Rebuild Virtual Environment
***************************

.. include:: rebuild_virtual_env.rst

.. _specific_upgrade_instructions:

Specific instructions
*********************

1.10.0
======

.. warning::

   Upgrade installed extensions BEFORE running ``check`` or
   ``migrate`` commands.

Upgrade all your installed plugins to the following versions:

.. warning::

   If you use the amavis plugin, make sure to include its
   configuration as follows into :file:`settings.py`:

   .. sourcecode:: python

      from modoboa_amavis import settings as modoboa_amavis_settings
      modoboa_amavis_settings.apply(globals())

+------------------------------+------------------------------+
|Name                          |Version                       |
+==============================+==============================+
|modoboa-amavis                |1.2.0                         |
+------------------------------+------------------------------+
|modoboa-contacts              |0.5.0                         |
+------------------------------+------------------------------+
|modoboa-dmarc                 |1.1.0                         |
+------------------------------+------------------------------+
|modoboa-imap-migration        |1.2.0                         |
+------------------------------+------------------------------+
|modoboa-pdfcredentials        |1.3.0                         |
+------------------------------+------------------------------+
|modoboa-postfix-autoreply     |1.4.0                         |
+------------------------------+------------------------------+
|modoboa-radicale              |1.2.0                         |
+------------------------------+------------------------------+
|modoboa-sievefilters          |1.4.0                         |
+------------------------------+------------------------------+
|modoboa-stats                 |1.4.0                         |
+------------------------------+------------------------------+
|modoboa-webmail               |1.4.0                         |
+------------------------------+------------------------------+

Edit the :file:`settings.py` file and apply the following modifications.

Add ``'modoboa.transport'`` to ``MODOBOA_APPS``:

.. sourcecode:: python

   MODOBOA_APPS = (
      'modoboa',
      'modoboa.core',
      'modoboa.lib',
      'modoboa.admin',
      'modoboa.transport',
      'modoboa.relaydomains',
      'modoboa.limits',
      'modoboa.parameters',
   )

Replace the following line:

.. sourcecode:: python

   MIDDLEWARE_CLASSES = (

by:

.. sourcecode:: python

   MIDDLEWARE = (

Update postfix map files as follows:

.. sourcecode:: bash

   > rm -f <path>/modoboa-postfix-maps.chk
   > python manage.py generate_postfix_maps --force --destdir <path>

Then, modify postfix's configuration as follows::

    smtpd_sender_login_maps =
      <driver>:<path>/sql-sender-login-map.cf

    transport_maps =
      <driver>:<path>/sql-transport.cf
      <driver>:<path>/sql-spliteddomains-transport.cf
      # other map files...

Replace ``<driver>`` and ``<path>`` by your values.

If ``transport_maps`` contains ``sql-relaydomains-transport.cf``, remove it.

Reload postfix.

Add the following cron job in order to generate DKIM keys::

  # Generate DKIM keys (they will belong to the user running this job)
  *       *       *       *       *       root    $PYTHON $INSTANCE/manage.py modo manage_dkim_keys

1.9.0
=====

If you want to manage inactive accounts, look at :ref:`inactive_accounts`.

1.8.3
=====

Edit the :file:`settings.py` file and replace the following line:

.. sourcecode:: python

   BASE_DIR = os.path.dirname(os.path.dirname(__file__))

by:

.. sourcecode:: python

   BASE_DIR = os.path.realpath(os.path.dirname(os.path.dirname(__file__)))

1.8.0
=====
<commit_msg>doc: Added warning about proxy_read_maps.<commit_after>#######
Upgrade
#######

Modoboa
*******

.. warning::

   The new version you are going to install may need to modify your
   database. Before you start, make sure to backup everything!

Most of the time, upgrading your installation to a newer Modoboa
version only requires a few actions. In every case, you will need to
apply the general procedure first and then check if the version you
are installing requires specific actions.

In case you use a dedicated user and/or a virtualenv, do not forget to
use them:

.. sourcecode:: bash

   > sudo -u <modoboa_user> -i
   > source <virtuenv_path>/bin/activate

Then, run the following commands:

.. sourcecode:: bash

   > pip install modoboa==<VERSION>
   > cd <modoboa_instance_dir>
   > python manage.py migrate
   > python manage.py collectstatic
   > python manage.py check --deploy

Once done, check if the version you are installing requires
:ref:`specific_upgrade_instructions`.

Finally, restart your web server.

Sometimes, you might need to upgrade postfix map files too. To do so,
just run the ``generate_postfix_maps`` command on the same directory
than the one used for installation (:file:`/etc/postfix` by default).

Make sure to use root privileges and run the following command:

.. sourcecode:: bash

   > python manage.py generate_postfix_maps --destdir <directory>

Then, reload postfix.

Extensions
**********

If a new version is available for an extension you're using, it is
recommanded to install it. Upgrading an extensions is pretty and the
procedure is almost the same than the one used for Modoboa.

In case you use a dedicated user and/or a virtualenv, do not forget to
use them:

.. sourcecode:: bash

   > sudo -i <modoboa_user>
   > source <virtuenv_path>/bin/activate

Then, run the following commands:

.. sourcecode:: bash

   > pip install <EXTENSION>==<VERSION>
   > cd <modoboa_instance_dir>
   > python manage.py migrate
   > python manage.py collectstatic
   > python manage.py check --deploy

Finally, restart your web server.

It is a generic upgrade procedure which will be enough most of the
time but it is generally a good idea to check the associated
documentation.

Rebuild Virtual Environment
***************************

.. include:: rebuild_virtual_env.rst

.. _specific_upgrade_instructions:

Specific instructions
*********************

1.10.0
======

.. warning::

   Upgrade installed extensions BEFORE running ``check`` or
   ``migrate`` commands.

Upgrade all your installed plugins to the following versions:

.. warning::

   If you use the amavis plugin, make sure to include its
   configuration as follows into :file:`settings.py`:

   .. sourcecode:: python

      from modoboa_amavis import settings as modoboa_amavis_settings
      modoboa_amavis_settings.apply(globals())

+------------------------------+------------------------------+
|Name                          |Version                       |
+==============================+==============================+
|modoboa-amavis                |1.2.0                         |
+------------------------------+------------------------------+
|modoboa-contacts              |0.5.0                         |
+------------------------------+------------------------------+
|modoboa-dmarc                 |1.1.0                         |
+------------------------------+------------------------------+
|modoboa-imap-migration        |1.2.0                         |
+------------------------------+------------------------------+
|modoboa-pdfcredentials        |1.3.0                         |
+------------------------------+------------------------------+
|modoboa-postfix-autoreply     |1.4.0                         |
+------------------------------+------------------------------+
|modoboa-radicale              |1.2.0                         |
+------------------------------+------------------------------+
|modoboa-sievefilters          |1.4.0                         |
+------------------------------+------------------------------+
|modoboa-stats                 |1.4.0                         |
+------------------------------+------------------------------+
|modoboa-webmail               |1.4.0                         |
+------------------------------+------------------------------+

Edit the :file:`settings.py` file and apply the following modifications.

Add ``'modoboa.transport'`` to ``MODOBOA_APPS``:

.. sourcecode:: python

   MODOBOA_APPS = (
      'modoboa',
      'modoboa.core',
      'modoboa.lib',
      'modoboa.admin',
      'modoboa.transport',
      'modoboa.relaydomains',
      'modoboa.limits',
      'modoboa.parameters',
   )

Replace the following line:

.. sourcecode:: python

   MIDDLEWARE_CLASSES = (

by:

.. sourcecode:: python

   MIDDLEWARE = (

Update postfix map files as follows:

.. sourcecode:: bash

   > rm -f <path>/modoboa-postfix-maps.chk
   > python manage.py generate_postfix_maps --force --destdir <path>

Then, modify postfix's configuration as follows::

    smtpd_sender_login_maps =
      <driver>:<path>/sql-sender-login-map.cf

    transport_maps =
      <driver>:<path>/sql-transport.cf
      <driver>:<path>/sql-spliteddomains-transport.cf
      # other map files...

Replace ``<driver>`` and ``<path>`` by your values.

If ``transport_maps`` contains ``sql-relaydomains-transport.cf``, remove it.

.. warning::

   If you make use of postfix's `proxymap server
   <http://www.postfix.org/proxymap.8.html>`_, you must also update
   the ``proxy_read_maps`` setting.

Reload postfix.

Add the following cron job in order to generate DKIM keys::

  # Generate DKIM keys (they will belong to the user running this job)
  *       *       *       *       *       root    $PYTHON $INSTANCE/manage.py modo manage_dkim_keys

1.9.0
=====

If you want to manage inactive accounts, look at :ref:`inactive_accounts`.

1.8.3
=====

Edit the :file:`settings.py` file and replace the following line:

.. sourcecode:: python

   BASE_DIR = os.path.dirname(os.path.dirname(__file__))

by:

.. sourcecode:: python

   BASE_DIR = os.path.realpath(os.path.dirname(os.path.dirname(__file__)))

1.8.0
=====

{'fraction_non_alphanumeric': 0.21941379878149184, 'fraction_numerical': 0.0071628519677260005, 'mean_word_length': 1.844064621868415, 'pattern_counts': {'":': 0, '<': 44, '<?xml version=': 0, '>': 78, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3986458', 'n_tokens_mistral': 3381, 'n_tokens_neox': 3184, 'n_words': 1039}