OTS software


  • Debian 10

install small helper packages:

apt install openssh-server
apt install zip

RDBMS Postgres

The application is based on data transfer with a database service on a remote database server. The underlying database model is named Blinkdms Magasin.

Database - features:

  • Indexing

  • Trigger, Constraints

  • Transaction (ACID)

  • Referential Integrity

  • Security

  • Locking

main Postgres directories/files:

  • [etc-config-dir] = /etc/postgresql/11/main

  • [PG_DATA_DIR] = /data/postgresql/main

  • [PG_DUMP_DIR] = /data/postgresql/dumps

Install Postgres 11:

apt-get install postgresql postgresql-contrib  (118MB)
apt-get install libpq-dev (for postgres + python)

Docu see

Manage data dir (create data dir verb+[PG_DATA_DIR]+, move original data dir to this location):

mkdir /data/postgresql/main
chown -R postgres:postgres /data/postgresql/main
mv /var/lib/postgresql/11/main /data/postgresql/

# create dump dir for export, import, backup
mkdir /data/postgresql/dumps
chown -R postgres:postgres /data/postgresql/dumps

set configs in etc-config-dir postgresql.conf :

SET standard_conforming_strings=on

set AUTHORIZATION in [etc-config-dir]/pg_hba.conf ; change ident to trust !


# "local" is for Unix domain socket connections only
local   all         all                               trust
host    all         all          trust
# IPv6 local connections:
host    all         all         ::1/128               trust

Start DB:

systemctl stop postgresql
systemctl start postgresql


  • needed for conversion docx to pdf

  • use program lowriter in the application

# size: 480MB
apt install default-jre

# size: 390MB
apt install libreoffice-java-common

# size: 50MB
apt install --no-install-recommends  libreoffice-writer

# test, if java and lowriter are installed
java -version
# output: e.g. openjdk version "" 2020-11-04

lowriter --version
# output: e.g. LibreOffice 10(Build:2)

# example convert
lowriter --convert-to pdf TR_20200709_Agarosebeads.docx

Python + Modules

  • minimum version: Python3.7

  • python3-pip (use: pip3)

  • Currently: no virtualenv !

Check Python version

python3 --version
# expected output: Python 3.7.3

# Pip (250 MB)
apt install python3-pip

# check version
pip3 --version
# output: pip 18.1

Install Pip modules:

pip3 install jsonrpcclient jsonrpcserver requests Flask  Flask-Session Flask-mail psycopg2 ldap3 python-docx

# upgrade needded for ldpa3
pip3 install --upgrade pyasn1

More details to the modules:

  • jsonrpcclient (for gozilla_jsonrpc)

  • jsonrpcserver (for JSONRPC)

  • requests (for gozilla_jsonrpc)

  • Flask

  • Flask-Session (for extented session)

  • Flask-mail (for emails)

  • psycopg2 (postgres, need apt-get package: libpq-dev)

  • ldap3 (since 2020-03)

  • python-docx (for fOffice document convert)

Webserver Nginx + uWSGI



Source as PDF: see [WebSrvInstall]

Nginx (static)

The application provides static HTML pages.

Install procedure

apt install  libssl-dev

# important PATHs:
# /var/log/daemon.log

%  apt install ufw

### NGINX ##
# see
#      how-to-install-nginx-on-ubuntu-18-04
% apt install nginx

# firewall: if needed TBD: ask your network admin
% ufw allow 'Nginx HTTP'

No create a file /etc/nginx/sites-available/blinkdms


  • If you want to set a server-name add option: server_name YOUR_LAN YOUR_HOST_NAME;

  • Please set your YOUR_HOST_NAME, set YOUR_LAN: e.g. blink.lan)

server {
    listen 8080;
    listen [::]:8080;

    location / {
        include uwsgi_params;
        uwsgi_pass unix:/opt/blinkdms/blinkdms/app.sock;

Continue configuration

# copy config to sites-enabled
ln -s /etc/nginx/sites-available/blinkdms /etc/nginx/sites-enabled
# test config
nginx -t

Important commands for maintenance: start/stop/reload

# %systemctl stop nginx
# %systemctl start nginx
# reload config
# %systemctl reload nginx
# check NGINX
# %systemctl status nginx

uWSGI (dynamic)

The application provides dynamic HTML pages.

pip3 install uwsgi

create a system service file /etc/systemd/system/blinkdms.service

Description=uWSGI instance to serve blinkdms


ExecStart=/usr/local/bin/uwsgi --ini app.ini


Continue with uwsgi starting

# create user if NOT exists
# important: the user needs a home and a shell
#    for PDF convert of command lowriter !!!

# if www-data not exists ...
# useradd -m www-data
# Whats this ??? ...
# sudo passwd www-data

# IMPORTANT: nginx and uwsgi will be started later after installing the python-code ...

# useful commands

systemctl restart nginx
systemctl stop blinkdms
systemctl start blinkdms
systemctl restart blinkdms
systemctl status blinkdms
tail /var/log/daemon.log
tail /var/log/nginx/error.log

# checks the Nginx error logs.
less /var/log/nginx/error.log
# checks the Nginx access logs
less /var/log/nginx/access.log
# checks the Nginx process logs
journalctl -u nginx
# checks your Flask app's uWSGI logs.
journalctl -u blinkdms


Info from:

% sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048
   -keyout /etc/ssl/private/nginx-selfsigned.key
   -out /etc/ssl/certs/nginx-selfsigned.crt

Country Name (2 letter code) [AU]:DE
State or Province Name (full name) [Some-State]:Thuringia
Locality Name (eg, city) []:Jena
Organization Name (eg, company) [Internet Widgits Pty Ltd]:YOUR_COMPANY
Organizational Unit Name (eg, section) []:IT
Common Name (e.g. server FQDN or YOUR name) []:YOUR_SERVER_NAME
Email Address []:your@email-address

#  create a strong Diffie-Hellman group,
% openssl dhparam -out /etc/nginx/dhparam.pem 4096

# Creating a Configuration Snippet Pointing to the SSL Key and Certificate
% sudo nano /etc/nginx/snippets/self-signed.conf

# Creating a Configuration Snippet with Strong Encryption Settings
% nano /etc/nginx/snippets/ssl-params.conf

# mod /etc/nginx/sites-available/blinkdms

# enabled changes on NGINX
% nginx -t
# see warnings
nginx: [warn] "ssl_stapling" ignored, issuer certificate not found
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

# restart
% systemctl restart nginx

Multiple Webservers


  • Goal: run multiple instances of the application with different databases.

  • blinkdms_dev runs only HTTP protocol (no SSL)


# copy /etc/nginx/sites-available/blinkdms+ to new config blinkdms_dev
# modify blinkdms_dev
% ln -s /etc/nginx/sites-available/... /etc/nginx/sites-enabled
# copy the python-code from /opt/blinkdms to /opt/blinkdms_dev
# change GROUP ownership of /opt/blinkdms_dev/blinkdms
chmod g+w blinkdms
chgrp www-data blinkdms/app.sock
chmod g+w blinkdms/app.sock

# modify /opt/blinkdms_dev/app.ini
# create new /etc/systemd/system/blinkdms_dev.service (see example below)
# modify app-config /opt/blinkdms_dev/blinkdms/conf/

# reload system configs
% systemctl daemon-reload
# restart Nginx + uWSGI
% systemctl restart nginx
% systemctl restart blinkdms_dev

Example for /etc/systemd/system/blinkdms_dev.service:

Description=uWSGI instance to serve blinkdms_dev


ExecStart=/usr/local/bin/uwsgi --ini app.ini


Application developed software

Install system code

Modify permissions for /usr/bin/lowriter

chown -R www-data:www-data  /var/www

Create data directories

mkdir /data/blinkdms
mkdir /data/blinkdms/docs
mkdir /data/blinkdms/work
chown -R www-data:www-data /data/blinkdms


copy code from [GIT_PROJECT]/blinkdms to /opt/blinkdms/blinkdms

chown -R www-data:www-data /opt/blinkdms/blinkdms

Basic Configuration

  • Resource: /opt/blinkdms/blinkdms/conf

  • copy to

Edit (at least the DB password):

superglobal['db'] = {
   'main':  {

Postgres: database schema

Scope: Create the magasin-database-schema

  • /opt/blinkdms/blinkdms/conf/

  • [SQL_SRC_DIR]=/opt/blinkdms/blinkdms/install/sql


# login as database root and create database
su -s /bin/bash postgres
createdb dmsdb

# now you are root again

create user, tablespace, schema and initial data

  • check, if config_entry [db”][“main”] exists in /opt/blinkdms/blinkdms/conf/

  • give a password for option –app_root_pw

python3 /opt/blinkdms/blinkdms/install/scripts/ --create
      --config_entry "main" --app_root_pw "XXX"

Just in case you have to delete this complete database schema + user: call this command line

python3 /opt/blinkdms/blinkdms/install/scripts/ --delete --dbuser "blinkdms"


su - postgres
psql -d dmsdb -U blinkdms
select * from DB_USER;

More tutorials for postgres + Python:


Prerequisites: the code is installed on /opt/blinkdms/blinkdms (see section “Install system code”)


  • [PYTHON_SRC_DIR]=/opt/blinkdms/blinkdms

  • the Basis-pythonpath “/opt/blinkdms” is set in file “/opt/blinkdms/blinkdms/app.ini”

Code post config

make app.sock wriuteable for www-data

chgrp www-data /opt/blinkdms/blinkdms
chmod g+w /opt/blinkdms/blinkdms
touch /opt/blinkdms/blinkdms/app.sock
chgrp www-data /opt/blinkdms/blinkdms/app.sock
chmod g+w /opt/blinkdms/blinkdms/app.sock

Link sources for Admin:

cd /opt/blinkdms/blinkdms
ln -s /opt/blinkdms/blinkdms/ADM/templates /opt/blinkdms/blinkdms/templates/ADM
ln -s /opt/blinkdms/blinkdms/ADM/static /opt/blinkdms/blinkdms/static/ADM

Start Web server

# start nginx
systemctl restart nginx

systemctl daemon-reload

# allow start of the daemon on system start ...
systemctl enable blinkdms.service

systemctl restart blinkdms

Test a python script

if you want to test a python script on command line you first have to do taht:

export PYTHONPATH=/opt/blinkdms/

First login to the system

  • go to the web browser; url: x.x.x.x:8080 (depending on your nginx config)

  • login as root, password: the password was set during “Postgres: database schema” : variable app_root_pw

  • go to the Admin area

  • run the plugin “System Check”