Installing Heisenbridge (Matrix IRC Bridge) on Gentoo Linux

Heisenbridge is a bridge connection a Matrix server to the IRC network. This article describes the installation of Heisenbridge atop a Synapse server on Gentoo linux. The setup procedure relies in part on the installation procedure described here for Synapse, so if you install Heisenbridge independently of Synapse on Gentoo, some additional steps and changes to the procedure below are necessary:

  • creating the directories
  • adding the matrix user
  • installing the Python virtual environment
  • the openrc script depends on service synapse

Installation

The installation of Heisenbridge is pretty simple. As we use the same Python virtual environment as for the installation of Synapse, the installation boils down to:

cd /opt/synapse
su matrix
source env/bin/activate
pip install git+https://github.com/hifi/heisenbridge

To generate a sample configuration file, run:

python -m heisenbridge -c heisenbridge.yaml --generate

Configuration

In most cases, no changes to the sample configuration file should be necessary.

To make Synapse talk to Heisenbridge, the heisenbridge.yaml configuration file needs to be added to Synapse's appservice list (in homeserver.yaml):

app_service_config_files: [ /opt/synapse/heisenbridge.yaml ]

Synapse needs to be restarted to make this change effective.

openrc Scripts

As with Synapse, no openrc scripts exist for Heisenbridge. This is the script I use for Heisenbridge:

#!/sbin/openrc-run

depend() {
        need net synapse
}

cd /opt/synapse
source /opt/synapse/env/bin/activate

start() {
        ebegin "Starting heisenbridge"
        start-stop-daemon --start --user matrix --background --make-pidfile --pidfile heisenbridge.pid --exec python -- -m heisenbridge -c heisenbridge.yaml &>heisenbridge.log
        eend $? 
}

stop() {
        ebegin "Stopping heisenbridge"
        start-stop-daemon --stop --user matrix --exec python -- -m heisenbridge -c heisenbridge.yaml &>heisenbridge.log
        eend $? 
}