Install Tryton on FreeBSD v13

Tryton is open source business software that can be used for enterprise resource management (ERP) and accounting. This post describes installing Tryton (and the PostgreSQL DBMS) on FreeBSD, and is one in a series on Tryton.

Tryton naming conventions:

  • Tryton (capitalized) is the Tryton system in totality.
  • trytond is the Tryton server daemon.
  • tryton (uncapitilized) is the Tryton desktop client. 
  • sao is the Tryton web client.
  • PostgreSQL is the database management system used by Tryton.

sao will not be installed in this tutorial.

This post is a Work in Process while being updated to describe installing Tryton 6.2 and PostgreSQL 14 on FreeBSD 13.

Install FreeBSD

Install FreeBSD v13 using suitable media and perform typical initial configuration. Create an initial admin user in the install wizard and include them in the wheel group. 

After booting into the new system and logging in as the admin user, copy a public ssh key for the admin user to ~/.ssh/authorized_keys and disable ssh password authentication in /etc/ssh/sshd_config for security.

% su - 
# vi /etc/ssh/sshd_config
...
# Change to no to disable PAM authentication
ChallengeResponseAuthentication no
...
# sudo service sshd restart

Update FreeBSD and package manager database for third-party software (pkg is initially only a shim which installs the current version of pkg).

# freebsd-update fetch
# freebsd-update install
# pkg update

Install sudo for the admin user to use for system administration.

# pkg install sudo

Configure sudo to allow the admin user (and all other members of the wheel group) to allow use without needing to enter a password for convenience (reasonable on a small system).

# visudo
...
## Uncomment to allow members of group wheel to execute any command
# %wheel ALL=(ALL) ALL

## Same thing without a password
%wheel ALL=(ALL) NOPASSWD: ALL

PostgreSQL

Tryton supports the SQLite DBMS for developer testing but for production PostgreSQL will be used.  

Install the latest version of PostgreSQL (currently 14.1). 

% sudo pkg install postgresql14-server

Edit /etc/rc.conf to start the server at startup

% sudo vi /etc/rc.conf
...
postgresql_enable="YES"

Create a new PostgreSQL database cluster and start the PostgreSQL server. 

% sudo /usr/local/etc/rc.d/postgresql initdb
% sudo service postgresql start
% sudo service postgresql status

The installation procedure creates a “postgres” user who owns the PostgreSQL files and the postgres server process. The provided configuration file /var/db/postgres/data14/postgresql.conf will allow access from localhost only. 

Use the PostgreSQL createuser command to create a tryton” super-user,

% sudo su postgres
$ createuser -sdrP tryton
Enter password for new role:
Enter it again:
$ exit
%

and restart PostgreSQL.

% sudo service postgresql restart

Confirm localhost can connect to the PostgreSQL server (“-W” prompts for user password).

% psql --username=tryton -W --list
Password: 
List of databases
   Name    | Owner    | Encoding | Collate | Ctype   | Access privileges
-----------+----------+----------+---------+---------+-----------------------
 postgres  | postgres | UTF8     | C       | C.UTF-8 |
 template0 | postgres | UTF8     | C       | C.UTF-8 | =c/postgres          +
           |          |          |         |         | postgres=CTc/postgres
 template1 | postgres | UTF8     | C       | C.UTF-8 | =c/postgres          +
           |          |          |         |         | postgres=CTc/postgres
(3 rows)
%

Python

Tryton has required Python 3 since v4.4, and Python 3.8 will have been installed as a dependency of postgresql14-server. However it will be convenient to create symlinks for accessing Python in a conventional manner.

% cd /usr/local/bin
% sudo ln -s python3.8 python3
% sudo ln -s pydoc3.8 pydoc3

Also bash and and pip will need to be installed. bash (the Bourne Again SHell) is required to use Python’s built-in venv module, which will be used to create a virtual environment for Tryton to avoid potential system dependency issues. pip (the Python package manager), will be used needed to install Tryton from PyPI (the Python Package Index). 

% sudo pkg install bash
% sudo pkg install py38-pip

Unlike python3, pip will be executed simply as pip (which is a symlink to the actual executable pip3.8 created by pip installation).

pip (at least on FreeBSD) must only be used to install packages into a user directory or virtual environment to avoid creating system inconsistencies, as per the pip post-install message. 

Install the Python SQLite package so Tryton can use SQLite for testing, 

 sudo pkg install py38-sqlite3

Install System Dependencies

Tryton makes use of libxml2, an XML C parser and toolkit, and libsxlt, an XSLT C library. 

% sudo pkg install libxml2
% sudo pkg install libxslt
% sudo pkg install graphviz

graphviz is not required unless sao is being installed.

Create a directory to install trytond

Create a directory to install trytond in. A dedicated user could be created to execute trytond, and their home directory used to install trytond and for storing document attachments, but for simplicity at this time a regular user and home directory will be used.

% sudo mkdir -p ~/work/trytond

Create virtual environment

% cd ~/work/trytond
% bash
% cd work/trytond
% bash
$ python3 -m venv env
$ source env/bin/activate
(env) ~/work/trytond$

Install trytond and modules

First install trytond, which provides basic Tryton server functionality.

(env) ~/work/trytond$ pip install trytond

Next install trytond modules for required user functionality. For managing parts, bills of materials, vendors and customers, the following modules will be sufficient.

  • trytond-product 
(env) ~/work/trytond$ pip install trytond-product

You can search PiPY for Tryton Framework to see all Tryton modules. Refine the search by adding “trytond” in the search field and sort the results by last updated, which will tend to put core modules towards the top of the list.

trytond modules can have dependencies, which will also installed when a module is installed. To see all the trytond modules which have been installed, use pip to list installed modules and grep for trydond.

(env) ~/work/trytond$ pip list | grep trytond
trytond 6.2.3
(env) ~/work/trytond$

Create a log directory for trytond.

% sudo mkdir /var/log/trytond
% sudo chown -R tryton:tryton /var/log/trytond

Create a json-rpc data directory for trytond

% sudo mkdir /var/run/trytond
% sudo chown -R tryton:tryton /var/log/trytond

Create trytond.conf

The Tryton configuration file trytond.conf is read by the Tryton server daemon trytond when it starts, and includes such site-specific data as:

  • computer addresses to respond to (jsonrpc).
  • username and password for the PostgreSQL “tryton” super-user.
  • Tryton “administrator” password (required to create, drop, backup or restore a database).
  • specify FreeBSD-specific directory paths

The trytond package does not include a trytond.conf file as trytond will use reasonable defaults, including using an SQLite database. However PostgreSQL is the recommended database for use cases other than basic testing, which will require creating a suitable trytond.conf file.

Create trytond.conf with the following content:

jsonrpc = *:8000,0.0.0.0:8000
jsondata_path = /var/run/trytond

db_type = postgresql
db_host = localhost
db_port = 5432
db_user = tryton
db_password = appleton

admin_passwd = appleton

pidfile = /var/run/trytond/trytond.pid
logfile = /var/log/trytond/trytond.log

data_path = /home/tryton

Start trytond

For production use an rc script should be created to control trytond. However for simplicity trytond will be started manually.

# ~/work/env/modules/bin/trytond

trytrond can be stopped using Ctrl-C.

Create and configure a new Tryton database

Download and install tryton, the Tryton desktop client for your system. The major and minor version of tryton must be the same as the major and minor version of trytond to connect.

Launch the Tryton client and access menu: File > Databases > New database.

Enter the Tryton server admin password (“admin_passwd” in trytond.conf) in the password field, then click Change beside the IP address and change the address to that of your server.

You must enter the password first, before changing the server address, because the Tryton client will attempt to connect to the server immediately after the server address is changed, and will report “Unable to connect” if the admin password was not already entered.

Enter the name of the database to create (e.g. “scc”) and the admin password for the database, then click Create.

Login to the new database as user “admin” and the password you entered to create the database. The Module Configuration Wizard will run automatically after login to configure the new database.

  • Add user (e.g. “Dale Scott”, login “dale”), optionally add permissions (you may need to update user permissions after installing modules, so this is optional at this point),
    • add Permissions: “Administration” (which will be the only permission group available)
    • add Rule: Read, Write, Create, Delete, Model: View Search (which will be the only rule available available).

The new Tryton database can now be configured for use as per Configuring Tryton (coming soon).

7 Replies to “Install Tryton on FreeBSD v13”

  1. Hi,

    Did you consider using virtualenv?
    I think you have done a good job of documenting the major steps so far.

    Tryton documentation needs developing so I suggest that your works to date is of reasonable value to the project.

    Keep up the comments / blog, it helps us all.

    1. Thanks Tray. I have “used” virtualenv, but only in a workshop – and I was just typing what was on the screen. It’s something I need to learn more about though. I’ve had less time lately (I’m rebuilding the production server at the office to run Tryton), but hope to finish the install and config part of the tutorial in a week or two.

  2. Hi Dale, did not know you were a “local” guy working with Tryton (I’m Calgary-based too)! I started using Tryton almost 2 years ago now internally as well as for a side project, and there are some possible opportunities I am looking into for a couple of additional projects. The Tryton community is mostly overseas but very helpful and knowledgeable.

    I would have to second Tray’s suggestion. Installing in a virtualenv is my preferred method of implementing Tryton, specially on the server side. It has some advantages similar to any otehr form of virtualization–two installs of different versions could run concurrently, you don’t have to worry about dependencies being broken, easy to back up ad restore or rollback a failed upgrade and so on.

    Let me know if you are interested in a local resource for collaborating on Tryton related projects!

    1. Hi Mark, it’s great to know someone working with Tryton in Canada, let alone in Calgary! virtuanenv is definitely something I want to understand. I’ll email you privately about collaborating.

  3. Update: things are not working. I updated a FreeBSD-10 vm using freebsd-update fetch/install, pkg upgrade, and then the following to update everything that had been installed using pip:

    > pip freeze –local | grep -v ‘^\-e’ | cut -d = -f 1 | xargs pip install -U

    Now the server won’t start (“trytond module not found” error out of the /usr/local/bin/trytond script. I’m seeing how a fresh install goes in Ubuntu before getting back to this.

    Update again. I had to rebuild the server from scratch, freebsd-update, then install tryton (using virtualenv no less).

  4. I’m curious about Tryton installation on Linux. I gather they’d be slightly different than for FreeBSD. Do any of the previous posters have information on that? I will also check Dale’s email.

    Cheers,
    Vic

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.