Menu

Installing

Bogdan Drozdowski

Initial steps - most are one-time

A supported database (currently: PostgreSQL) must be running.
On a Linux system, you would do one of:

  • login to the system as the database user postgres (you can do su - postgres as root to log in to that account on Linux) and run:
    pg_ctl start
  • login as root and run:
    systemctl start postgresqlXX (XX being the version)
  • login as root and run:
    service postgresql start

A web (HTTP) server with PHP support (like Apache HTTP Server with mod_php installed) must be running.
On a Linux system, you would do one of (as root):

  • this:
    systemctl start httpd-prefork
  • or this:
    service httpd start

Create the database user to host the application's database.
On PostgreSQL, login to the system as the database user postgres and run:

    createuser -P trinventum

You can create other database users later, and give them full or less privileges so that those users can execute all the activities or just the ones they have access to.

Create the application's database.
On PostgreSQL, login to the system as the database user postgres and run:

    createdb -O trinventum trinventum

A procedural language suitable for the database must be installed in the logical database.
On PostgreSQL versions earlier than 9.0, login to the system as the database user postgres and run:

    createlang plpgsql trinventum

(don't wory if it says that the language already exists).
Later PostgreSQL have the language already built-in by default.

Database access rules must be created within the database server unless you wish to leave the default rules.
On PostgreSQL, you would do (as the database user postgres or root):

    cp /var/lib/pgsql/data/pg_hba.conf /var/lib/pgsql/data/pg_hba.conf-backup
    echo local trinventum trinventum scram-sha-256 >> /var/lib/pgsql/data/pg_hba.conf
    echo host all all 127.0.0.1/32 scram-sha-256 >> /var/lib/pgsql/data/pg_hba.conf

(Note the double >>- it's CRUCIAL to use double >>, a single > would OVERWRITE the target file).
On older PostgreSQL versions replace scram-sha-256 with md5.

If you'll need to access the database from another computer:

  • a line similar to the host all all 127.0.0.1/32 scram-sha-256 should be added to pg_hba.conf, containing the correct IP address
  • firewall rules may need to be adjusted
  • the /etc/hosts.allow file (tcpwrappers) may need to be adjusted

After changing the access rules for the database server, restart it. On Linux with PostgreSQL, you would do one of:

  • login to the system as the database user postgres and run:
    pg_ctl restart
  • login as root and run:
    systemctl restart postgresqlXX (XX being the version)
  • login as root and run:
    service postgresql restart

Installation - web application (for manual installation)

To install:

  • copy the contents of the webapp directory (including hidden files) to a chosen location reachable by the web server and adjust the access modes accordingly so that the web server can actually run the files.
    Alternatively, if you have the make program and some common Linux utilities, you can run make install, passing the prefix of the target directory. Trinventum will be installed in $(PREFIX)/trinventum. Examples:
    make install PREFIX=/srv/www/html SERVERCONF=/etc/httpd/conf/webapps.d
    make install PREFIX=/var/www/html SERVERCONF=/etc/httpd/conf.d
    make install PREFIX=$HOME/public_html SERVERCONF=$HOME/tmp

The SERVERCONF parameter specifies where to put the global web server configuration file. Can be ignored and set to any directory for local installations.
To install the documentation, you can add a chosen directory as the DOCDIR parameter to make install. Documentation will be installed in $(DOCDIR)/trinventum. Examples:

        make install PREFIX=/srv/www/html SERVERCONF=/etc/httpd/conf/webapps.d DOCDIR=/usr/share/doc
        make install PREFIX=/var/www/html DOCDIR=/usr/share/doc
        make install PREFIX=$HOME/public_html DOCDIR=$HOME/tools/doc
  • the necessary database structures will be created by the application itself upon the first successful login of a user with full access to the database schema (like the schema owner trinventum created earlier). There is NO NEED to run any SQL scripts manually.

Installation - web application (for Docker installation)

To install Trinventum as a Docker container for testing, execute one of (as root):

    docker/docker.sh
    docker-compose -p trinventum -f docker/docker-compose.yaml up -d

in the Trinventum source code top directory (NOT the docker subdirectory).

WARNING: The default configuration has no permanent storage for the database. In order to have a persistent, working setup, you must add permanent storage to the configuration files.

WARNING: The default docker-compose.yaml file has hardcoded simple passwords. If you wish to use this file and have a secure setup, you must change those passwords in the file.

Optional - create roles and other users

Apart from the main database user (the database owner), you can have users with various privileges using the application:

  • product management,
  • seller management,
  • buyer management,
  • transaction management,
  • any mix of the above.

To create the base roles, run the scripts/create_roles.pgsql file on the database as the database administration user (postgres):

    psql -U postgres -d trinventum -f scripts/create_roles.pgsql

Then, you can use the shell command createuser to create new users - login to the system as the database user postgres and run:

    createuser -P trin_mgr
    createuser -P trin_sell
    createuser -P trin_buy
    createuser -P trin_tx

and grant the selected role(s), found in the scripts/create_roles.pgsql file, to the new user:

    psql -U postgres -d trinventum -c 'grant trinventum_product_manager to trin_mgr'
    psql -U postgres -d trinventum -c 'grant trinventum_seller_manager to trin_sell'
    psql -U postgres -d trinventum -c 'grant trinventum_buyer_manager to trin_buy'
    psql -U postgres -d trinventum -c 'grant trinventum_transaction_manager to trin_tx'

Then, you can log in as the chosen user and have access to just the required functionalities.

Uninstallation

To uninstall, if needed:

  • remove the contents of the webapp directory from the location chosen during installation (you can also run make uninstall, passing the same prefix as during the installation),

  • delete the application's database - run as postgres:

    dropdb trinventum
  • delete the application's database user - run as postgres:
    dropuser trinventum

Related

Wiki: Home
Wiki: Usage