File tryton-server.README.SUSE of Package trytond.7144

tryton-server for openSUSE
==========================

How to get it running (Without reading the instructions)
========================================================

You have already installed the package trytond and found this documentation. Good.

1) Log in as root and start the database
#su
#systemctl start postgresql

2) Change postgres parameters. You need to log in as user postgres, in order to avoid authorisation issues. Assuming we have nano as editor:
<you are logged in as user 'root'>
#su postgres
#nano /var/lib/pgsql/data/pg_hba.conf
Change the line
    local   all             all                                     md5
to
    local   all             all                                     trust
Save your input.

3) Create a role for 'tryton' in the database (sill as user postgres)
#psql -c "CREATE USER tryton WITH CREATEDB;"

4) exit as user postgres and restart postgres
#exit
#systemctl restart postgresql

5) Now lets look at /etc/tryton/trytond.conf. Uncomment the line with super_pwd (it is recommended that you set your own password here!
#nano /etc/tryton/trytond.conf
uncomment super_pwd

6) start trytond:
#systemctl start trytond
Now the Tryton Server is running. You need a client to connect to it

7) Install the tryton client:
#zypper in tryton

8) Open the tryton client:
#tryton
go to 'manage profiles' -> add -> name it 'localhost' -> Host: localhost
-> you should now see a button to create a database

DONE.


Setup (a bit more in detail)
============================

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.

We can distinguish two scenarios, to which the following description will reference:

  1) the database is created manually (recommended for productive environments)

  2) the database shall be created from the Tryton client (recommended for test)

  * In both cases, make sure PostgreSQL is running:

    # systemctl status postgresql

    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.

    If postgres runs locally, you may need to change the configuration file 
    /var/lib/pgsql/data/pg_hba.conf the line
    local   all             all                                     md5
    to
    local   all             all                                     trust
    
    Restart the database-server for the changes to take effect.
    
  * Creating the database user:
    
    The Tryton Server runs as user 'tryton', so we need a role in postgres for this.
    
    Case 1)
    For manual database creation it is sufficient to create the user as follows:
    
    su postgres
    psql -c "CREATE USER tryton WITH CREATEDB;" 
    
    Case 2)
    In case 2 the user needs additionally an encrypted password::

    su postgres
    psql -c "ALTER ROLE tryton ENCRYPTED PASSWORD 'tryton_password' ;"
    
    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):

    The openSUSE package comes with a working configuration example, see 
    /usr/share/doc/packages/trytond/trytond.conf.example
    It contains all settings for a locally running database and manual database
    configuration.
    
    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.
    
    For case 1 you do not need to do anything additional.
    For case 2 (creation of database from Tryton frontend) you need to set the
    Super password in the configuration file.
    See section super_pwd in
    http://trytond.readthedocs.org/en/latest/topics/configuration.html 
    As a result you will get an encypted password in the form
    super_pwd = grlvvq5T4r5BQ
    which is entered in /etc/tryton/trytond.conf
    
  * 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: See https://github.com/mbehrle/tryton/blob/wiki/InstallationonopenSUSE.md#Setting_up_SSL_communication_with_the_Tryton_server
    for a description to set up certificates

  * Restarting trytond:

    # systemctl restart trytond

    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 to connect to
    the server again.


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

Creating the database for Tryton
--------------------------------

For case 1, manual creation of the database, the following steps are to be performed:

  * Creating the database:

    # su - postgres -c "createdb mydb --encoding='UTF-8' --owner=tryton"

    Note: The owner of the database should be the same user, as under which the 
    tryton server runs (default:tryton) Enter a name for the database 
    (here as default: mydb).

  * Initializing the database:

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

    Note: Use the database name you chose in the previous step (here as default: 
    mydb). 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.

For case 2, you need to create an encrypted password and enter it in the
configuration file as super_pwd

See: http://doc.tryton.org/3.8/trytond/doc/topics/configuration.html


Installation of the Webfrontend for tryton (sao) from package
-------------------------------------------------------------

For most openSUSE Flavours tryton-sao is packed. You can install it with
     zypper install tryton-sao

You need to edit /etc/tryton/trytond.conf. Installation of tryton-sao follows the 
standards for nodejs-installations, so the path is within the node-modules:

In the section [jsonrpc], set the data path:
    data = /usr/lib/node-modules/tryton-sao

Now restart trytond.

Installation of the Webfrontend for tryton (sao) from source
------------------------------------------------------------

In case you want to install sao from source:
sao bases on nodejs, and it comes as separate package. Download and extract 
tryton-sao into a directory, say /srv/tryton-sao

Make sure you have nodejs and git installed:
    zypper install nodejs git

Now change into to installation directory and install sao:
    cd /srv/tryton-sao/package
    npm install

Now you need to run grunt. make sure it is run from the locally installed version:
    cd /srv/tryton-sao/package
    node_modules/grunt-cli/bin/grunt

Last but not least, edit /etc/tryton/trytond.conf
In the section [jsonrpc], set the data path:
    data = /srv/tryton-sao/package

Now restart trytond.
    

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 mydb

    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 runs by default under the user 'tryton', who is setup as no-login. 
    If you need to login as user tryton, use su - tryton -s /bin/bash

  * 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).

  * 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].

  * modules can be installed via YaST or zypper, e.g. zypper in trytond_account
  
  * 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_*) you have installed on your system. 
        
  * Only the same major version of Tryton client and Tryton server can connect.

 -- Axel Braun <axel.braun@gmx.de> Wed Sep 28 18:35:02 UTC 2016
openSUSE Build Service is sponsored by