tryton-server for Debian
========================

Setup
=====

Preparing the database
----------------------

Tryton uses a Relational Database Management System (RDBMS) to store data. The
preferred RDBMS for Tryton is PostgreSQL.

You have to setup this database manually. Here is a short explanation how to
achieve this (you need to execute all commands as root):

  * Making sure, PostgreSQL is running:

    # service postgresql* restart

    Note: If PostgreSQL runs on another machine than the Tryton server, make sure
    you have setup database password authentication. Please refer to the
    PostgreSQL manual how to do this. If they run on the same machine, connection
    via local sockets is preferred and you are done with the default configuration
    of the PostgreSQL package.

  * Creating the database user:

    # su - postgres -c "createuser --createdb --no-createrole --no-superuser \
        --pwprompt tryton"

    You have to enter
    * a password for the future database user (this will be used later in the
      setup of the database URI in /etc/tryton/trytond.conf as password)
    * confirm it
    * and finally enter the password of the postgres superuser.

    Note: If you want to run the database as another user than 'tryton', you
    need to replace 'tryton' above with the user you want to use instead.

Preparing the Tryton server
---------------------------

  * Setting up the Tryton server (trytond):

    Adjust /etc/tryton/trytond.conf to reflect the setup of your system by using
    the database user and password from step 1 for the database URI.

  * If the Tryton server shall listen on some external interface (i.e. shall be
    available for clients connecting from other machines), change the jsonrpc
    protocol to listen accordingly.

  * If the Tryton server is listening on external interfaces, it is highly
    recommended to enable SSL for the connection.

    Note: The package is prepared to use the snakeoil certfificates from
    the ssl-cert package. If you are installing the ssl-cert package after
    the tryton-server package, take care to add the tryton user to the
    ssl-cert group with

    # adduser tryton ssl-cert

  * Restarting trytond:

    # service tryton-server restart

    Note: The fingerprint of connected servers is stored in the clients
    known_hosts file. When a server is changed for its SSL usage, the client
    will refuse to reconnect to this server. Removing the according line
    from ~/.config/tryton/<version>/known_hosts will allow one to connect to
    the server again.


Now you are ready to connect with a client, e.g. tryton-client.

Creating the database
---------------------

Note: The following steps can also be performed easily from the Tryton
Client and are not mandatory to be done on the command line.

  * Creating the database:

    # su - postgres -c "createdb --encoding=UNICODE --owner=tryton tryton"

    Note: Use your database user for tryton as owner of the database, and enter
    a name for the database (here as default: tryton).

  * Initializing the database:

    # /usr/bin/trytond -c /etc/tryton/trytond.conf -u res -d tryton

    Note: Use the database name you chose in the previous step (here as default: tryton).
    You will be asked for the admin password for this database.

As result you will have a bare Tryton database with the base modules installed.

Upgrade
-------

  * Once you have upgraded to a new major version (second number of the
    version string) you have to update your database(s).
    After the categorically recommended backup do:

    # /usr/bin/trytond -c /etc/tryton/trytond.conf --all -d tryton

    Remember to replace tryton with the name of your database.


Notes
-----

Now, you're finished with the system setup. Please be aware of the following things:

  * trytond has one default account for server administration:
    - User: admin; password: the one you have configured in trytond.conf
    as super_pwd. This user is the one used for database management tasks
    from the client.

    Note: Each Tryton database will have its own admin with login password
    stored in the database itself (not to be confound with the admin of the
    Tryton Server).

  * trytond must have read access to its configuration file, otherwise it will
    start with internal defaults. The postinst script will (re)set ownership to
    the system user running trytond and correct the permissions on the standard
    configuration file (/etc/tryton/trytond.conf), if not otherwise stated by
    means of dpkg-statoverride.

  * trytond listens by default on port 8000 (jsonrpc). If you need to change
    this, edit /etc/tryton/trytond.conf in the section [jsonrpc].

  * trytond in its upstream configuration listens by default to the localhost
    interface. If you want to change this default to listen on all interfaces,
    edit /etc/tryton/trytond.conf in the section [jsonrpc].

  * Installation of modules into the database can be done from the
    Administration Panel of the client. Under Modules you can select from the
    modules packages (trytond-modules*) you have installed on your system.

  * Only the same major version of Tryton client and Tryton server can connect.

 -- Mathias Behrle <mathiasb@m9s.biz>  Tue, 22 Oct 2014 16:45:00 +0200
