Synapse

Published 01-01-0001 00:00:00

Installing Synapse on Gentoo

Installing packages

~ # emerge -av dev-python/pip dev-python/virtualenv dev-python/virtualenvwrapper 

Creating a user with a home directory

~ # useradd -m -g users -G wheel,audio -s /bin/bash kronoz

Creating an isolated environment

~ $ echo "export WORKON_HOME=~/.virtualenvs" >> ~/.bashrc
~ $ echo "source /usr/bin/virtualenvwrapper.sh" >> ~/.bashrc
~ $ source ~/.bashrc
~ $ mkvirtualenv -p python2.7 synapse

Installing python packages

~ $ pip install psycopg2 pip-review

Updating an isolated environment

~ $ pip install --upgrade pip
~ $ pip-review --local --interactive

Installing the Synapse Server

~ $ pip install https://github.com/matrix-org/synapse/tarball/master

Creating a configuration file

~ $ python -m synapse.app.homeserver --server-name kronoz.guru --config-path homeserver.yaml --generate-config --report-stats=yes

Configuring the configuration file

~ $ nano ~/.virtualenvs/synapse/homeserver.yaml
TODO

Creating a PostgreSQL Database

~ # su postgres
~ $ psql
~ $ CREATE USER matrix WITH PASSWORD 'synapse';
~ $ CREATE DATABASE synapse;
~ $ GRANT ALL PRIVILEGES ON DATABASE synapse TO matrix;

Configuring the configuration file for the database

~ $ nano homeserver.yaml
database:
    name: psycopg2
    args:
        user: matrix
        password: synapse
        database: synapse
        host: x.x.x.x
        cp_min: 5
        cp_max: 10

Adding a Synapse Server to Startup

Variant via local.d

Installing Console Screen Multiplexer

~ # emerge -av app-misc/screen
~ # nano /etc/local.d/synapse.start
#!/bin/bash

su -c "screen -d -m -S synapse ~/.virtualenvs/synapse/bin/synctl start ~/.virtualenvs/synapse/homeserver.yaml" kronoz
~ # chmod +x /etc/local.d/synapse.start

Starting the Synapse Server

~ $ synctl start

Create user

~ $ register_new_matrix_user -c homeserver.yaml https://localhost:8448

Configuring the federation on the name server

_matrix._tcp.kronoz.guru. 1800 IN SRV 0 0 8448 hostname.

Configuring Proxy on the Caddy Web Server

~ $ nano /etc/caddy/vhosts/sites-available/matrix.kronoz.guru
  matrix.kronoz.guru {
     proxy / http://192.168.1.60:8008 { transparent }
     tls root@kronoz.guru
     log /home/kronoz/web/data/logs/caddy-access_matrix.kronoz.guru.log {
         rotate_size 100 # Rotate after 100 MB
         rotate_age  14  # Keep log files for 14 days
         rotate_keep 10  # Keep at most 10 log files
     }

     errors /home/kronoz/web/data/logs/caddy-error_matrix.kronoz.guru.log {
         rotate_size 50 # Rotate after 50 MB
         rotate_age  30 # Keep rotated files for 30 days
         rotate_keep 5  # Keep at most 5 log files
     }
  }
~ # service caddy restart

Update Synapse Server

~ $ pip install --upgrade --process-dependency-links https://github.com/matrix-org/synapse/tarball/master