From 2d708954936dcc3708d260dc2427fd41922dc1d7 Mon Sep 17 00:00:00 2001
From: Jan Mach <jan.mach@cesnet.cz>
Date: Wed, 19 May 2021 18:27:38 +0200
Subject: [PATCH] Unpolished proof of concept for the use of Vagrant for local
 Mentat development.

Original idea wa to use Docker for this purpose, but it turned out full
featured virtual server will be much better suited for this task due to
the comlexity of the whole environment.

(Redmine issue: #7041)
---
 .gitignore                                    |  10 +-
 .vagrantenv/.bashrc                           | 122 ++++++++++++++
 .vagrantenv/apt.list                          |   1 +
 .vagrantenv/finalize.sh                       |  25 +++
 .vagrantenv/postfix.main.cf                   |  46 ++++++
 .vagrantenv/provision.sh                      | 153 ++++++++++++++++++
 Makefile                                      |  43 ++++-
 Vagrantfile                                   |  54 +++++++
 conf/apache/site_mentat_vagrant.conf          | 112 +++++++++++++
 conf/core/database.json.conf                  |   6 +-
 .../migrations-events}/README                 |   0
 .../migrations-events}/alembic.ini            |   0
 .../migrations-events}/env.py                 |   0
 .../migrations-events}/script.py.mako         |   0
 .../versions/.gitplaceholder                  |   0
 ...a714_split_event_column_from_events_to_.py |   0
 .../102ae7b9979f_remove_cesnet__prefix.py     |   0
 ...d_added_support_for_aggregated_address_.py |   0
 ...c3b_make_data_in_cesnet_eventclass_not_.py |   0
 conf/requirements-dev.pip                     |   1 +
 conf/requirements-latest-dev.pip              |   1 +
 conf/requirements.pip                         |   2 +-
 {scripts => conf/scripts}/as-dump.sh          |   0
 {scripts => conf/scripts}/depcheck.py         |   0
 {scripts => conf/scripts}/fetch-negistry.sh   |   0
 conf/scripts/lib-mentat.sh                    |  29 ++++
 conf/scripts/lib.sh                           |  13 ++
 {scripts => conf/scripts}/lwchroot-init.sh    |   0
 {scripts => conf/scripts}/maintenance-mode.sh |   0
 .../scripts}/mentat-check-alive.sh            |   0
 .../scripts}/mentat-check-inspectionerrors.sh |   0
 .../scripts}/mentat-check-noeventclass.sh     |   0
 .../scripts}/mentat-check-test.sh             |   0
 .../mentat-check-volatiledescription.sh       |   0
 .../scripts}/mentat-reports-order.py          |   0
 {scripts => conf/scripts}/sqldb-init.sh       |   0
 .../scripts}/sqldb-maintenance.sh             |   0
 {scripts => conf/scripts}/sqldb-migrate.sh    |   0
 {scripts => conf/scripts}/sqldb-optimize.sh   |   0
 doc/sphinx/_doclib/development.rst            |  24 ++-
 doc/sphinx/_doclib/installation.rst           |   6 +-
 etc/default/mentat                            |   6 +-
 etc/systemd/{ => system}/mentat.service       |   0
 etc/systemd/system/sendria.service            |  11 ++
 packaging/debian/rules                        |   3 +-
 45 files changed, 652 insertions(+), 16 deletions(-)
 create mode 100644 .vagrantenv/.bashrc
 create mode 100644 .vagrantenv/apt.list
 create mode 100644 .vagrantenv/finalize.sh
 create mode 100644 .vagrantenv/postfix.main.cf
 create mode 100644 .vagrantenv/provision.sh
 create mode 100644 Vagrantfile
 create mode 100644 conf/apache/site_mentat_vagrant.conf
 rename {migrations-events => conf/migrations-events}/README (100%)
 rename {migrations-events => conf/migrations-events}/alembic.ini (100%)
 rename {migrations-events => conf/migrations-events}/env.py (100%)
 rename {migrations-events => conf/migrations-events}/script.py.mako (100%)
 rename {migrations-events => conf/migrations-events}/versions/.gitplaceholder (100%)
 rename {migrations-events => conf/migrations-events}/versions/0f31c168a714_split_event_column_from_events_to_.py (100%)
 rename {migrations-events => conf/migrations-events}/versions/102ae7b9979f_remove_cesnet__prefix.py (100%)
 rename {migrations-events => conf/migrations-events}/versions/3fb6b209a5cd_added_support_for_aggregated_address_.py (100%)
 rename {migrations-events => conf/migrations-events}/versions/a9e28583cc3b_make_data_in_cesnet_eventclass_not_.py (100%)
 rename {scripts => conf/scripts}/as-dump.sh (100%)
 rename {scripts => conf/scripts}/depcheck.py (100%)
 rename {scripts => conf/scripts}/fetch-negistry.sh (100%)
 create mode 100755 conf/scripts/lib-mentat.sh
 create mode 100755 conf/scripts/lib.sh
 rename {scripts => conf/scripts}/lwchroot-init.sh (100%)
 rename {scripts => conf/scripts}/maintenance-mode.sh (100%)
 rename {scripts => conf/scripts}/mentat-check-alive.sh (100%)
 rename {scripts => conf/scripts}/mentat-check-inspectionerrors.sh (100%)
 rename {scripts => conf/scripts}/mentat-check-noeventclass.sh (100%)
 rename {scripts => conf/scripts}/mentat-check-test.sh (100%)
 rename {scripts => conf/scripts}/mentat-check-volatiledescription.sh (100%)
 rename {scripts => conf/scripts}/mentat-reports-order.py (100%)
 rename {scripts => conf/scripts}/sqldb-init.sh (100%)
 rename {scripts => conf/scripts}/sqldb-maintenance.sh (100%)
 rename {scripts => conf/scripts}/sqldb-migrate.sh (100%)
 rename {scripts => conf/scripts}/sqldb-optimize.sh (100%)
 rename etc/systemd/{ => system}/mentat.service (100%)
 create mode 100644 etc/systemd/system/sendria.service

diff --git a/.gitignore b/.gitignore
index bca4779da..5b94c50a4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
 !.gitignore
 .directory
+.vagrant
 .coverage
 *~
 *.aux
@@ -71,9 +72,6 @@ parsetab.py
 /doc/sphinx/_doclib/_inc_bin.cfg-daemon.rst
 /doc/sphinx/_doclib/_inc_bin.cfg-script.rst
 
-# Ignore local lightweight chroot.
-/chroot/
-
 # Ignore local .dotenv configuration file
 .env
 
@@ -83,3 +81,9 @@ parsetab.py
 *.substvars
 /packaging/debian/mentat-ng/
 /packaging/debian/files
+
+# Ignore custom stuff.
+/conf/install.pip
+/chroot/
+/data/
+/var/
diff --git a/.vagrantenv/.bashrc b/.vagrantenv/.bashrc
new file mode 100644
index 000000000..a26630509
--- /dev/null
+++ b/.vagrantenv/.bashrc
@@ -0,0 +1,122 @@
+# ~/.bashrc: executed by bash(1) for non-login shells.
+# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
+# for examples
+
+# If not running interactively, don't do anything
+case $- in
+    *i*) ;;
+      *) return;;
+esac
+
+# don't put duplicate lines or lines starting with space in the history.
+# See bash(1) for more options
+HISTCONTROL=ignoreboth
+
+# append to the history file, don't overwrite it
+shopt -s histappend
+
+# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
+HISTSIZE=1000
+HISTFILESIZE=2000
+
+# check the window size after each command and, if necessary,
+# update the values of LINES and COLUMNS.
+shopt -s checkwinsize
+
+# If set, the pattern "**" used in a pathname expansion context will
+# match all files and zero or more directories and subdirectories.
+#shopt -s globstar
+
+# make less more friendly for non-text input files, see lesspipe(1)
+[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
+
+# set variable identifying the chroot you work in (used in the prompt below)
+if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
+    debian_chroot=$(cat /etc/debian_chroot)
+fi
+
+# set a fancy prompt (non-color, unless we know we "want" color)
+case "$TERM" in
+    xterm-color|*-256color) color_prompt=yes;;
+esac
+
+# uncomment for a colored prompt, if the terminal has the capability; turned
+# off by default to not distract the user: the focus in a terminal window
+# should be on the output of commands, not on the prompt
+#force_color_prompt=yes
+
+if [ -n "$force_color_prompt" ]; then
+    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
+	# We have color support; assume it's compliant with Ecma-48
+	# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
+	# a case would tend to support setf rather than setaf.)
+	color_prompt=yes
+    else
+	color_prompt=
+    fi
+fi
+
+if [ "$color_prompt" = yes ]; then
+    export GIT_PS1_SHOWDIRTYSTATE=1
+    export GIT_PS1_SHOWSTASHSTATE=1
+    export GIT_PS1_SHOWUNTRACKEDFILES=1
+    export GIT_PS1_SHOWUPSTREAM="auto verbose"
+
+    if [[ ${EUID} == 0 ]] ; then
+       PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
+       #PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\h\[\033[01;34m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[01;33m\]$(__git_ps1 " [%s]")\[\033[00m\]\$ '
+    else
+       #PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w \$\[\033[00m\] '
+       PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[01;33m\]$(__git_ps1 " [%s]")\[\033[00m\]\$ '
+    fi
+else
+    PS1='${debian_chroot:+($debian_chroot)}\u@\h \w \$ '
+fi
+unset color_prompt force_color_prompt
+
+# If this is an xterm set the title to user@host:dir
+case "$TERM" in
+xterm*|rxvt*)
+    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
+    ;;
+*)
+    ;;
+esac
+
+# enable color support of ls and also add handy aliases
+if [ -x /usr/bin/dircolors ]; then
+    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
+    alias ls='ls --color=auto'
+    #alias dir='dir --color=auto'
+    #alias vdir='vdir --color=auto'
+
+    alias grep='grep --color=auto'
+    alias fgrep='fgrep --color=auto'
+    alias egrep='egrep --color=auto'
+fi
+
+# colored GCC warnings and errors
+#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
+
+# some more aliases
+alias ll='ls -alF'
+alias la='ls -A'
+alias l='ls -CF'
+alias cd..='cd ..'
+alias ..='cd ..'
+alias ...='cd ../..'
+alias ....='cd ../../..'
+alias cdm='cd /vagrant/'
+alias entervenv='. venv/bin/activate'
+alias mentatvenv='. /var/mentat/venv/bin/activate'
+
+# enable programmable completion features (you don't need to enable
+# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
+# sources /etc/bash.bashrc).
+if ! shopt -oq posix; then
+  if [ -f /usr/share/bash-completion/bash_completion ]; then
+    . /usr/share/bash-completion/bash_completion
+  elif [ -f /etc/bash_completion ]; then
+    . /etc/bash_completion
+  fi
+fi
diff --git a/.vagrantenv/apt.list b/.vagrantenv/apt.list
new file mode 100644
index 000000000..f027e0d4b
--- /dev/null
+++ b/.vagrantenv/apt.list
@@ -0,0 +1 @@
+vim
diff --git a/.vagrantenv/finalize.sh b/.vagrantenv/finalize.sh
new file mode 100644
index 000000000..ebbf3b4dc
--- /dev/null
+++ b/.vagrantenv/finalize.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+# Installing environment suitable for Mentat development
+#
+# Copyright (C) since 2011 CESNET, z.s.p.o
+# Use of this source is governed by the MIT license, see LICENSE file.
+#-------------------------------------------------------------------------------
+
+echo "==========> <BEGIN> finalize.sh"
+
+sudo -u mentat /var/mentat/venv/bin/python /vagrant/bin/mentat-dbmngr.py --command init
+sudo -u mentat bash -c "source /var/mentat/venv/bin/activate ; hawat-cli db stamp head"
+sudo -u mentat bash -c "source /var/mentat/venv/bin/activate ; /etc/mentat/scripts/sqldb-migrate.sh stamp head"
+
+sudo -u mentat /var/mentat/venv/bin/python /vagrant/bin/mentat-precache.py --allow-empty
+
+/etc/mentat/scripts/sqldb-optimize.sh
+
+sudo -u postgres psql -c "SELECT usename FROM pg_catalog.pg_user;" | grep root > /dev/null
+if [ $? -ne 0 ]; then
+    echo "Creating default PostgreSQL user 'root'"
+    sudo -u postgres psql -c "CREATE USER root SUPERUSER WITH PASSWORD 'root';"
+fi
+
+echo "==========> <DONE> finalize.sh"
diff --git a/.vagrantenv/postfix.main.cf b/.vagrantenv/postfix.main.cf
new file mode 100644
index 000000000..9f7d74680
--- /dev/null
+++ b/.vagrantenv/postfix.main.cf
@@ -0,0 +1,46 @@
+# See /usr/share/postfix/main.cf.dist for a commented, more complete version
+
+
+# Debian specific:  Specifying a file name will cause the first
+# line of that file to be used as the name.  The Debian default
+# is /etc/mailname.
+#myorigin = /etc/mailname
+
+smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
+biff = no
+
+# appending .domain is the MUA's job.
+append_dot_mydomain = no
+
+# Uncomment the next line to generate "delayed mail" warnings
+#delay_warning_time = 4h
+
+readme_directory = no
+
+# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
+# fresh installs.
+compatibility_level = 2
+
+
+
+# TLS parameters
+smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
+smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
+smtpd_use_tls=yes
+smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
+smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
+
+# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
+# information on enabling SSL in the smtp client.
+
+# http://www.postfix.org/STANDARD_CONFIGURATION_README.html
+smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
+myhostname = buster.lan
+alias_maps = hash:/etc/aliases
+alias_database = hash:/etc/aliases
+relayhost = 127.0.0.1:1025
+mydestination =
+mailbox_size_limit = 0
+recipient_delimiter = +
+inet_interfaces = loopback-only
+inet_protocols = all
diff --git a/.vagrantenv/provision.sh b/.vagrantenv/provision.sh
new file mode 100644
index 000000000..36982c361
--- /dev/null
+++ b/.vagrantenv/provision.sh
@@ -0,0 +1,153 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+# Installing environment suitable for Mentat development
+#
+# Copyright (C) since 2011 CESNET, z.s.p.o
+# Use of this source is governed by the MIT license, see LICENSE file.
+#-------------------------------------------------------------------------------
+
+echo "==========> <BEGIN> provision.sh"
+
+echo "==========> Linking default configurations"
+if [ ! -L /etc/default/mentat ] ; then
+  ln -s /vagrant/etc/default/mentat /etc/default/mentat
+fi
+if [ ! -L /etc/mentat ] ; then
+  ln -s /vagrant/conf /etc/mentat
+fi
+. /etc/default/mentat
+. /etc/mentat/scripts/lib.sh
+
+echo "==========> Configuring timezone and locales"
+echo "Europe/Prague" > /etc/timezone
+dpkg-reconfigure -f noninteractive tzdata && \
+  sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
+  sed -i -e 's/# cs_CZ.UTF-8 UTF-8/cs_CZ.UTF-8 UTF-8/' /etc/locale.gen && \
+  echo 'LANG="en_US.UTF-8"'>/etc/default/locale && \
+  dpkg-reconfigure --frontend=noninteractive locales && \
+  update-locale LANG=en_US.UTF-8
+
+echo "==========> Creating Mentat user"
+if ! getent passwd mentat > /dev/null 2>&1; then
+    useradd -m -s /bin/bash -U mentat --groups sudo
+    cp -pr /home/vagrant/.ssh /home/mentat/
+    chown -R mentat:mentat /home/mentat
+    echo "%mentat ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/mentat
+fi
+
+echo "==========> Linking additional configuration files"
+ensure_linked_file /vagrant/.vagrantenv/.bashrc /home/vagrant/.bashrc
+ensure_linked_file /vagrant/.vagrantenv/.bashrc /home/mentat/.bashrc
+
+echo "==========> Installing common dependencies"
+apt-get update -qq \
+  && DEBIAN_FRONTEND=noninteractive apt-get -yq dist-upgrade \
+  && DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
+    build-essential \
+    gnupg2 \
+    curl \
+    wget \
+    less \
+    git \
+    vim \
+    bash-completion \
+    sudo \
+    openssl \
+    ssl-cert \
+  && apt-get clean \
+  && rm -rf /tmp/* /var/tmp/*
+
+echo "==========> Installing third party package repository - PostgreSQL"
+if [ ! -f /etc/apt/sources.list.d/pgdg.list ] ; then
+  curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
+  echo 'deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list
+fi
+
+echo "==========> Installing third party package repository - NodeJS"
+if [ ! -f /etc/apt/sources.list.d/nodesource.list ] ; then
+  curl -sL https://deb.nodesource.com/setup_$NODE_MAJOR.x | bash -
+fi
+
+echo "==========> Installing third party package repository - Yarn"
+if [ ! -f /etc/apt/sources.list.d/yarn.list ] ; then
+  curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
+  echo 'deb http://dl.yarnpkg.com/debian/ stable main' > /etc/apt/sources.list.d/yarn.list
+fi
+
+echo "==========> Installing application dependencies"
+apt-get update -qq \
+  && DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
+    python3 \
+    python3-dev \
+    python3-setuptools \
+    python3-pip \
+    python3-venv \
+    postgresql-13 \
+    postgresql-13-ip4r \
+    postgresql-client-13 \
+    postgresql-server-dev-13 \
+    libpq-dev \
+    nodejs \
+    yarn=$YARN_VERSION-1 \
+    rrdtool \
+    librrd-dev \
+    libdb5.3 \
+    libdb5.3-dev \
+    postfix \
+    mailutils \
+    apache2 \
+    libapache2-mod-wsgi-py3 \
+  && apt-get clean \
+  && rm -rf /tmp/* /var/tmp/*
+
+echo "==========> Installing GeoIPupdate tool"
+if [ ! -f /usr/bin/geoipupdate ] && [ ! -e /usr/bin/geoipupdate ] ; then
+  wget -O /tmp/geoipupdate_4.6.0_linux_amd64.deb https://github.com/maxmind/geoipupdate/releases/download/v4.6.0/geoipupdate_4.6.0_linux_amd64.deb && \
+    dpkg -i /tmp/geoipupdate_4.6.0_linux_amd64.deb && \
+    rm -f /tmp/geoipupdate_4.6.0_linux_amd64.deb
+fi
+
+echo "==========> Installing Grunt task runner"
+if [ ! -f /usr/bin/grunt ] && [ ! -e /usr/bin/grunt ] ; then
+  npm install -g grunt-cli
+fi
+
+echo "==========> Installing application installation PIP file"
+if [ ! -f /etc/mentat/install.pip ] ; then
+  echo '--editable "/vagrant/"' > /etc/mentat/install.pip
+fi
+
+echo "==========> Configuring Apache to serve development server"
+if [ ! -L /etc/apache2/sites-enabled/site_mentat_vagrant.conf ] ; then
+  ensure_linked_file /vagrant/conf/apache/site_mentat_vagrant.conf /etc/apache2/sites-available/site_mentat_vagrant.conf
+  sed -i.bak s/APACHE_RUN_USER=www-data/APACHE_RUN_USER=mentat/g /etc/apache2/envvars
+  sed -i.bak s/APACHE_RUN_GROUP=www-data/APACHE_RUN_GROUP=mentat/g /etc/apache2/envvars
+  rm -f /etc/apache2/envvars.bak
+
+  a2enmod rewrite
+  a2enmod ssl
+  a2enmod wsgi
+  a2dissite 000-default.conf
+  a2dissite default-ssl.conf
+  a2ensite site_mentat_vagrant.conf
+
+  systemctl restart apache2.service
+fi
+
+echo "==========> Preparing Python development environment"
+if ! [ -d "${MENTAT_VENV}" ]; then
+    python3 -m venv "${MENTAT_VENV}"
+fi
+${MENTAT_VENV}/bin/pip install pip --upgrade
+${MENTAT_VENV}/bin/pip install -r /etc/mentat/requirements-dev.pip
+
+
+echo "==========> Configuring email services for development"
+ensure_linked_file /vagrant/.vagrantenv/postfix.main.cf /etc/postfix/main.cf
+systemctl restart postfix.service
+
+ensure_linked_file /vagrant/etc/systemd/system/sendria.service /etc/systemd/system/sendria.service
+systemctl daemon-reload
+systemctl start sendria.service
+
+echo "==========> <DONE> provision.sh"
diff --git a/Makefile b/Makefile
index a43e296dd..a40114d29 100644
--- a/Makefile
+++ b/Makefile
@@ -217,8 +217,12 @@ venv: FORCE
 #
 develop: deps install-whl-dev build-webui
 
+develop-docker: deps-docker translations-compile build-webui
+
 deps: deps-prerequisites deps-lwchroot deps-python deps-python-dev deps-editable deps-webui deps-geoip deps-negistry deps-postgresql translations-compile
 
+deps-docker: deps-prerequisites deps-dirs-docker deps-python deps-python-dev deps-editable deps-webui deps-geoip-docker deps-negistry-docker
+
 clean: clean-pycs clean-build-docs clean-build-python clean-build-debian
 
 docs: docs-sync docs-sphinx
@@ -276,7 +280,11 @@ deps-prerequisites: FORCE
 #
 deps-lwchroot: FORCE
 	@echo "\n$(GREEN)*** Creating local lightweight chroot subdirectory structure ***$(NC)\n"
-	@./scripts/lwchroot-init.sh
+	@./conf/scripts/lwchroot-init.sh
+
+deps-dirs-docker: FORCE
+	@echo "\n$(GREEN)*** Creating local lightweight chroot subdirectory structure ***$(NC)\n"
+	@./conf/scripts/devdirs-init.sh
 
 #
 # Install project`s Python dependencies using pip requirements file. The dependencies
@@ -357,12 +365,23 @@ deps-geoip: FORCE
 	@geoipupdate --verbose --database-directory $(shell realpath ./chroot/usr/share/GeoIP)
 	@echo ""
 
+deps-geoip-docker: FORCE
+	@echo "\n$(GREEN)*** Installing IP geolocation databases ***$(NC)\n"
+	@mkdir -p /usr/share/GeoIP
+	#@geoipupdate --verbose --database-directory /usr/share/GeoIP
+	@echo ""
+
 #
 # Fetch and install Negistry whois database.
 #
 deps-negistry: FORCE
 	@echo "\n$(GREEN)*** Installing Negistry whois database ***$(NC)\n"
-	@./scripts/fetch-negistry.sh --stub --target=$(shell realpath ./chroot/var/mentat/whois-negistry.json)
+	@./conf/scripts/fetch-negistry.sh --stub --target=$(shell realpath ./chroot/var/mentat/whois-negistry.json)
+	@echo ""
+
+deps-negistry-docker: FORCE
+	@echo "\n$(GREEN)*** Installing Negistry whois database ***$(NC)\n"
+	@./conf/scripts/fetch-negistry.sh --stub --target=/var/mentat/whois-negistry.json
 	@echo ""
 
 #
@@ -370,7 +389,7 @@ deps-negistry: FORCE
 #
 deps-postgresql: FORCE
 	@echo "\n$(GREEN)*** Installing and configuring PostgreSQL database ***$(NC)\n"
-	@./scripts/sqldb-init.sh
+	@./conf/scripts/sqldb-init.sh
 	@echo ""
 
 
@@ -389,7 +408,7 @@ run-mentat-dev:
 run-webui-dev:
 	@echo "\n$(GREEN)*** Running development web server with development configuration on $(DEV_SERVER):$(DEV_PORT) ***$(NC)\n"
 	#APP_ROOT_PATH=$(shell realpath ./chroot) hawat-cli run --host $(DEV_SERVER) --port $(DEV_PORT)
-	HAWAT_CONFIG_FILE=$(shell realpath ./hawat.local.conf) hawat-cli run --host $(DEV_SERVER) --port $(DEV_PORT)
+	HAWAT_CONFIG_FILE=$(shell realpath ./hawat.local.conf) hawat-cli run --host "0.0.0.0" --port $(DEV_PORT)
 
 run-mailserver-dev:
 	@echo "\n$(GREEN)*** Running development mail server on $(DEV_MAIL_SERVER):$(DEV_MAIL_PORT) ***$(NC)\n"
@@ -467,6 +486,22 @@ presentations: FORCE
 	done
 
 
+db-data-fetch: FORCE
+	@echo "\n$(GREEN)*** Fetching latest production database dump ***$(NC)\n"
+	@rm -rf ./data
+	@mkdir -p ./data
+	@scp mentat-alt:/var/mentat/production-dump/mentat_psqldb_latest.tar.gz ./data/
+	@cd ./data/ && tar -xzvf ./mentat_psqldb_latest.tar.gz
+	@rm -f ./data/mentat_psqldb_latest.tar.gz
+	@mv ./data/var/mentat/tmp/mentat_* ./data/mentat_psqldb_latest
+	@rm -rf ./data/var
+	@echo ""
+
+db-data-import: FORCE
+	@echo "\n$(GREEN)*** Importing latest production database dump ***$(NC)\n"
+	@sudo -u postgres pg_restore --verbose --format=d --dbname=mentat_main /vagrant/data/mentat_psqldb_daily_latest/main
+	@echo ""
+
 #-------------------------------------------------------------------------------
 
 
diff --git a/Vagrantfile b/Vagrantfile
new file mode 100644
index 000000000..953ee016f
--- /dev/null
+++ b/Vagrantfile
@@ -0,0 +1,54 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+Vagrant.configure('2') do |config|
+  config.vm.hostname = 'mentat-devel.local'
+  config.vm.box = 'debian/contrib-buster64'
+
+  # Flask development server
+  config.vm.network 'forwarded_port', guest: 5000, host: 5000
+  # Apache web server
+  config.vm.network 'forwarded_port', guest: 443, host: 4443
+  # Sendria
+  config.vm.network 'forwarded_port', guest: 1080, host: 1080
+
+  # Create a private network, which allows host-only access to the machine
+  # using a specific IP.
+  # config.vm.network "private_network", ip: "192.168.33.10"
+
+  # Create a public network, which generally matched to bridged network.
+  # Bridged networks make the machine appear as another physical device on
+  # your network.
+  # config.vm.network "public_network"
+
+  # Share an additional folder to the guest VM. The first argument is
+  # the path on the host to the actual folder. The second argument is
+  # the path on the guest to mount the folder. And the optional third
+  # argument is a set of non-required options.
+  # config.vm.synced_folder "../data", "/vagrant_data"
+
+  # Provider-specific configuration so you can fine-tune various
+  # backing providers for Vagrant. These expose provider-specific options.
+  # Example for VirtualBox:
+  #
+  # config.vm.provider "virtualbox" do |vb|
+  #   # Display the VirtualBox GUI when booting the machine
+  #   vb.gui = true
+  #
+  #   # Customize the amount of memory on the VM:
+  #   vb.memory = "1024"
+  # end
+  #
+
+  config.vm.provision 'shell', inline: <<-SHELL
+    bash /vagrant/.vagrantenv/provision.sh
+    bash /vagrant/packaging/debian/postinst
+    bash /vagrant/.vagrantenv/finalize.sh
+  SHELL
+  #config.vm.provision :ansible do |ansible|
+  #  ansible.playbook = '.vagrantenv/provision.yml'
+  #end
+
+  VAGRANT_COMMAND = ARGV[0]
+  config.ssh.username = 'mentat' if VAGRANT_COMMAND == 'ssh'
+end
diff --git a/conf/apache/site_mentat_vagrant.conf b/conf/apache/site_mentat_vagrant.conf
new file mode 100644
index 000000000..6e37cb3c9
--- /dev/null
+++ b/conf/apache/site_mentat_vagrant.conf
@@ -0,0 +1,112 @@
+#-------------------------------------------------------------------------------
+# Example APACHE web server configuration file for HAWAT - development version
+#
+# This is an example configuration for authentication based on SSO service
+# Shibboleth. Please adjust the configuration file according to your needs.
+# In most cases customization of following directives should be enough to
+# get it working properly and quickly:
+#
+#   * ServerAdmin
+#   * ServerName
+#   * SSLCertificateFile
+#   * SSLCertificateKeyFile
+#   * SSLCertificateChainFile
+#
+# This file is part of Mentat system (https://mentat.cesnet.cz/).
+#
+# Copyright (C) since 2011 CESNET, z.s.p.o (http://www.ces.net/)
+# Use of this source is governed by the MIT license, see LICENSE file.
+#-------------------------------------------------------------------------------
+
+WSGIPythonHome /var/mentat/venv
+
+<IfModule mod_ssl.c>
+    <VirtualHost _default_:443>
+        ServerAdmin webmaster@mentat.organization.org
+        ServerName mentat.organization.org
+
+        <IfModule mod_headers.c>
+                # Enforce HTTPS protocol at all times.
+                Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
+                # Deny access to content via HTML iframe.
+                Header always set X-Frame-Options DENY
+        </IfModule>
+
+        DocumentRoot /var/www
+
+        WSGIDaemonProcess hawat user=mentat group=mentat threads=5 python-home=/var/mentat/venv
+        WSGIScriptAlias /mentat /vagrant/bin/mentat-hawat-dev.wsgi
+
+        <Location />
+            Require all granted
+        </Location>
+
+        <Directory /vagrant/lib/hawat>
+            WSGIProcessGroup hawat
+            WSGIApplicationGroup %{GLOBAL}
+            Require all granted
+        </Directory>
+
+        <Location /mentat/auth_env/login>
+            AuthType Basic
+            AuthName "Mentat system login"
+            AuthUserFile /etc/mentat/apache/htpasswd.example
+            Require valid-user
+        </Location>
+        <Location /mentat/auth_env/register>
+            AuthType Basic
+            AuthName "Mentat system registration"
+            AuthUserFile /etc/mentat/apache/htpasswd.example
+            Require valid-user
+        </Location>
+
+        RewriteEngine on
+        # Rewrite the path when accessed without a trailing slash.
+        RewriteRule ^/mentat$ /mentat/ [R]
+        # Rewrite webserver root to mentat application.
+        RewriteRule ^/$ /mentat/ [R]
+
+
+        ErrorLog ${APACHE_LOG_DIR}/error.log
+
+        # Possible values: debug, info, notice, warn, error, crit, alert, emerg.
+        LogLevel warn
+
+        CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
+
+        SSLEngine on
+        #SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
+
+        # Using default self-signed server certificates
+        SSLCertificateFile  /etc/ssl/certs/ssl-cert-snakeoil.pem
+        SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
+
+        # Using custom server certificates
+        #SSLCertificateFile      /etc/ssl/servercert/cert.pem
+        #SSLCertificateKeyFile   /etc/ssl/servercert/key.pem
+        #SSLCertificateChainFile /etc/ssl/servercert/chain.pem
+
+        # Enforce only strong SSL protocols. Generator as of August 2016. This
+        # tool is available at https://mozilla.github.io/server-side-tls/ssl-config-generator/
+        # Resource: https://httpd.apache.org/docs/trunk/ssl/ssl_howto.html#onlystrong
+        SSLProtocol         all -SSLv3 -TLSv1 -TLSv1.1
+        SSLCipherSuite      ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
+        SSLHonorCipherOrder on
+        SSLCompression      off
+        SSLSessionTickets   off
+
+        <FilesMatch "\.(cgi|shtml|phtml|php)$">
+                SSLOptions +StdEnvVars
+        </FilesMatch>
+        <Directory /usr/lib/cgi-bin>
+                SSLOptions +StdEnvVars
+        </Directory>
+
+        BrowserMatch "MSIE [2-6]" \
+                nokeepalive ssl-unclean-shutdown \
+                downgrade-1.0 force-response-1.0
+        # MSIE 7 and newer should be able to use keepalive
+        BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
+
+    </VirtualHost>
+</IfModule>
diff --git a/conf/core/database.json.conf b/conf/core/database.json.conf
index 17a739c01..585cac300 100644
--- a/conf/core/database.json.conf
+++ b/conf/core/database.json.conf
@@ -8,7 +8,9 @@
         # SQL storage connection settings.
         #
         "sqlstorage": {
-            "url": "postgresql://mentat:mentat@localhost/mentat_main",
+            # Connect to the PostgreSQL running on outer host machine.
+            # "url": "postgresql://mentat:mentat@10.0.2.2:5432/mentat_main",
+            "url": "postgresql://mentat:mentat@localhost:5432/mentat_main",
             "echo": false
         },
 
@@ -19,6 +21,8 @@
             "dbname":   "mentat_events",
             "user":     "mentat",
             "password": "mentat",
+            # Connect to the PostgreSQL running on outer host machine.
+            # "host":     "10.0.2.2",
             "host":     "localhost",
             "port":     5432
         }
diff --git a/migrations-events/README b/conf/migrations-events/README
similarity index 100%
rename from migrations-events/README
rename to conf/migrations-events/README
diff --git a/migrations-events/alembic.ini b/conf/migrations-events/alembic.ini
similarity index 100%
rename from migrations-events/alembic.ini
rename to conf/migrations-events/alembic.ini
diff --git a/migrations-events/env.py b/conf/migrations-events/env.py
similarity index 100%
rename from migrations-events/env.py
rename to conf/migrations-events/env.py
diff --git a/migrations-events/script.py.mako b/conf/migrations-events/script.py.mako
similarity index 100%
rename from migrations-events/script.py.mako
rename to conf/migrations-events/script.py.mako
diff --git a/migrations-events/versions/.gitplaceholder b/conf/migrations-events/versions/.gitplaceholder
similarity index 100%
rename from migrations-events/versions/.gitplaceholder
rename to conf/migrations-events/versions/.gitplaceholder
diff --git a/migrations-events/versions/0f31c168a714_split_event_column_from_events_to_.py b/conf/migrations-events/versions/0f31c168a714_split_event_column_from_events_to_.py
similarity index 100%
rename from migrations-events/versions/0f31c168a714_split_event_column_from_events_to_.py
rename to conf/migrations-events/versions/0f31c168a714_split_event_column_from_events_to_.py
diff --git a/migrations-events/versions/102ae7b9979f_remove_cesnet__prefix.py b/conf/migrations-events/versions/102ae7b9979f_remove_cesnet__prefix.py
similarity index 100%
rename from migrations-events/versions/102ae7b9979f_remove_cesnet__prefix.py
rename to conf/migrations-events/versions/102ae7b9979f_remove_cesnet__prefix.py
diff --git a/migrations-events/versions/3fb6b209a5cd_added_support_for_aggregated_address_.py b/conf/migrations-events/versions/3fb6b209a5cd_added_support_for_aggregated_address_.py
similarity index 100%
rename from migrations-events/versions/3fb6b209a5cd_added_support_for_aggregated_address_.py
rename to conf/migrations-events/versions/3fb6b209a5cd_added_support_for_aggregated_address_.py
diff --git a/migrations-events/versions/a9e28583cc3b_make_data_in_cesnet_eventclass_not_.py b/conf/migrations-events/versions/a9e28583cc3b_make_data_in_cesnet_eventclass_not_.py
similarity index 100%
rename from migrations-events/versions/a9e28583cc3b_make_data_in_cesnet_eventclass_not_.py
rename to conf/migrations-events/versions/a9e28583cc3b_make_data_in_cesnet_eventclass_not_.py
diff --git a/conf/requirements-dev.pip b/conf/requirements-dev.pip
index 8d7ea7ff6..b24db6d29 100644
--- a/conf/requirements-dev.pip
+++ b/conf/requirements-dev.pip
@@ -4,5 +4,6 @@ nose==1.3.7
 coverage==5.0.4
 pyflakes==2.1.1
 pylint==2.4.4
+sendria==2.2.2
 sphinx==2.4.4
 sphinx-rtd-theme==0.4.3
diff --git a/conf/requirements-latest-dev.pip b/conf/requirements-latest-dev.pip
index 45d395277..a285ea718 100644
--- a/conf/requirements-latest-dev.pip
+++ b/conf/requirements-latest-dev.pip
@@ -4,5 +4,6 @@ nose
 coverage
 pyflakes
 pylint
+sendria
 sphinx
 sphinx-rtd-theme
diff --git a/conf/requirements.pip b/conf/requirements.pip
index fad643400..38278ffc9 100644
--- a/conf/requirements.pip
+++ b/conf/requirements.pip
@@ -6,7 +6,7 @@ babel==2.8.0
 wtforms==2.2.1
 sqlalchemy==1.3.15
 alembic==1.4.2
-jinja2==2.10.3
+jinja2==3.0.1
 blinker==1.4
 bsddb3==6.2.7
 flask==1.1.1
diff --git a/scripts/as-dump.sh b/conf/scripts/as-dump.sh
similarity index 100%
rename from scripts/as-dump.sh
rename to conf/scripts/as-dump.sh
diff --git a/scripts/depcheck.py b/conf/scripts/depcheck.py
similarity index 100%
rename from scripts/depcheck.py
rename to conf/scripts/depcheck.py
diff --git a/scripts/fetch-negistry.sh b/conf/scripts/fetch-negistry.sh
similarity index 100%
rename from scripts/fetch-negistry.sh
rename to conf/scripts/fetch-negistry.sh
diff --git a/conf/scripts/lib-mentat.sh b/conf/scripts/lib-mentat.sh
new file mode 100755
index 000000000..e65a5c8d5
--- /dev/null
+++ b/conf/scripts/lib-mentat.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+# This file is part of Mentat system (https://mentat.cesnet.cz/).
+#
+# Copyright (C) since 2011 CESNET, z.s.p.o (http://www.ces.net/)
+# Use of this source is governed by the MIT license, see LICENSE file.
+#-------------------------------------------------------------------------------
+
+COLCODE_BLACK=$(tput setaf 0)
+COLCODE_RED=$(tput setaf 1)
+COLCODE_GREEN=$(tput setaf 2)
+COLCODE_ORANGE=$(tput setaf 3)
+COLCODE_BLUE=$(tput setaf 4)
+COLCODE_PURPLE=$(tput setaf 5)
+COLCODE_CYAN=$(tput setaf 6)
+COLCODE_WHITE=$(tput setaf 7)
+COLCODE_NC=$(tput sgr0)
+
+COLCODE_B_BLACK=$(tput setab 0)
+COLCODE_B_RED=$(tput setab 1)
+COLCODE_B_GREEN=$(tput setab 2)
+COLCODE_B_ORANGE=$(tput setab 3)
+COLCODE_B_BLUE=$(tput setab 4)
+COLCODE_B_PURPLE=$(tput setab 5)
+COLCODE_B_CYAN=$(tput setab 6)
+COLCODE_B_WHITE=$(tput setab 7)
+
+COLCODE_BOLD=$(tput bold)
+COLCODE_FAINT=$(tput dim)
diff --git a/conf/scripts/lib.sh b/conf/scripts/lib.sh
new file mode 100755
index 000000000..429b47f11
--- /dev/null
+++ b/conf/scripts/lib.sh
@@ -0,0 +1,13 @@
+#-------------------------------------------------------------------------------
+# Bash function library for Mentat system.
+#
+# Copyright (C) since 2011 CESNET, z.s.p.o
+# Use of this source is governed by the MIT license, see LICENSE file.
+#-------------------------------------------------------------------------------
+
+function ensure_linked_file {
+	if [ -f $2 ] ; then
+		rm -f $2
+	fi
+	ln -s $1 $2
+}
diff --git a/scripts/lwchroot-init.sh b/conf/scripts/lwchroot-init.sh
similarity index 100%
rename from scripts/lwchroot-init.sh
rename to conf/scripts/lwchroot-init.sh
diff --git a/scripts/maintenance-mode.sh b/conf/scripts/maintenance-mode.sh
similarity index 100%
rename from scripts/maintenance-mode.sh
rename to conf/scripts/maintenance-mode.sh
diff --git a/scripts/mentat-check-alive.sh b/conf/scripts/mentat-check-alive.sh
similarity index 100%
rename from scripts/mentat-check-alive.sh
rename to conf/scripts/mentat-check-alive.sh
diff --git a/scripts/mentat-check-inspectionerrors.sh b/conf/scripts/mentat-check-inspectionerrors.sh
similarity index 100%
rename from scripts/mentat-check-inspectionerrors.sh
rename to conf/scripts/mentat-check-inspectionerrors.sh
diff --git a/scripts/mentat-check-noeventclass.sh b/conf/scripts/mentat-check-noeventclass.sh
similarity index 100%
rename from scripts/mentat-check-noeventclass.sh
rename to conf/scripts/mentat-check-noeventclass.sh
diff --git a/scripts/mentat-check-test.sh b/conf/scripts/mentat-check-test.sh
similarity index 100%
rename from scripts/mentat-check-test.sh
rename to conf/scripts/mentat-check-test.sh
diff --git a/scripts/mentat-check-volatiledescription.sh b/conf/scripts/mentat-check-volatiledescription.sh
similarity index 100%
rename from scripts/mentat-check-volatiledescription.sh
rename to conf/scripts/mentat-check-volatiledescription.sh
diff --git a/scripts/mentat-reports-order.py b/conf/scripts/mentat-reports-order.py
similarity index 100%
rename from scripts/mentat-reports-order.py
rename to conf/scripts/mentat-reports-order.py
diff --git a/scripts/sqldb-init.sh b/conf/scripts/sqldb-init.sh
similarity index 100%
rename from scripts/sqldb-init.sh
rename to conf/scripts/sqldb-init.sh
diff --git a/scripts/sqldb-maintenance.sh b/conf/scripts/sqldb-maintenance.sh
similarity index 100%
rename from scripts/sqldb-maintenance.sh
rename to conf/scripts/sqldb-maintenance.sh
diff --git a/scripts/sqldb-migrate.sh b/conf/scripts/sqldb-migrate.sh
similarity index 100%
rename from scripts/sqldb-migrate.sh
rename to conf/scripts/sqldb-migrate.sh
diff --git a/scripts/sqldb-optimize.sh b/conf/scripts/sqldb-optimize.sh
similarity index 100%
rename from scripts/sqldb-optimize.sh
rename to conf/scripts/sqldb-optimize.sh
diff --git a/doc/sphinx/_doclib/development.rst b/doc/sphinx/_doclib/development.rst
index e40883f73..4bb529809 100644
--- a/doc/sphinx/_doclib/development.rst
+++ b/doc/sphinx/_doclib/development.rst
@@ -114,7 +114,7 @@ procedures:
 
 * Debian dependencies
 
-  * Debian dependencies must be specified in the ``deploy/mentat/ctrl/control.tmpl``
+  * Debian dependencies must be specified in the ``packaging/debian/control``
     file. Please study the `documentation <https://www.debian.org/doc/debian-policy/ch-controlfields.html#binary-package-control-files-debian-control>`__ to correctly
     use Debian dependency system.
 
@@ -612,6 +612,28 @@ target:
 Generated packages will be placed into ``./deploy/mentat/`` subdirectory.
 
 
+Development with Vagrant
+--------------------------------------------------------------------------------
+
+.. note::
+	This is still experimental and work in progress.
+
+.. code-block:: shell
+
+	curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
+	sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
+	sudo apt update && sudo apt install vagrant
+
+	make db-data-fetch
+	vagrant up
+	vagrant ssh
+	cd /vagrant/
+	make db-data-import
+
+At this point you are all set to develop Mentat locally without cluttering your personal
+workstation.
+
+
 Examples
 --------------------------------------------------------------------------------
 
diff --git a/doc/sphinx/_doclib/installation.rst b/doc/sphinx/_doclib/installation.rst
index 1784ef197..c35a803c8 100644
--- a/doc/sphinx/_doclib/installation.rst
+++ b/doc/sphinx/_doclib/installation.rst
@@ -220,7 +220,7 @@ Install - pip
 
 .. _section-installation-prerequisites-postgresql:
 
-Install - PostgreSQL 12
+Install - PostgreSQL 13
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 * `Documentation <https://www.postgresql.org/docs/>`__
@@ -229,10 +229,10 @@ Install - PostgreSQL 12
 .. code-block:: shell
 
     # Run these commands as root:
-    $ echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list
+    $ echo "deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list
     $ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
     $ apt update
-    $ apt install postgresql-12 postgresql-12-ip4r postgresql-client-12 postgresql-server-dev-12 libpq-dev pgadmin4
+    $ apt install postgresql-13 postgresql-13-ip4r postgresql-client-13 postgresql-server-dev-13 libpq-dev pgadmin4
 
 
 .. _section-installation-prerequisites-yarn:
diff --git a/etc/default/mentat b/etc/default/mentat
index cbd000b42..74b07941d 100644
--- a/etc/default/mentat
+++ b/etc/default/mentat
@@ -6,6 +6,10 @@
 # Use of this source is governed by the MIT license, see LICENSE file.
 #-------------------------------------------------------------------------------
 
+PG_MAJOR=13
+NODE_MAJOR="12"
+YARN_VERSION="1.22.5"
+
 # Master switch for Debian system scripts.
 MENTAT_IS_ENABLED=yes
 #MENTAT_IS_ENABLED=no
@@ -21,7 +25,7 @@ MENTAT_GROUP=mentat
 # aware, that this variable should be an array.
 MENTAT_CHECKS_MAIL_TO=(root)
 
-# Emails for Mentat system 
+# Emails for Mentat system
 MENTAT_ADMINS_MAIL_TO=(root)
 
 # Base URL for Mentat`s web interface Hawat (with trailing slash).
diff --git a/etc/systemd/mentat.service b/etc/systemd/system/mentat.service
similarity index 100%
rename from etc/systemd/mentat.service
rename to etc/systemd/system/mentat.service
diff --git a/etc/systemd/system/sendria.service b/etc/systemd/system/sendria.service
new file mode 100644
index 000000000..2b076fc3b
--- /dev/null
+++ b/etc/systemd/system/sendria.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Sendria - Mailtrap service for development
+After=network.target
+
+[Service]
+Type=simple
+ExecStart=/var/mentat/venv/bin/python -m sendria --db /tmp/mails.sqlite --http-ip 0.0.0.0
+Restart=always
+
+[Install]
+WantedBy=multi-user.target
diff --git a/packaging/debian/rules b/packaging/debian/rules
index 053f4c943..22bb3bfc4 100755
--- a/packaging/debian/rules
+++ b/packaging/debian/rules
@@ -19,12 +19,11 @@ binary:
 	mkdir -p debian/mentat-ng/usr/share/bash-completion/completions
 
 	cp -r ../conf/* debian/mentat-ng/etc/mentat/
-	cp -r ../scripts debian/mentat-ng/etc/mentat/
 	cp -r ../migrations-events debian/mentat-ng/etc/mentat/
 	cp -r ../etc/bash_completion.d/* debian/mentat-ng/usr/share/bash-completion/completions
 	cp -r ../etc/default debian/mentat-ng/etc/
 	cp -r ../etc/init.d debian/mentat-ng/etc/
-	cp -r ../etc/systemd debian/mentat-ng/etc/
+	cp ../etc/systemd/system/mentat.service debian/mentat-ng/etc/systemd/system
 
 	if [ -L 'debian/mentat-ng/etc/mentat/migrations-events/.env' ]; then rm -f 'debian/mentat-ng/etc/mentat/migrations-events/.env'; fi
 
-- 
GitLab