1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mautrix_signal_ynh.git synced 2024-09-03 19:46:07 +02:00

Merge pull request #91 from YunoHost-Apps/testing

Testing
This commit is contained in:
Alexandre Aubin 2024-04-07 19:04:54 +02:00 committed by GitHub
commit 76c28b29e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 492 additions and 1048 deletions

View file

@ -1,107 +0,0 @@
#!/bin/bash
#=================================================
# PACKAGE UPDATING HELPER
#=================================================
# This script is meant to be run by GitHub Actions
# The YunoHost-Apps organisation offers a template Action to run this script periodically
# Since each app is different, maintainers can adapt its contents so as to perform
# automatic actions when a new upstream release is detected.
#=================================================
# FETCHING LATEST RELEASE AND ITS ASSETS
#=================================================
# Fetching information
current_version=$(cat manifest.json | jq -j '.version|split("~")[0]')
repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]')
# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions)
version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1)
assets="https://github.com/$repo/archive/refs/tags/$version.tar.gz"
# Later down the script, we assume the version has only digits and dots
# Sometimes the release name starts with a "v", so let's filter it out.
# You may need more tweaks here if the upstream repository has different naming conventions.
if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then
version=${version:1}
fi
# Setting up the environment variables
echo "Current version: $current_version"
echo "Latest release from upstream: $version"
echo "VERSION=$version" >> $GITHUB_ENV
echo "REPO=$repo" >> $GITHUB_ENV
# For the time being, let's assume the script will fail
echo "PROCEED=false" >> $GITHUB_ENV
# Proceed only if the retrieved version is greater than the current one
if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then
echo "::warning ::No new version available"
exit 0
# Proceed only if a PR for this new version does not already exist
elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then
echo "::warning ::A branch already exists for this update"
exit 0
fi
#=================================================
# UPDATE SOURCE FILES
#=================================================
# Let's download source tarball
asset_url=$assets
echo "Handling asset at $asset_url"
src="app"
# Create the temporary directory
tempdir="$(mktemp -d)"
# Download sources and calculate checksum
filename=${asset_url##*/}
curl --silent -4 -L $asset_url -o "$tempdir/$filename"
checksum=$(sha256sum "$tempdir/$filename" | head -c 64)
# Delete temporary directory
rm -rf $tempdir
# Get extension
if [[ $filename == *.tar.gz ]]; then
extension=tar.gz
else
extension=${filename##*.}
fi
# Rewrite source file
cat <<EOT > conf/$src.src
SOURCE_URL=$asset_url
SOURCE_SUM=$checksum
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=$extension
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=mautrix-signal.tar.gz
SOURCE_EXTRACT=false
EOT
echo "... conf/$src.src updated"
#=================================================
# SPECIFIC UPDATE STEPS
#=================================================
# Any action on the app's source code can be done.
# The GitHub Action workflow takes care of committing all changes after this script ends.
#=================================================
# GENERIC FINALIZATION
#=================================================
# Replace new version in manifest
echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json
# No need to update the README, yunohost-bot takes care of it
# The Action will proceed only if the PROCEED environment variable is set to true
echo "PROCEED=true" >> $GITHUB_ENV
exit 0

View file

@ -1,49 +0,0 @@
# This workflow allows GitHub Actions to automagically update your app whenever a new upstream release is detected.
# You need to enable Actions in your repository settings, and fetch this Action from the YunoHost-Apps organization.
# This file should be enough by itself, but feel free to tune it to your needs.
# It calls updater.sh, which is where you should put the app-specific update steps.
name: Check for new upstream releases
on:
# Allow to manually trigger the workflow
workflow_dispatch:
# Run it every day at 6:00 UTC
schedule:
- cron: '0 6 * * *'
jobs:
updater:
runs-on: ubuntu-latest
steps:
- name: Fetch the source code
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run the updater script
id: run_updater
run: |
# Setting up Git user
git config --global user.name 'yunohost-bot'
git config --global user.email 'yunohost-bot@users.noreply.github.com'
# Run the updater script
/bin/bash .github/workflows/updater.sh
- name: Commit changes
id: commit
if: ${{ env.PROCEED == 'true' }}
run: |
git commit -am "Upgrade to v$VERSION"
- name: Create Pull Request
id: cpr
if: ${{ env.PROCEED == 'true' }}
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update to version ${{ env.VERSION }}
committer: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
author: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
signoff: false
base: testing
branch: ci-auto-update-v${{ env.VERSION }}
delete-branch: true
title: 'Upgrade to version ${{ env.VERSION }}'
body: |
Upgrade to v${{ env.VERSION }}
draft: false

View file

@ -1,6 +1,6 @@
# All available README files by language # All available README files by language
- [Read the README in English](README.md) - [Read the README in English](README.md)
- [Irakurri README euskaraz](README_eu.md)
- [Lire le README en français](README_fr.md) - [Lire le README en français](README_fr.md)
- [Le o README en galego](README_gl.md) - [Le o README en galego](README_gl.md)
- [Leggi il “README” in italiano](README_it.md)

View file

@ -9,94 +9,20 @@ It shall NOT be edited by hand.
[![Install Matrix Signal bridge with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mautrix_signal) [![Install Matrix Signal bridge with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mautrix_signal)
*[Read this README is other languages.](./ALL_README.md)* *[Read this README in other languages.](./ALL_README.md)*
> *This package allows you to install Matrix Signal bridge quickly and simply on a YunoHost server.* > *This package allows you to install Matrix Signal bridge quickly and simply on a YunoHost server.*
> *If you don't have YunoHost, please consult [the guide](https://yunohost.org/install) to learn how to install it.* > *If you don't have YunoHost, please consult [the guide](https://yunohost.org/install) to learn how to install it.*
## Overview ## Overview
A puppeting bridge between Matrix and Signal packaged as a YunoHost service. Messages, notifications (and sometimes media) are bridged between a Signal user and a Matrix user. Currently the Matrix user can NOT invite other Matrix user in a bridged Signal room, so only someone with a Signal account can participate to Signal group conversations. The ["Mautrix-Signal"](https://docs.mau.fi/bridges/python/signal/index.html) bridge consists in a Synapse App Service and relies on postgresql (mysql also possible). Therefore, [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh) should be installed beforehand. A puppeting bridge between Matrix and Signal packaged as a YunoHost service. Messages, notifications (and sometimes media) are bridged between a Signal user and a Matrix user.
Currently the Matrix user can NOT invite other Matrix user in a bridged Signal room, so only someone with a Signal account can participate to Signal group conversations.
The ["Mautrix-Signal"](https://docs.mau.fi/bridges/python/signal/index.html) bridge consists in a Synapse App Service and relies on postgresql (mysql also possible). Therefore, [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh) should be installed beforehand.
**Shipped version:** 0.4.3~ynh1 **Shipped version:** 0.4.3~ynh1
## Disclaimers / important information
## List of known public services
* Ask on one of the following rooms: #mautrix_yunohost:matrix.fdn.fr or #signal:maunium.net
## Bridging usage
** Note that several Signal and Matrix users can be bridged, each Signal account has its own bot administration room. If they are in a same Signal group, only one matrix room will be created. **
### Bridge a Signal user and a Matrix user
* First your Matrix user or Synapse Server has to be authorized in the Configuration of the bridge (see below)
* Then, invite the bot (default @signalbot:yoursynapse.domain) in this new Mautrix-Signal bot administration room.
* If the Bot does bot accept, see the [troubleshooting page](https://docs.mau.fi/bridges/general/troubleshooting.html)
* Send ``!sg help`` to the bot in the created room to know how to control the bot.
See also [upstream wiki Authentication page](https://docs.mau.fi/bridges/python/signal/authentication.html)
#### Linking the Bridge as a secondary device
* Type ``!sg link``
* Open Signal App of your primary device
* Open Settings => Linked Devices => + => Capture the QR code with the camera
* By defaults, only conversations with very recent messages will be bridged
* Accept invitations to the bridged chat rooms
#### Registering the Bridge as a primary device
* Type ``!sg register <phone>``, where ``<phone>`` is your phone number in the international format with no space, e.g. ``!sg register +33612345678``
* Answer in the bot room with the verification code that you reveived in SMS.
* Set a profile name with ``!sg set-profile-name <name>``
### Double puppeting
* Log in with ``login-matrix <access token>``
* After logging in, the default Matrix puppet of your Signal account should leave rooms and your account should join all rooms the puppet was in automatically.
### Relaybot: Bridge a group for several Matrix and several Signal users to chat together
* Create a room on the signal side
* Your bridged users will be invited on the Matrix side once they are invited on the Signal side
* You can invite more people over on the Matrix side
* Have one of the bridged users (who has the right permission) type `!sg set-relay` on the Matrix side. Their signal account will relay messages from other Matrix users
It is not yet possible to bridge to an existing signal room, or create a new signal room from the Matrix side.
## Configuration of the bridge
The bridge is [roughly configured at installation](https://github.com/YunoHost-Apps/mautrix_signal_ynh/blob/master/conf/config.yaml), e.g. allowed admin and user of the bot. Finer configuration can be done by modifying the
following configuration file with SSH:
```/opt/yunohost/mautrix_signal/config.yaml```
and then restarting the mautrix_signal service.
## Documentation
* Official "Mautrix-Signal" documentation: https://docs.mau.fi/bridges/python/signal/index.html
* Matrix room (Matrix Bridges in Yunohost): #mautrix_yunohost:matrix.fdn.fr
* Matrix room (upstream app): #signal:maunium.net
In case you need to upload your logs somewhere, be aware that they contain your contacts' and your phone numbers. Strip them out with
``| sed -r 's/[0-9]{10,}/📞/g' ``
* "Mautrix-Signal" bridge is based on the [signal daemon](https://gitlab.com/signald/signald) project.
* YunoHost documentation: If more specific documentation is needed, feel free to contribute.
## YunoHost specific features
#### Multi-user support
* Bot users are not related to Yunohost users. Any Matrix account or Synapse server autorized in the configuration of the bridge can invite/use the bot.
* The Signal bot is a local Matrix-Synapse user, but accessible through federation (synapse public or private).
* Several Signal and Matrix users can be bridged with one bridge, each user has its own bot administration room.
* If several bot users are in a same Signal group, only one Matrix room will be created by the bridge.
* See https://github.com/YunoHost-Apps/synapse_ynh#multi-users-support
#### Multi-instance support
* Multi-instance installation should work. Several bridge instances could be installed for one Matrix-Synapse instance so that one Matrix user can bridge several Signal accounts.
* Several bridge instances could be installed for each Matrix-Synapse instance to benefit from it. But one bridge can be used by users from several Matrix-Synapse instances.
## Limitations
* It looks like media are not bridged.
* Signal chats are not grouped in a Matrix community (as opposed to the Mautrix-WhatsApp or Mautrix-Facebook bridges)
## Documentation and resources ## Documentation and resources
- Official user documentation: <https://docs.mau.fi/bridges/python/signal/index.html> - Official user documentation: <https://docs.mau.fi/bridges/python/signal/index.html>

45
README_eu.md Normal file
View file

@ -0,0 +1,45 @@
<!--
Ohart ongi: README hau automatikoki sortu da <https://github.com/YunoHost/apps/tree/master/tools/readme_generator>ri esker
EZ editatu eskuz.
-->
# Matrix Signal bridge YunoHost-erako
[![Integrazio maila](https://dash.yunohost.org/integration/mautrix_signal.svg)](https://dash.yunohost.org/appci/app/mautrix_signal) ![Funtzionamendu egoera](https://ci-apps.yunohost.org/ci/badges/mautrix_signal.status.svg) ![Mantentze egoera](https://ci-apps.yunohost.org/ci/badges/mautrix_signal.maintain.svg)
[![Instalatu Matrix Signal bridge YunoHost-ekin](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mautrix_signal)
*[Irakurri README hau beste hizkuntzatan.](./ALL_README.md)*
> *Pakete honek Matrix Signal bridge YunoHost zerbitzari batean azkar eta zailtasunik gabe instalatzea ahalbidetzen dizu.*
> *YunoHost ez baduzu, kontsultatu [gida](https://yunohost.org/install) nola instalatu ikasteko.*
## Aurreikuspena
A puppeting bridge between Matrix and Signal packaged as a YunoHost service. Messages, notifications (and sometimes media) are bridged between a Signal user and a Matrix user.
Currently the Matrix user can NOT invite other Matrix user in a bridged Signal room, so only someone with a Signal account can participate to Signal group conversations.
The ["Mautrix-Signal"](https://docs.mau.fi/bridges/python/signal/index.html) bridge consists in a Synapse App Service and relies on postgresql (mysql also possible). Therefore, [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh) should be installed beforehand.
**Paketatutako bertsioa:** 0.4.3~ynh1
## Dokumentazioa eta baliabideak
- Erabiltzaileen dokumentazio ofiziala: <https://docs.mau.fi/bridges/python/signal/index.html>
- Jatorrizko aplikazioaren kode-gordailua: <https://github.com/mautrix/signal>
- YunoHost Denda: <https://apps.yunohost.org/app/mautrix_signal>
- Eman errore baten berri: <https://github.com/YunoHost-Apps/mautrix_signal_ynh/issues>
## Garatzaileentzako informazioa
Bidali `pull request`a [`testing` abarrera](https://github.com/YunoHost-Apps/mautrix_signal_ynh/tree/testing).
`testing` abarra probatzeko, ondorengoa egin:
```bash
sudo yunohost app install https://github.com/YunoHost-Apps/mautrix_signal_ynh/tree/testing --debug
edo
sudo yunohost app upgrade mautrix_signal -u https://github.com/YunoHost-Apps/mautrix_signal_ynh/tree/testing --debug
```
**Informazio gehiago aplikazioaren paketatzeari buruz:** <https://yunohost.org/packaging_apps>

View file

@ -16,79 +16,14 @@ Il NE doit PAS être modifié à la main.
## Vue densemble ## Vue densemble
Une passerelle entre Matrix et Signal empaquetée comme un service YunoHost. Les messages, médias et notifications sont relayées entre un compte Signal et un compte Matrix. Une passerelle entre Matrix et Signal empaquetée comme un service YunoHost. Les messages, médias et notifications sont relayées entre un compte Signal et un compte Matrix.
La passerelle ["Mautrix-Signal"](https://docs.mau.fi/bridges/python/signal/index.html) consiste en un Service d'Application Matrix-Synapse et repose sur une base-de-données postgresql. C'est pourquoi [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh) doit être préalablemnet installé. La passerelle ["Mautrix-Signal"](https://docs.mau.fi/bridges/python/signal/index.html) consiste en un Service d'Application Matrix-Synapse et repose sur une base-de-données postgresql. C'est pourquoi [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh) doit être préalablemnet installé.
** Attention : sauvegardez et restaurez toujours les deux applications Yunohost matrix-synapse et mautrix_signal en même temps!** **Attention : sauvegardez et restaurez toujours les deux applications Yunohost matrix-synapse et mautrix_signal en même temps!**
**Version incluse:** 0.4.3~ynh1 **Version incluse:** 0.4.3~ynh1
## Avertissements / informations importantes
## Liste de passerelles publiques
* Demandez sur un des salons suivants: #mautrix_yunohost:matrix.fdn.fr or #signal:maunium.net
## Usages de la passerelle
** Notez que plusieurs comptes Signal et Matrix peuvent être relayés, chaque compte Signal connecté a son propre Salon d'Administration. Si plusieurs utilisateur.ice.s du Robot sont dans un même groupe Signal, seul un Salon Matrix sera créé par la passerelle. **
### Relayer TOUTES les conversations entre UN compte Signal et UN compte Matrix
* Prérequis : votre compte Matrix ou le serveur sur lequel il est hébergé doit être autorisé dans la configuration de la passerelle (voir ci-dessous)
* Invitez le Robot (par défaut @signalbot:synapse.votredomaine) à une nouvelle conversation.
* Ce nouveau salon d'administration du Robot Mautrix-Signal est appelé "Administration Room".
* Envoyez ``help`` au Robot dans le "Administration Room" pour une liste des commandes d'administration de la passerelle.
Voir aussi [upstream wiki Authentication page](https://docs.mau.fi/bridges/python/signal/authentication.html)
#### Relier la passerelle comme un appareil secondaire
* Tapez ``!sg link``
* Ouvrez l'application Signal de votre appareil principal
* Ouvrez Paramètres => Appareils reliés => + => filmer le QR
* Par défaut, seules les conversations avec des messages très récents seront mises-en-miroir
* Acceptez les invitations aux salons
#### Enregistrer la passerelle comme appareil principal
* Tapez ``!sg register <phone>``, où ``<phone>`` est votre numéro de téléphone au format international sans espace, p.ex. ``!sg register +33612345678``
* Répondez dans le salon d'administration avec le code de vérification reçu par SMS.
* Définissez une nom de profil ``!sg set-profile-name <name>``
### Robot-Relai "Relaybot": Relayer les conversations de TOUS les comptes Matrix et TOUS les comptes Signal présents dans UN groupe/salon
* Pas implémenté pour l'instant
## Configuration de la passerelle
La passerelle est [configurée avec les paramètres standards adaptés pour votre YunoHost et l'instance Matrix-Synapse sélectionnée](https://github.com/YunoHost-Apps/mautrix_signal_ynh/blob/master/conf/config.yaml). Vous pouvez par exemple ajouter des administrateur.ice.s et utilisateur.ice.s du Robot autorisés en modifiant le fichier de configuration par liaison SSH:
``` sudo nano /opt/yunohost/mautrix_signal/config.yaml```
puis en redémarrant le service:
``` sudo yunohost service restart mautrix_signal```
## Documentation
* Documentation officielle "Mautrix-Signal": https://docs.mau.fi/bridges/python/signal/index.html
* Salon Matrix sur les Passerelles dans Yunohost): #mautrix_yunohost:matrix.fdn.fr
* Salon Matrix (application principale): #signal:maunium.net
Si vous devez téléverser vos fichiers log quelque-part, soyez avertis qu'ils contiennent des informations sur vos contacts et vos numéros de téléphone. Effacez-les avec
``| sed -r 's/[0-9]{10,}/📞/g' ``
* La passerelle "Mautrix-Signal" repose sur l'implémentation du [daemon signald](https://gitlab.com/signald/signald) .
* Documentation YunoHost: Si une documentation spécifique est nécessaire, n'hésitez pas à contribuer.
## Caractéristiques spécifiques YunoHost
#### Support multi-comptes
* Les utilisateur.ice.s du Robot ne sont pas liés aux comptes Yunohost. N'importe quel compte Matrix ou serveur Synapse autorisés dans la configuration de la passerelle peut inviter/utiliser le Robot.
* Le robot Signal est un utilisateur Matrix-Synapse local, mais accessible via la fédération (Synapse public ou privé).
* Plusieurs comptes Signal et Matrix peuvent être liés avec une seule passerelle, chaque compte a son propre salon d'administration.
* Si plusieurs utilisateur.ice.s du Robot sont dans un même groupe Signal, seul un Salon Matrix sera créé par la passerelle. Autrement dit, la passerelle construit un seul miroir du réseau de discussion existant sur Signal (utilisateurs et salons).
* Voir https://github.com/YunoHost-Apps/synapse_ynh#multi-users-support
#### Support multi-instance
* L'installation multi-instance devrait fonctionner. Plusieurs instances de passerelles pourraient être installées pour une instance de Matrix-Synapse. Cela permet à un compte matrix de se relier à plusieurs comptes Signal.
* Plusieurs instances de passerelles pourraient être installées pour que chaque instance de Matrix-Synapse puisse en bénéficier. Mais une passerelle peut être utilisée par les comptes de plusieurs instances Matrix-Synapse.
## Limitations
* Les appels Audio/Video ne sont pas relayés. Seule une notification apparait.
## Documentations et ressources ## Documentations et ressources
- Documentation officielle utilisateur: <https://docs.mau.fi/bridges/python/signal/index.html> - Documentation officielle utilisateur: <https://docs.mau.fi/bridges/python/signal/index.html>

View file

@ -16,87 +16,13 @@ NON debe editarse manualmente.
## Vista xeral ## Vista xeral
A puppeting bridge between Matrix and Signal packaged as a YunoHost service. Messages, notifications (and sometimes media) are bridged between a Signal user and a Matrix user. Currently the Matrix user can NOT invite other Matrix user in a bridged Signal room, so only someone with a Signal account can participate to Signal group conversations. The ["Mautrix-Signal"](https://docs.mau.fi/bridges/python/signal/index.html) bridge consists in a Synapse App Service and relies on postgresql (mysql also possible). Therefore, [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh) should be installed beforehand. A puppeting bridge between Matrix and Signal packaged as a YunoHost service. Messages, notifications (and sometimes media) are bridged between a Signal user and a Matrix user.
Currently the Matrix user can NOT invite other Matrix user in a bridged Signal room, so only someone with a Signal account can participate to Signal group conversations.
The ["Mautrix-Signal"](https://docs.mau.fi/bridges/python/signal/index.html) bridge consists in a Synapse App Service and relies on postgresql (mysql also possible). Therefore, [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh) should be installed beforehand.
**Versión proporcionada:** 0.4.3~ynh1 **Versión proporcionada:** 0.4.3~ynh1
## Avisos / información importante
## List of known public services
* Ask on one of the following rooms: #mautrix_yunohost:matrix.fdn.fr or #signal:maunium.net
## Bridging usage
** Note that several Signal and Matrix users can be bridged, each Signal account has its own bot administration room. If they are in a same Signal group, only one matrix room will be created. **
### Bridge a Signal user and a Matrix user
* First your Matrix user or Synapse Server has to be authorized in the Configuration of the bridge (see below)
* Then, invite the bot (default @signalbot:yoursynapse.domain) in this new Mautrix-Signal bot administration room.
* If the Bot does bot accept, see the [troubleshooting page](https://docs.mau.fi/bridges/general/troubleshooting.html)
* Send ``!sg help`` to the bot in the created room to know how to control the bot.
See also [upstream wiki Authentication page](https://docs.mau.fi/bridges/python/signal/authentication.html)
#### Linking the Bridge as a secondary device
* Type ``!sg link``
* Open Signal App of your primary device
* Open Settings => Linked Devices => + => Capture the QR code with the camera
* By defaults, only conversations with very recent messages will be bridged
* Accept invitations to the bridged chat rooms
#### Registering the Bridge as a primary device
* Type ``!sg register <phone>``, where ``<phone>`` is your phone number in the international format with no space, e.g. ``!sg register +33612345678``
* Answer in the bot room with the verification code that you reveived in SMS.
* Set a profile name with ``!sg set-profile-name <name>``
### Double puppeting
* Log in with ``login-matrix <access token>``
* After logging in, the default Matrix puppet of your Signal account should leave rooms and your account should join all rooms the puppet was in automatically.
### Relaybot: Bridge a group for several Matrix and several Signal users to chat together
* Create a room on the signal side
* Your bridged users will be invited on the Matrix side once they are invited on the Signal side
* You can invite more people over on the Matrix side
* Have one of the bridged users (who has the right permission) type `!sg set-relay` on the Matrix side. Their signal account will relay messages from other Matrix users
It is not yet possible to bridge to an existing signal room, or create a new signal room from the Matrix side.
## Configuration of the bridge
The bridge is [roughly configured at installation](https://github.com/YunoHost-Apps/mautrix_signal_ynh/blob/master/conf/config.yaml), e.g. allowed admin and user of the bot. Finer configuration can be done by modifying the
following configuration file with SSH:
```/opt/yunohost/mautrix_signal/config.yaml```
and then restarting the mautrix_signal service.
## Documentation
* Official "Mautrix-Signal" documentation: https://docs.mau.fi/bridges/python/signal/index.html
* Matrix room (Matrix Bridges in Yunohost): #mautrix_yunohost:matrix.fdn.fr
* Matrix room (upstream app): #signal:maunium.net
In case you need to upload your logs somewhere, be aware that they contain your contacts' and your phone numbers. Strip them out with
``| sed -r 's/[0-9]{10,}/📞/g' ``
* "Mautrix-Signal" bridge is based on the [signal daemon](https://gitlab.com/signald/signald) project.
* YunoHost documentation: If more specific documentation is needed, feel free to contribute.
## YunoHost specific features
#### Multi-user support
* Bot users are not related to Yunohost users. Any Matrix account or Synapse server autorized in the configuration of the bridge can invite/use the bot.
* The Signal bot is a local Matrix-Synapse user, but accessible through federation (synapse public or private).
* Several Signal and Matrix users can be bridged with one bridge, each user has its own bot administration room.
* If several bot users are in a same Signal group, only one Matrix room will be created by the bridge.
* See https://github.com/YunoHost-Apps/synapse_ynh#multi-users-support
#### Multi-instance support
* Multi-instance installation should work. Several bridge instances could be installed for one Matrix-Synapse instance so that one Matrix user can bridge several Signal accounts.
* Several bridge instances could be installed for each Matrix-Synapse instance to benefit from it. But one bridge can be used by users from several Matrix-Synapse instances.
## Limitations
* It looks like media are not bridged.
* Signal chats are not grouped in a Matrix community (as opposed to the Mautrix-WhatsApp or Mautrix-Facebook bridges)
## Documentación e recursos ## Documentación e recursos
- Documentación oficial para usuarias: <https://docs.mau.fi/bridges/python/signal/index.html> - Documentación oficial para usuarias: <https://docs.mau.fi/bridges/python/signal/index.html>

View file

@ -1,30 +0,0 @@
;; Test complet
# auto_remove=1
; pre-install
sudo yunohost tools update apps
sudo yunohost app install https://github.com/YunoHost-Apps/synapse_ynh/ -a "domain=$domain&server_name=$server_name&is_free_registration=$is_free_registration&jitsi_server=$jitsi_server" --force
; Manifest
port="8449" (PORT)
synapsenumber="1"
botname="signalbot"
encryption=0
botadmin="@johndoe:synapsedomain.tld" (USER)
botusers="*:synapsedomain.tld"
; Checks
pkg_linter=1
setup_sub_dir=0
setup_root=0
setup_nourl=1
setup_private=0
setup_public=0
upgrade=1
# upgrade=1 from_commit=fc1ba62e6529bb529a413d5895398baa5f2029d7
# 0.2.3~ynh1
upgrade=1 from_commit=40c16d3c8898196c6e1a43e8f0af70c052dd41f6
backup_restore=1
multi_instance=1
port_already_use=1
change_url=0
actions=0
config_panel=0
;;; Upgrade options

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/mautrix/signal/archive/refs/tags/v0.4.3.tar.gz
SOURCE_SUM=e75636e845d4b9d84070efec510b7358b93a4fb0d6ffe4300dbdb9260725ba53
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=mautrix-signal.tar.gz
SOURCE_EXTRACT=false

View file

@ -2,15 +2,14 @@
homeserver: homeserver:
# The address that this appservice can use to connect to the homeserver. # The address that this appservice can use to connect to the homeserver.
address: https://__DOMAIN__ address: https://__DOMAIN__
# The domain of the homeserver (for MXIDs, etc). # The domain of the homeserver (also known as server_name, used for MXIDs, etc).
domain: __SERVER_NAME__ domain: __SERVER_NAME__
# Whether or not to verify the SSL certificate of the homeserver. # Whether or not to verify the SSL certificate of the homeserver.
# Only applies if address starts with https:// # Only applies if address starts with https://
verify_ssl: true verify_ssl: true
# Whether or not the homeserver supports asmux-specific endpoints, # What software is the homeserver running?
# such as /_matrix/client/unstable/net.maunium.asmux/dms for atomically # Standard Matrix homeservers like Synapse, Dendrite and Conduit should just use "standard" here.
# updating m.direct. software: standard
asmux: false
# Number of retries for all HTTP requests if the homeserver isn't reachable. # Number of retries for all HTTP requests if the homeserver isn't reachable.
http_retry_count: 4 http_retry_count: 4
# The URL to push real-time bridge status to. # The URL to push real-time bridge status to.
@ -21,7 +20,10 @@ homeserver:
message_send_checkpoint_endpoint: null message_send_checkpoint_endpoint: null
# Maximum number of simultaneous HTTP connections to the homeserver. # Maximum number of simultaneous HTTP connections to the homeserver.
connection_limit: 100 connection_limit: 100
# Whether asynchronous uploads via MSC2246 should be enabled for media.
# Requires a media repo that supports MSC2246.
async_media: false
# Application service host/registration related details # Application service host/registration related details
# Changing these values requires regeneration of the registration. # Changing these values requires regeneration of the registration.
appservice: appservice:
@ -39,7 +41,6 @@ appservice:
max_body_size: 1 max_body_size: 1
# The full URI to the database. SQLite and Postgres are supported. # The full URI to the database. SQLite and Postgres are supported.
# However, SQLite support is extremely experimental and should not be used.
# Format examples: # Format examples:
# SQLite: sqlite:///filename.db # SQLite: sqlite:///filename.db
# Postgres: postgres://username:password@hostname/dbname # Postgres: postgres://username:password@hostname/dbname
@ -48,6 +49,7 @@ appservice:
# https://magicstack.github.io/asyncpg/current/api/index.html#asyncpg.pool.create_pool # https://magicstack.github.io/asyncpg/current/api/index.html#asyncpg.pool.create_pool
# https://docs.python.org/3/library/sqlite3.html#sqlite3.connect # https://docs.python.org/3/library/sqlite3.html#sqlite3.connect
# For sqlite, min_size is used as the connection thread pool size and max_size is ignored. # For sqlite, min_size is used as the connection thread pool size and max_size is ignored.
# Additionally, SQLite supports init_commands as an array of SQL queries to run on connect (e.g. to set PRAGMAs).
database_opts: database_opts:
min_size: 5 min_size: 5
max_size: 10 max_size: 10
@ -108,11 +110,11 @@ signal:
# time of the messages will be determined by the first users to read the message, rather # time of the messages will be determined by the first users to read the message, rather
# than individually. If the bridge has a single user, this can be turned on safely. # than individually. If the bridge has a single user, this can be turned on safely.
enable_disappearing_messages_in_groups: false enable_disappearing_messages_in_groups: false
# Bridge config # Bridge config
bridge: bridge:
# Localpart template of MXIDs for Signal users. # Localpart template of MXIDs for Signal users.
# {userid} is replaced with an identifier for the Signal user. # {userid} is replaced with the UUID of the Signal user.
username_template: "sg_{userid}" username_template: "sg_{userid}"
# Displayname template for Signal users. # Displayname template for Signal users.
# {displayname} is replaced with the displayname of the Signal user, which is the first # {displayname} is replaced with the displayname of the Signal user, which is the first
@ -134,6 +136,9 @@ bridge:
autocreate_group_portal: true autocreate_group_portal: true
# Whether or not to create portals for all contacts on login/connect. # Whether or not to create portals for all contacts on login/connect.
autocreate_contact_portal: false autocreate_contact_portal: false
# Whether or not to make portals of Signal groups in which joining via invite link does
# not need to be approved by an administrator publicly joinable on Matrix.
public_portals: false
# Whether or not to use /sync to get read receipts and typing notifications # Whether or not to use /sync to get read receipts and typing notifications
# when double puppeting is enabled # when double puppeting is enabled
sync_with_custom_puppets: true sync_with_custom_puppets: true
@ -141,12 +146,12 @@ bridge:
# Note that updating the m.direct event is not atomic (except with mautrix-asmux) # Note that updating the m.direct event is not atomic (except with mautrix-asmux)
# and is therefore prone to race conditions. # and is therefore prone to race conditions.
sync_direct_chat_list: false sync_direct_chat_list: false
# Servers to always allow double puppeting from, even if double_puppet_allow_discovery is false.
double_puppet_server_map:
example.com: https://example.com
# Allow using double puppeting from any server with a valid client .well-known file. # Allow using double puppeting from any server with a valid client .well-known file.
double_puppet_allow_discovery: false double_puppet_allow_discovery: false
# Shared secrets for https://github.com/devture/matrix-synapse-shared-secret-auth # Servers to allow double puppeting from, even if double_puppet_allow_discovery is false.
double_puppet_server_map:
example.com: https://example.com
# Shared secret for https://github.com/devture/matrix-synapse-shared-secret-auth
# #
# If set, custom puppets will be enabled automatically for local users # If set, custom puppets will be enabled automatically for local users
# instead of users having to find an access token and run `login-matrix` # instead of users having to find an access token and run `login-matrix`
@ -154,46 +159,104 @@ bridge:
# If using this for other servers than the bridge's server, # If using this for other servers than the bridge's server,
# you must also set the URL in the double_puppet_server_map. # you must also set the URL in the double_puppet_server_map.
login_shared_secret_map: login_shared_secret_map:
example.com: foobar example.com: foo
# Whether or not created rooms should have federation enabled. # Whether or not created rooms should have federation enabled.
# If false, created portal rooms will never be federated. # If false, created portal rooms will never be federated.
federate_rooms: true federate_rooms: true
# End-to-bridge encryption support options. You must install the e2be optional dependency for # End-to-bridge encryption support options.
# this to work. See https://docs.mau.fi/bridges/general/end-to-bridge-encryption.html #
# See https://docs.mau.fi/bridges/general/end-to-bridge-encryption.html for more info.
encryption: encryption:
# Allow encryption, work in group chat rooms with e2ee enabled # Allow encryption, work in group chat rooms with e2ee enabled
allow: __ENCRYPTION__ allow: __ENCRYPTION__
# Default to encryption, force-enable encryption in all portals the bridge creates # Default to encryption, force-enable encryption in all portals the bridge creates
# This will cause the bridge bot to be in private chats for the encryption to work properly. # This will cause the bridge bot to be in private chats for the encryption to work properly.
default: false default: false
# Options for automatic key sharing. # Whether to use MSC2409/MSC3202 instead of /sync long polling for receiving encryption-related data.
key_sharing: appservice: false
# Enable key sharing? If enabled, key requests for rooms where users are in will be fulfilled. # Require encryption, drop any unencrypted messages.
# You must use a client that supports requesting keys from other users to use this feature. require: false
allow: false # Enable key sharing? If enabled, key requests for rooms where users are in will be fulfilled.
# Require the requesting device to have a valid cross-signing signature? # You must use a client that supports requesting keys from other users to use this feature.
# This doesn't require that the bridge has verified the device, only that the user has verified it. allow_key_sharing: false
# Not yet implemented. # Options for deleting megolm sessions from the bridge.
require_cross_signing: false delete_keys:
# Require devices to be verified by the bridge? # Beeper-specific: delete outbound sessions when hungryserv confirms
# Verification by the bridge is not yet implemented. # that the user has uploaded the key to key backup.
require_verification: true delete_outbound_on_ack: false
# Whether or not to explicitly set the avatar and room name for private # Don't store outbound sessions in the inbound table.
# chat portal rooms. This will be implicitly enabled if encryption.default is true. dont_store_outbound: false
private_chat_portal_meta: false # Ratchet megolm sessions forward after decrypting messages.
ratchet_on_decrypt: false
# Delete fully used keys (index >= max_messages) after decrypting messages.
delete_fully_used_on_decrypt: false
# Delete previous megolm sessions from same device when receiving a new one.
delete_prev_on_new_session: false
# Delete megolm sessions received from a device when the device is deleted.
delete_on_device_delete: false
# Periodically delete megolm sessions when 2x max_age has passed since receiving the session.
periodically_delete_expired: false
# What level of device verification should be required from users?
#
# Valid levels:
# unverified - Send keys to all device in the room.
# cross-signed-untrusted - Require valid cross-signing, but trust all cross-signing keys.
# cross-signed-tofu - Require valid cross-signing, trust cross-signing keys on first use (and reject changes).
# cross-signed-verified - Require valid cross-signing, plus a valid user signature from the bridge bot.
# Note that creating user signatures from the bridge bot is not currently possible.
# verified - Require manual per-device verification
# (currently only possible by modifying the `trust` column in the `crypto_device` database table).
verification_levels:
# Minimum level for which the bridge should send keys to when bridging messages from Telegram to Matrix.
receive: unverified
# Minimum level that the bridge should accept for incoming Matrix messages.
send: unverified
# Minimum level that the bridge should require for accepting key requests.
share: cross-signed-tofu
# Options for Megolm room key rotation. These options allow you to
# configure the m.room.encryption event content. See:
# https://spec.matrix.org/v1.3/client-server-api/#mroomencryption for
# more information about that event.
rotation:
# Enable custom Megolm room key rotation settings. Note that these
# settings will only apply to rooms created after this option is
# set.
enable_custom: false
# The maximum number of milliseconds a session should be used
# before changing it. The Matrix spec recommends 604800000 (a week)
# as the default.
milliseconds: 604800000
# The maximum number of messages that should be sent with a given a
# session before changing it. The Matrix spec recommends 100 as the
# default.
messages: 100
# Whether to explicitly set the avatar and room name for private chat portal rooms.
# If set to `default`, this will be enabled in encrypted rooms and disabled in unencrypted rooms.
# If set to `always`, all DM rooms will have explicit names and avatars set.
# If set to `never`, DM rooms will never have names and avatars set.
private_chat_portal_meta: default
# Whether or not the bridge should send a read receipt from the bridge bot when a message has # Whether or not the bridge should send a read receipt from the bridge bot when a message has
# been sent to Signal. This let's you check manually whether the bridge is receiving your # been sent to Signal. This let's you check manually whether the bridge is receiving your
# messages. # messages.
# Note that this is not related to Signal delivery receipts. # Note that this is not related to Signal delivery receipts.
delivery_receipts: false delivery_receipts: false
# Whether or not delivery errors should be reported as messages in the Matrix room. (not yet implemented) # Whether or not delivery errors should be reported as messages in the Matrix room.
delivery_error_reports: false delivery_error_reports: true
# Whether the bridge should send the message status as a custom com.beeper.message_send_status event.
message_status_events: false
# Set this to true to tell the bridge to re-send m.bridge events to all rooms on the next run. # Set this to true to tell the bridge to re-send m.bridge events to all rooms on the next run.
# This field will automatically be changed back to false after it, # This field will automatically be changed back to false after it,
# except if the config file is not writable. # except if the config file is not writable.
resend_bridge_info: false resend_bridge_info: false
# Interval at which to resync contacts (in seconds). # Interval at which to resync contacts (in seconds).
periodic_sync: 0 periodic_sync: 0
# Should leaving the room on Matrix make the user leave on Signal?
bridge_matrix_leave: true
# Should the bridge auto-create a group chat on Signal when a ghost is invited to a room?
# Requires the user to have sufficient power level and double puppeting enabled.
create_group_on_invite: true
hacky_contact_name_mixup_detection: false
# Provisioning API part of the web server for automated portal creation and fetching information. # Provisioning API part of the web server for automated portal creation and fetching information.
# Used by things like mautrix-manager (https://github.com/tulir/mautrix-manager). # Used by things like mautrix-manager (https://github.com/tulir/mautrix-manager).
@ -205,6 +268,13 @@ bridge:
# The shared secret to authorize users of the API. # The shared secret to authorize users of the API.
# Set to "generate" to generate and save a new token. # Set to "generate" to generate and save a new token.
shared_secret: generate shared_secret: generate
# Segment API key to enable analytics tracking for web server
# endpoints. Set to null to disable.
# Currently the only events are login start, QR code scan, and login
# success/failure.
segment_key: null
# Optional user_id to use when sending Segment events. If null, defaults to using mxID.
segment_user_id: null
# The prefix for commands. Only required in non-management rooms. # The prefix for commands. Only required in non-management rooms.
command_prefix: "!sg" command_prefix: "!sg"
@ -235,7 +305,7 @@ bridge:
# mxid - Specific user # mxid - Specific user
permissions: permissions:
"*": "relay" "*": "relay"
"__BOTUSERS__": "user" __IF_BOTUSERS__"__BOTUSERS__": "user"
"__BOTADMIN__": "admin" "__BOTADMIN__": "admin"
relay: relay:
@ -258,6 +328,17 @@ bridge:
m.audio: '$sender_displayname sent an audio file' m.audio: '$sender_displayname sent an audio file'
m.video: '$sender_displayname sent a video' m.video: '$sender_displayname sent a video'
m.location: '$sender_displayname sent a location' m.location: '$sender_displayname sent a location'
# Specify a dedicated relay account. Must be a regular matrix account logged into this bridge
# and double puppeting working to auto-accept invites. When this user is invited to a room
# it will automatically be set as the relay user. May be overridden with `set-relay` or `unset-relay`
# relaybot: '@relaybot:example.com'
# Whether or not invites from non-logged-in users should be relayed
invite: true
# Format for generating URLs from location messages for sending to Signal
# Google Maps: 'https://www.google.com/maps/place/{lat},{long}'
# OpenStreetMap: 'https://www.openstreetmap.org/?mlat={lat}&mlon={long}'
location_format: 'https://www.google.com/maps/place/{lat},{long}'
# Python logging configuration. # Python logging configuration.
# #

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://gitlab.com/signald/signald/-/archive/0.17.0/signald-0.17.0.tar.gz
SOURCE_SUM=225e36637daccf5f01138b7e29e3b2195bced7b13a290d163e34fe1f5d4a5d2a
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=signald.tar.gz
SOURCE_EXTRACT=true

View file

@ -6,8 +6,8 @@ After=matrix-synapse.service
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
ExecStart=__FINALPATH__/bin/python3 -m mautrix_signal ExecStart=__INSTALL_DIR__/bin/python3 -m mautrix_signal
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View file

@ -1,11 +1,13 @@
## List of known public services ## List of known public services
* Ask on one of the following rooms: #mautrix_yunohost:matrix.fdn.fr or #signal:maunium.net * Ask on one of the following rooms: `#mautrix_yunohost:matrix.fdn.fr` or `#signal:maunium.net`
## Bridging usage ## Bridging usage
** Note that several Signal and Matrix users can be bridged, each Signal account has its own bot administration room. If they are in a same Signal group, only one matrix room will be created. **
**Note that several Signal and Matrix users can be bridged, each Signal account has its own bot administration room. If they are in a same Signal group, only one matrix room will be created.**
### Bridge a Signal user and a Matrix user ### Bridge a Signal user and a Matrix user
* First your Matrix user or Synapse Server has to be authorized in the Configuration of the bridge (see below) * First your Matrix user or Synapse Server has to be authorized in the Configuration of the bridge (see below)
* Then, invite the bot (default @signalbot:yoursynapse.domain) in this new Mautrix-Signal bot administration room. * Then, invite the bot (default @signalbot:yoursynapse.domain) in this new Mautrix-Signal bot administration room.
* If the Bot does bot accept, see the [troubleshooting page](https://docs.mau.fi/bridges/general/troubleshooting.html) * If the Bot does bot accept, see the [troubleshooting page](https://docs.mau.fi/bridges/general/troubleshooting.html)
@ -13,6 +15,7 @@
See also [upstream wiki Authentication page](https://docs.mau.fi/bridges/python/signal/authentication.html) See also [upstream wiki Authentication page](https://docs.mau.fi/bridges/python/signal/authentication.html)
#### Linking the Bridge as a secondary device #### Linking the Bridge as a secondary device
* Type ``!sg link`` * Type ``!sg link``
* Open Signal App of your primary device * Open Signal App of your primary device
* Open Settings => Linked Devices => + => Capture the QR code with the camera * Open Settings => Linked Devices => + => Capture the QR code with the camera
@ -20,16 +23,18 @@ See also [upstream wiki Authentication page](https://docs.mau.fi/bridges/python/
* Accept invitations to the bridged chat rooms * Accept invitations to the bridged chat rooms
#### Registering the Bridge as a primary device #### Registering the Bridge as a primary device
* Type ``!sg register <phone>``, where ``<phone>`` is your phone number in the international format with no space, e.g. ``!sg register +33612345678`` * Type ``!sg register <phone>``, where ``<phone>`` is your phone number in the international format with no space, e.g. ``!sg register +33612345678``
* Answer in the bot room with the verification code that you reveived in SMS. * Answer in the bot room with the verification code that you reveived in SMS.
* Set a profile name with ``!sg set-profile-name <name>`` * Set a profile name with ``!sg set-profile-name <name>``
### Double puppeting ### Double puppeting
* Log in with ``login-matrix <access token>`` * Log in with ``login-matrix <access token>``
* After logging in, the default Matrix puppet of your Signal account should leave rooms and your account should join all rooms the puppet was in automatically. * After logging in, the default Matrix puppet of your Signal account should leave rooms and your account should join all rooms the puppet was in automatically.
### Relaybot: Bridge a group for several Matrix and several Signal users to chat together ### Relaybot: Bridge a group for several Matrix and several Signal users to chat together
* Create a room on the signal side * Create a room on the signal side
* Your bridged users will be invited on the Matrix side once they are invited on the Signal side * Your bridged users will be invited on the Matrix side once they are invited on the Signal side
* You can invite more people over on the Matrix side * You can invite more people over on the Matrix side
@ -39,36 +44,36 @@ It is not yet possible to bridge to an existing signal room, or create a new sig
## Configuration of the bridge ## Configuration of the bridge
The bridge is [roughly configured at installation](https://github.com/YunoHost-Apps/mautrix_signal_ynh/blob/master/conf/config.yaml), e.g. allowed admin and user of the bot. Finer configuration can be done by modifying the The bridge is [roughly configured at installation](https://github.com/YunoHost-Apps/mautrix_signal_ynh/blob/master/conf/config.yaml), e.g. allowed admin and user of the bot. Finer configuration can be done by modifying the
following configuration file with SSH: following configuration file with SSH:
```/opt/yunohost/mautrix_signal/config.yaml``` ```/opt/yunohost/mautrix_signal/config.yaml```
and then restarting the mautrix_signal service. and then restarting the mautrix_signal service.
## Documentation ## Documentation
* Official "Mautrix-Signal" documentation: https://docs.mau.fi/bridges/python/signal/index.html * Official "Mautrix-Signal" documentation: <https://docs.mau.fi/bridges/python/signal/index.html>
* Matrix room (Matrix Bridges in Yunohost): #mautrix_yunohost:matrix.fdn.fr * Matrix room (Matrix Bridges in Yunohost): #mautrix_yunohost:matrix.fdn.fr
* Matrix room (upstream app): #signal:maunium.net * Matrix room (upstream app): #signal:maunium.net
In case you need to upload your logs somewhere, be aware that they contain your contacts' and your phone numbers. Strip them out with In case you need to upload your logs somewhere, be aware that they contain your contacts' and your phone numbers. Strip them out with
``| sed -r 's/[0-9]{10,}/📞/g' `` ```| sed -r 's/[0-9]{10,}/📞/g'```
* "Mautrix-Signal" bridge is based on the [signal daemon](https://gitlab.com/signald/signald) project. * "Mautrix-Signal" bridge is based on the [signal daemon](https://gitlab.com/signald/signald) project.
* YunoHost documentation: If more specific documentation is needed, feel free to contribute. * YunoHost documentation: If more specific documentation is needed, feel free to contribute.
## YunoHost specific features ## YunoHost specific features
#### Multi-user support ### Multi-user support
* Bot users are not related to Yunohost users. Any Matrix account or Synapse server autorized in the configuration of the bridge can invite/use the bot. * Bot users are not related to Yunohost users. Any Matrix account or Synapse server autorized in the configuration of the bridge can invite/use the bot.
* The Signal bot is a local Matrix-Synapse user, but accessible through federation (synapse public or private). * The Signal bot is a local Matrix-Synapse user, but accessible through federation (synapse public or private).
* Several Signal and Matrix users can be bridged with one bridge, each user has its own bot administration room. * Several Signal and Matrix users can be bridged with one bridge, each user has its own bot administration room.
* If several bot users are in a same Signal group, only one Matrix room will be created by the bridge. * If several bot users are in a same Signal group, only one Matrix room will be created by the bridge.
* See https://github.com/YunoHost-Apps/synapse_ynh#multi-users-support * See <https://github.com/YunoHost-Apps/synapse_ynh#multi-users-support>
#### Multi-instance support ### Multi-instance support
* Multi-instance installation should work. Several bridge instances could be installed for one Matrix-Synapse instance so that one Matrix user can bridge several Signal accounts. * Multi-instance installation should work. Several bridge instances could be installed for one Matrix-Synapse instance so that one Matrix user can bridge several Signal accounts.
* Several bridge instances could be installed for each Matrix-Synapse instance to benefit from it. But one bridge can be used by users from several Matrix-Synapse instances. * Several bridge instances could be installed for each Matrix-Synapse instance to benefit from it. But one bridge can be used by users from several Matrix-Synapse instances.
## Limitations ## Limitations
* It looks like media are not bridged. * It looks like media are not bridged.
* Signal chats are not grouped in a Matrix community (as opposed to the Mautrix-WhatsApp or Mautrix-Facebook bridges) * Signal chats are not grouped in a Matrix community (as opposed to the Mautrix-WhatsApp or Mautrix-Facebook bridges)

View file

@ -1,11 +1,13 @@
## Liste de passerelles publiques ## Liste de passerelles publiques
* Demandez sur un des salons suivants: #mautrix_yunohost:matrix.fdn.fr or #signal:maunium.net * Demandez sur un des salons suivants: `#mautrix_yunohost:matrix.fdn.fr` or `#signal:maunium.net`
## Usages de la passerelle ## Usages de la passerelle
** Notez que plusieurs comptes Signal et Matrix peuvent être relayés, chaque compte Signal connecté a son propre Salon d'Administration. Si plusieurs utilisateur.ice.s du Robot sont dans un même groupe Signal, seul un Salon Matrix sera créé par la passerelle. **
**Notez que plusieurs comptes Signal et Matrix peuvent être relayés, chaque compte Signal connecté a son propre Salon d'Administration. Si plusieurs utilisateur.ice.s du Robot sont dans un même groupe Signal, seul un Salon Matrix sera créé par la passerelle.**
### Relayer TOUTES les conversations entre UN compte Signal et UN compte Matrix ### Relayer TOUTES les conversations entre UN compte Signal et UN compte Matrix
* Prérequis : votre compte Matrix ou le serveur sur lequel il est hébergé doit être autorisé dans la configuration de la passerelle (voir ci-dessous) * Prérequis : votre compte Matrix ou le serveur sur lequel il est hébergé doit être autorisé dans la configuration de la passerelle (voir ci-dessous)
* Invitez le Robot (par défaut @signalbot:synapse.votredomaine) à une nouvelle conversation. * Invitez le Robot (par défaut @signalbot:synapse.votredomaine) à une nouvelle conversation.
* Ce nouveau salon d'administration du Robot Mautrix-Signal est appelé "Administration Room". * Ce nouveau salon d'administration du Robot Mautrix-Signal est appelé "Administration Room".
@ -13,6 +15,7 @@
Voir aussi [upstream wiki Authentication page](https://docs.mau.fi/bridges/python/signal/authentication.html) Voir aussi [upstream wiki Authentication page](https://docs.mau.fi/bridges/python/signal/authentication.html)
#### Relier la passerelle comme un appareil secondaire #### Relier la passerelle comme un appareil secondaire
* Tapez ``!sg link`` * Tapez ``!sg link``
* Ouvrez l'application Signal de votre appareil principal * Ouvrez l'application Signal de votre appareil principal
* Ouvrez Paramètres => Appareils reliés => + => filmer le QR * Ouvrez Paramètres => Appareils reliés => + => filmer le QR
@ -20,44 +23,47 @@ Voir aussi [upstream wiki Authentication page](https://docs.mau.fi/bridges/pytho
* Acceptez les invitations aux salons * Acceptez les invitations aux salons
#### Enregistrer la passerelle comme appareil principal #### Enregistrer la passerelle comme appareil principal
* Tapez ``!sg register <phone>``, où ``<phone>`` est votre numéro de téléphone au format international sans espace, p.ex. ``!sg register +33612345678`` * Tapez ``!sg register <phone>``, où ``<phone>`` est votre numéro de téléphone au format international sans espace, p.ex. ``!sg register +33612345678``
* Répondez dans le salon d'administration avec le code de vérification reçu par SMS. * Répondez dans le salon d'administration avec le code de vérification reçu par SMS.
* Définissez une nom de profil ``!sg set-profile-name <name>`` * Définissez une nom de profil ``!sg set-profile-name <name>``
### Robot-Relai "Relaybot": Relayer les conversations de TOUS les comptes Matrix et TOUS les comptes Signal présents dans UN groupe/salon ### Robot-Relai "Relaybot": Relayer les conversations de TOUS les comptes Matrix et TOUS les comptes Signal présents dans UN groupe/salon
* Pas implémenté pour l'instant * Pas implémenté pour l'instant
## Configuration de la passerelle ## Configuration de la passerelle
La passerelle est [configurée avec les paramètres standards adaptés pour votre YunoHost et l'instance Matrix-Synapse sélectionnée](https://github.com/YunoHost-Apps/mautrix_signal_ynh/blob/master/conf/config.yaml). Vous pouvez par exemple ajouter des administrateur.ice.s et utilisateur.ice.s du Robot autorisés en modifiant le fichier de configuration par liaison SSH: La passerelle est [configurée avec les paramètres standards adaptés pour votre YunoHost et l'instance Matrix-Synapse sélectionnée](https://github.com/YunoHost-Apps/mautrix_signal_ynh/blob/master/conf/config.yaml). Vous pouvez par exemple ajouter des administrateur.ice.s et utilisateur.ice.s du Robot autorisés en modifiant le fichier de configuration par liaison SSH:
``` sudo nano /opt/yunohost/mautrix_signal/config.yaml``` ```sudo nano /opt/yunohost/mautrix_signal/config.yaml```
puis en redémarrant le service: puis en redémarrant le service:
``` sudo yunohost service restart mautrix_signal``` ```sudo yunohost service restart mautrix_signal```
## Documentation ## Documentation
* Documentation officielle "Mautrix-Signal": https://docs.mau.fi/bridges/python/signal/index.html * Documentation officielle "Mautrix-Signal": <https://docs.mau.fi/bridges/python/signal/index.html>
* Salon Matrix sur les Passerelles dans Yunohost): #mautrix_yunohost:matrix.fdn.fr * Salon Matrix sur les Passerelles dans Yunohost): #mautrix_yunohost:matrix.fdn.fr
* Salon Matrix (application principale): #signal:maunium.net * Salon Matrix (application principale): #signal:maunium.net
Si vous devez téléverser vos fichiers log quelque-part, soyez avertis qu'ils contiennent des informations sur vos contacts et vos numéros de téléphone. Effacez-les avec Si vous devez téléverser vos fichiers log quelque-part, soyez avertis qu'ils contiennent des informations sur vos contacts et vos numéros de téléphone. Effacez-les avec :
``| sed -r 's/[0-9]{10,}/📞/g' `` ```| sed -r 's/[0-9]{10,}/📞/g'```
* La passerelle "Mautrix-Signal" repose sur l'implémentation du [daemon signald](https://gitlab.com/signald/signald) . * La passerelle "Mautrix-Signal" repose sur l'implémentation du [daemon signald](https://gitlab.com/signald/signald).
* Documentation YunoHost: Si une documentation spécifique est nécessaire, n'hésitez pas à contribuer. * Documentation YunoHost: Si une documentation spécifique est nécessaire, n'hésitez pas à contribuer.
## Caractéristiques spécifiques YunoHost ## Caractéristiques spécifiques YunoHost
#### Support multi-comptes ### Support multi-comptes
* Les utilisateur.ice.s du Robot ne sont pas liés aux comptes Yunohost. N'importe quel compte Matrix ou serveur Synapse autorisés dans la configuration de la passerelle peut inviter/utiliser le Robot.
* Les utilisateur.ice.s du Robot ne sont pas liés aux comptes Yunohost. N'importe quel compte Matrix ou serveur Synapse autorisés dans la configuration de la passerelle peut inviter/utiliser le Robot.
* Le robot Signal est un utilisateur Matrix-Synapse local, mais accessible via la fédération (Synapse public ou privé). * Le robot Signal est un utilisateur Matrix-Synapse local, mais accessible via la fédération (Synapse public ou privé).
* Plusieurs comptes Signal et Matrix peuvent être liés avec une seule passerelle, chaque compte a son propre salon d'administration. * Plusieurs comptes Signal et Matrix peuvent être liés avec une seule passerelle, chaque compte a son propre salon d'administration.
* Si plusieurs utilisateur.ice.s du Robot sont dans un même groupe Signal, seul un Salon Matrix sera créé par la passerelle. Autrement dit, la passerelle construit un seul miroir du réseau de discussion existant sur Signal (utilisateurs et salons). * Si plusieurs utilisateur.ice.s du Robot sont dans un même groupe Signal, seul un Salon Matrix sera créé par la passerelle. Autrement dit, la passerelle construit un seul miroir du réseau de discussion existant sur Signal (utilisateurs et salons).
* Voir https://github.com/YunoHost-Apps/synapse_ynh#multi-users-support * Voir <https://github.com/YunoHost-Apps/synapse_ynh#multi-users-support>
#### Support multi-instance ### Support multi-instance
* L'installation multi-instance devrait fonctionner. Plusieurs instances de passerelles pourraient être installées pour une instance de Matrix-Synapse. Cela permet à un compte matrix de se relier à plusieurs comptes Signal. * L'installation multi-instance devrait fonctionner. Plusieurs instances de passerelles pourraient être installées pour une instance de Matrix-Synapse. Cela permet à un compte matrix de se relier à plusieurs comptes Signal.
* Plusieurs instances de passerelles pourraient être installées pour que chaque instance de Matrix-Synapse puisse en bénéficier. Mais une passerelle peut être utilisée par les comptes de plusieurs instances Matrix-Synapse. * Plusieurs instances de passerelles pourraient être installées pour que chaque instance de Matrix-Synapse puisse en bénéficier. Mais une passerelle peut être utilisée par les comptes de plusieurs instances Matrix-Synapse.
## Limitations ## Limitations
* Les appels Audio/Video ne sont pas relayés. Seule une notification apparait. * Les appels Audio/Video ne sont pas relayés. Seule une notification apparait.

View file

@ -1 +1,4 @@
A puppeting bridge between Matrix and Signal packaged as a YunoHost service. Messages, notifications (and sometimes media) are bridged between a Signal user and a Matrix user. Currently the Matrix user can NOT invite other Matrix user in a bridged Signal room, so only someone with a Signal account can participate to Signal group conversations. The ["Mautrix-Signal"](https://docs.mau.fi/bridges/python/signal/index.html) bridge consists in a Synapse App Service and relies on postgresql (mysql also possible). Therefore, [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh) should be installed beforehand. A puppeting bridge between Matrix and Signal packaged as a YunoHost service. Messages, notifications (and sometimes media) are bridged between a Signal user and a Matrix user.
Currently the Matrix user can NOT invite other Matrix user in a bridged Signal room, so only someone with a Signal account can participate to Signal group conversations.
The ["Mautrix-Signal"](https://docs.mau.fi/bridges/python/signal/index.html) bridge consists in a Synapse App Service and relies on postgresql (mysql also possible). Therefore, [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh) should be installed beforehand.

View file

@ -1,4 +1,5 @@
Une passerelle entre Matrix et Signal empaquetée comme un service YunoHost. Les messages, médias et notifications sont relayées entre un compte Signal et un compte Matrix. Une passerelle entre Matrix et Signal empaquetée comme un service YunoHost. Les messages, médias et notifications sont relayées entre un compte Signal et un compte Matrix.
La passerelle ["Mautrix-Signal"](https://docs.mau.fi/bridges/python/signal/index.html) consiste en un Service d'Application Matrix-Synapse et repose sur une base-de-données postgresql. C'est pourquoi [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh) doit être préalablemnet installé. La passerelle ["Mautrix-Signal"](https://docs.mau.fi/bridges/python/signal/index.html) consiste en un Service d'Application Matrix-Synapse et repose sur une base-de-données postgresql. C'est pourquoi [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh) doit être préalablemnet installé.
** Attention : sauvegardez et restaurez toujours les deux applications Yunohost matrix-synapse et mautrix_signal en même temps!** **Attention : sauvegardez et restaurez toujours les deux applications Yunohost matrix-synapse et mautrix_signal en même temps!**

View file

@ -1,89 +0,0 @@
{
"name": "Matrix Signal bridge",
"id": "mautrix_signal",
"packaging_format": 1,
"description": {
"en": "Matrix / Synapse puppeting bridge for Signal",
"fr": "Passerelle Matrix / Synapse pour Signal"
},
"version": "0.4.3~ynh1",
"url": "https://github.com/mautrix/signal",
"upstream": {
"license": "AGPL-3.0-or-later",
"userdoc": "https://docs.mau.fi/bridges/python/signal/index.html",
"code": "https://github.com/mautrix/signal"
},
"license": "AGPL-3.0-or-later",
"maintainer": {
"name": "MayeulC",
"email": "mautrix_signal_ynh@sans-nuage.fr",
"url": "https://github.com/YunoHost-Apps/mautrix_signal_ynh"
},
"requirements": {
"yunohost": ">= 11.0.0"
},
"multi_instance": true,
"services": [
"postgresql"
],
"arguments": {
"install": [
{
"name": "synapsenumber",
"type": "string",
"ask": {
"en": "Choose the local synapse instance number to communicate with mautrix_signal",
"fr": "Choisissez le numéro de l'instance synapse qui doit communiquer avec mautrix_signal"
},
"example": "2 (for instance synapse__2)",
"help": {
"en": "If you installed synapse only once time, then leave default value 1.",
"fr": "Si vous n'avez installé qu'une fois synapse, gardez la valeur par défaut 1."
},
"default": "1"
},
{
"name": "botname",
"type": "string",
"ask": {
"en": "Choose a local synapse user name for the Signal bot",
"fr": "Choisissez un nom d'utilisateur synapse local pour le robot Signal"
},
"example": "signalbot",
"help": {
"en": "A system user will be created. Invite @signalbot:localsynapse.servername from an authorized Matrix account to start bridging. Give the matrix server_name, not the full domain/url.",
"fr": "Un utilisateur système sera créé. Inviter @signalbot:localsynapse.servername depuis un compte Matrix autorisé pour démarrer une passerelle. Donner le nom du serveur matrix, pas le domaine/url complet."
},
"default": "signalbot"
},
{
"name": "botadmin",
"type": "string",
"ask": {
"en": "Choose the Matrix account administrator of the Signal bot",
"fr": "Choisissez le compte Matrix administrateur du robot Signal"
},
"example": "@johndoe:localsynapse.servername or @johndoe:matrix.org",
"help": {
"en": "The Signal bot administrator does not need to be a local synapse account.",
"fr": "Le compte administrateur du robot Signal peut ne pas être un compte local synapse."
},
"default": "Your main Matrix account"
},
{
"name": "botusers",
"type": "string",
"ask": {
"en": "Choose Matrix user(s) authorized to bridge with the Signal bot",
"fr": "Choisissez le/les compte(s) Matrix autorisés à utiliser la passerelle Signal"
},
"example": "admin or domain or @johndoe:server.name or server.name or *",
"default": "domain",
"help": {
"en": "Either the administrator only (admin), all local Synapse users (domain), a remote or local user (@johndoe:server.name), a remote server (matrix.org), or all remote/local servers (*) can be authorized. Give the Matrix server_name, not the full domain/URL.",
"fr": "L'administrateur seulement (admin), tous les comptes Synapse locaux (domain), un compte local ou distant (@johndoe:server.name), un serveur distant (matrix.org), ou tous les serveurs remote/local (*). Donner le nom du serveur Matrix, pas le domaine/URL complet."
}
}
]
}
}

109
manifest.toml Normal file
View file

@ -0,0 +1,109 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "mautrix_signal"
name = "Matrix Signal bridge"
description.en = "Matrix / Synapse puppeting bridge for Signal"
description.fr = "Passerelle Matrix / Synapse pour Signal"
version = "0.4.3~ynh1"
maintainers = ["MayeulC"]
[upstream]
license = "AGPL-3.0-or-later"
userdoc = "https://docs.mau.fi/bridges/python/signal/index.html"
code = "https://github.com/mautrix/signal"
fund = "https://github.com/sponsors/tulir"
[integration]
yunohost = ">= 11.2"
architectures = "all"
multi_instance = true
ldap = "not_relevant"
sso = "not_relevant"
disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ...
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
[install]
[install.synapsenumber]
ask.en = "Choose the local synapse instance number to communicate with mautrix_signal"
ask.fr = "Choisissez le numéro de l'instance synapse qui doit communiquer avec mautrix_signal"
help.en = "If you installed synapse only once time, then leave default value 1."
help.fr = "Si vous n'avez installé qu'une fois synapse, gardez la valeur par défaut 1."
type = "string"
example = "2 (for instance synapse__2)"
default = "1"
[install.botname]
ask.en = "Choose a local synapse user name for the Signal bot"
ask.fr = "Choisissez un nom d'utilisateur synapse local pour le robot Signal"
help.en = "A system user will be created. Invite @signalbot:localsynapse.servername from an authorized Matrix account to start bridging. Give the matrix server_name, not the full domain/url."
help.fr = "Un utilisateur système sera créé. Inviter @signalbot:localsynapse.servername depuis un compte Matrix autorisé pour démarrer une passerelle. Donner le nom du serveur matrix, pas le domaine/url complet."
type = "string"
example = "signalbot"
default = "signalbot"
[install.botadmin]
ask.en = "Choose the Matrix account administrator of the Signal bot"
ask.fr = "Choisissez le compte Matrix administrateur du robot Signal"
help.en = "The Signal bot administrator does not need to be a local synapse account."
help.fr = "Le compte administrateur du robot Signal peut ne pas être un compte local synapse."
type = "string"
example = "@johndoe:localsynapse.servername or @johndoe:matrix.org"
default = "Your main Matrix account"
[install.botusers]
ask.en = "Choose Matrix user(s) authorized to bridge with the Signal bot"
ask.fr = "Choisissez le/les compte(s) Matrix autorisés à utiliser la passerelle Signal"
help.en = "Either the administrator only (admin), all local Synapse users (domain), a remote or local user (@johndoe:server.name), a remote server (matrix.org), or all remote/local servers (*) can be authorized. Give the Matrix server_name, not the full domain/URL."
help.fr = "L'administrateur seulement (admin), tous les comptes Synapse locaux (domain), un compte local ou distant (@johndoe:server.name), un serveur distant (matrix.org), ou tous les serveurs remote/local (*). Donner le nom du serveur Matrix, pas le domaine/URL complet."
type = "string"
example = "admin or domain or @johndoe:server.name or server.name or *"
default = "domain"
[resources]
[resources.sources]
[resources.sources.main]
url = "https://github.com/mautrix/signal/archive/refs/tags/v0.4.3.tar.gz"
sha256 = "e75636e845d4b9d84070efec510b7358b93a4fb0d6ffe4300dbdb9260725ba53"
rename = "mautrix-signal.tar.gz"
extract = false
autoupdate.strategy = "latest_github_release"
[resources.sources.signald]
url = "https://gitlab.com/signald/signald/-/archive/0.17.0/signald-0.17.0.tar.gz"
sha256 = "225e36637daccf5f01138b7e29e3b2195bced7b13a290d163e34fe1f5d4a5d2a"
[resources.system_user]
[resources.install_dir]
[resources.permissions]
[resources.ports]
main.default = 8449
[resources.apt]
packages = [
"postgresql",
"python3",
"python3-dev",
"build-essential",
"libolm-dev",
]
[resources.apt.extras.signal]
repo = "https://updates.signald.org unstable main"
key = "https://updates.signald.org/apt-signing-key.asc"
packages = [
"libunixsocket-java",
"signald",
"signaldctl",
]
[resources.database]
type = "postgresql"

View file

@ -4,14 +4,33 @@
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
# dependencies used by the app (must be on a single line) signald_data="/var/lib/signald"
pkg_dependencies="postgresql python3 python3-dev build-essential libolm-dev" signald_exe="/usr/bin/signald"
extra_dependencies="libunixsocket-java signald signaldctl" signald_user="signald"
enable_relaybot=true
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS
#================================================= #=================================================
_install_rustup() {
export PATH="$PATH:$install_dir/.cargo/bin:$install_dir/.local/bin:/usr/local/sbin"
if [ -e "$install_dir/.rustup" ]; then
ynh_exec_as "$app" env "PATH=$PATH" rustup update
else
ynh_exec_as "$app" bash -c 'curl -sSf -L https://static.rust-lang.org/rustup.sh | sh -s -- -y --default-toolchain=stable --profile=minimal'
fi
}
_mautrix_signal_build_venv() {
python3 -m venv "$install_dir/venv"
"$install_dir/venv/bin/pip3" install --upgrade pip setuptools wheel
"$install_dir/venv/bin/pip3" install --upgrade \
"$install_dir/src/mautrix-signal.tar.gz[metrics,e2be,formattednumbers,qrlink,stickers]"
}
#================================================= #=================================================
# EXPERIMENTAL HELPERS # EXPERIMENTAL HELPERS
#================================================= #=================================================

View file

@ -10,28 +10,6 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
signald_data="/var/lib/signald"
#signald_exe="/usr/bin/signald"
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
#================================================= #=================================================
@ -41,28 +19,24 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$final_path" ynh_backup --src_path="$install_dir"
#================================================= #=================================================
# SPECIFIC BACKUP # SYSTEM CONFIGURATION
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
# BACKUP SYSTEMD
#================================================= #=================================================
ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup --src_path="/etc/systemd/system/$app.service"
ynh_backup --src_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# BACKUP VARIOUS FILES # BACKUP VARIOUS FILES
#================================================= #=================================================
ynh_backup --src_path="$signald_data" ynh_backup --src_path="$signald_data"
ynh_backup --src_path="/var/log/$app/"
#================================================= #=================================================
# BACKUP THE POSTGRESQL DATABASE # BACKUP THE POSTGRESQL DATABASE
#================================================= #=================================================

View file

@ -9,32 +9,18 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST # INITIALIZE AND STORE SETTINGS
#================================================= #=================================================
synapsenumber=$YNH_APP_ARG_SYNAPSENUMBER
botname=$YNH_APP_ARG_BOTNAME
bot_synapse_adm=true bot_synapse_adm=true
encryption=false encryption=false
botadmin=$YNH_APP_ARG_BOTADMIN
botusers=$YNH_APP_ARG_BOTUSERS
app=$YNH_APP_INSTANCE_NAME if [[ -z "$botusers" ]] || [ "$botusers" == "admin" ]; then
if_botusers="# "
if [ "$botusers" == "admin" ] else
then if_botusers=""
botusers=$botadmin
fi fi
# ToDo check (in manifest?) if the selected synapse instance is not already connected to a mautrix_bridge bridge # ToDo check (in manifest?) if the selected synapse instance is not already connected to a mautrix_bridge bridge
@ -47,161 +33,88 @@ fi
server_name=$(ynh_app_setting_get --app $synapse_instance --key server_name) server_name=$(ynh_app_setting_get --app $synapse_instance --key server_name)
domain=$(ynh_app_setting_get --app $synapse_instance --key domain) domain=$(ynh_app_setting_get --app $synapse_instance --key domain)
mautrix_version=$(ynh_app_upstream_version) mautrix_version=$(ynh_app_upstream_version)
enable_relaybot=true
bot_synapse_db_user="@$botname:$server_name" bot_synapse_db_user="@$botname:$server_name"
synapse_db_name="matrix_$synapse_instance" synapse_db_name="matrix_$synapse_instance"
signald_user="signald" # This is actually chosen by the signald dependency
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/opt/yunohost/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=7
ynh_app_setting_set --app=$app --key=botname --value=$botname
ynh_app_setting_set --app=$app --key=bot_synapse_adm --value=$bot_synapse_adm ynh_app_setting_set --app=$app --key=bot_synapse_adm --value=$bot_synapse_adm
ynh_app_setting_set --app=$app --key=encryption --value=$encryption ynh_app_setting_set --app=$app --key=encryption --value=$encryption
ynh_app_setting_set --app=$app --key=botadmin --value=$botadmin
ynh_app_setting_set --app=$app --key=botusers --value=$botusers
ynh_app_setting_set --app=$app --key=synapse_instance --value=$synapse_instance ynh_app_setting_set --app=$app --key=synapse_instance --value=$synapse_instance
ynh_app_setting_set --app=$app --key=server_name --value=$server_name ynh_app_setting_set --app=$app --key=server_name --value=$server_name
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=mautrix_version --value=$mautrix_version ynh_app_setting_set --app=$app --key=mautrix_version --value=$mautrix_version
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Finding an available port..." --weight=1
# Find a free port for communication between your local synapse instance (home server) and its app service mautrix_bridge.
port=$(ynh_find_port --port=8449)
ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=10
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_install_extra_app_dependencies --repo="https://updates.signald.org unstable main" --package="$extra_dependencies" --key="https://updates.signald.org/apt-signing-key.asc"
sleep 3
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
# Add the user to the signald group. The signald group was created when the signald # Add the user to the signald group. The signald group was created when the signald
# package was installed from the extra repository # package was installed from the extra repository
# resolved by https://gitlab.com/signald/signald/-/commit/278240f3f1cc40a3b444c958b68ca3d6908e98a8 # resolved by https://gitlab.com/signald/signald/-/commit/278240f3f1cc40a3b444c958b68ca3d6908e98a8
ynh_system_user_create --username=$app --home_dir="$final_path" --groups="$signald_user" usermod -a -G "$signald_user" "$app"
#=================================================
# CREATE A POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=3
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=3 ynh_script_progression --message="Setting up source files..." --weight=3
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path/src" ynh_setup_source --dest_dir="$install_dir/src"
chmod 750 "$final_path" chmod -R o-rwx "$install_dir"
chmod -R o-rwx "$final_path" chown -R "$app:$app" "$install_dir"
chown -R $app:$app "$final_path"
mkdir -p /var/log/$app
#=================================================
# SPECIFIC SETUP
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=2 ynh_script_progression --message="Adding a configuration file..." --weight=2
ynh_add_config --template="../conf/config.yaml" --destination="$final_path/config.yaml" ynh_add_config --template="config.yaml" --destination="$install_dir/config.yaml"
chmod 400 "$final_path/config.yaml" chmod 400 "$install_dir/config.yaml"
chown $app:$app "$final_path/config.yaml" chown "$app:$app" "$install_dir/config.yaml"
#================================================= #=================================================
# INSTALL MAUTRIX-BRIDGE PYTHON MODULE # INSTALL MAUTRIX-BRIDGE PYTHON MODULE
#================================================= #=================================================
ynh_script_progression --message="Installing Mautrix-Bridge Python Module..." --weight=6 ynh_script_progression --message="Installing Mautrix-Bridge Python Module..." --weight=6
mkdir -p /var/log/$app if [ "$YNH_ARCH" == "armhf" ] || [ "$YNH_ARCH" == "armel" ]; then
# Configure Mautrix-Bridge # Install rustup is not already installed
python3 -m venv $final_path # We need this to be able to install cryptgraphy
export HOME=$final_path _install_rustup
$final_path/bin/pip3 install --upgrade pip setuptools wheel fi
$final_path/bin/pip3 install --upgrade $final_path/src/mautrix-signal.tar.gz[metrics,e2be,formattednumbers,qrlink,stickers]
_mautrix_signal_build_venv
#================================================= #=================================================
# REGISTER SYNAPSE APP-SERVICE # REGISTER SYNAPSE APP-SERVICE
#================================================= #=================================================
ynh_script_progression --message="Registering Synapse app-service" --weight=1 ynh_script_progression --message="Registering Synapse app-service" --weight=1
$final_path/bin/python3 -m mautrix_signal -g -c $final_path/config.yaml -r /etc/matrix-$synapse_instance/app-service/$app.yaml "$install_dir/venv/bin/python3" -m mautrix_signal -g -c "$install_dir/config.yaml" -r "/etc/matrix-$synapse_instance/app-service/$app.yaml"
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die --message="Synapse can't restart with the appservice configuration" "/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh" || ynh_die --message="Synapse can't restart with the appservice configuration"
chown -R $app:$app "$final_path" chown -R "$app:$app" "$install_dir"
ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml" ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml"
ynh_store_file_checksum --file="$final_path/config.yaml" ynh_store_file_checksum --file="$install_dir/config.yaml"
#================================================= #=================================================
# SETUP SYSTEMD # SYSTEM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=3 ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
yunohost service add "$app" --description="$app daemon for bridging Signal and Matrix messages" --log=/var/log/$app/$app.log
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=3
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate ynh_use_logrotate
chmod -R 600 "/var/log/$app"
chmod 700 "/var/log/$app"
chown -R $app:$app /var/log/$app
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="$app daemon for bridging Signal and Matrix messages" --log=/var/log/$app/$app.log
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=2 ynh_script_progression --message="Starting $app's systemd service..." --weight=2
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -12,82 +12,34 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
botname=$(ynh_app_setting_get --app=$app --key=botname)
synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
server_name=$(ynh_app_setting_get --app=$app --key=server_name)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
synapse_db_name="matrix_$synapse_instance" synapse_db_name="matrix_$synapse_instance"
bot_synapse_db_user="@$botname:$server_name" bot_synapse_db_user="@$botname:$server_name"
signald_data="/var/lib/signald"
signald_exe="/usr/bin/signald"
signald_user="signald"
#================================================= #=================================================
# STANDARD REMOVE # REMOVE SYSTEM CONFIGURATIONS
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) # Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then
then ynh_script_progression --message="Removing $app service integration..." --weight=3
ynh_script_progression --message="Removing $app service integration..." --weight=3 yunohost service remove "$app"
yunohost service remove $app
fi fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config ynh_remove_systemd_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
# Remove the app-specific logrotate config # Remove the app-specific logrotate config
ynh_remove_logrotate ynh_remove_logrotate
#================================================= #=================================================
# REMOVE THE POSTGRESQL DATABASE # REMOVE THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=4 ynh_script_progression --message="Removing the PostgreSQL configuration..." --weight=4
# Remove a database if it exists, along with the associated user # Remove permissions of app to the synapse db
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name ynh_psql_execute_as_root --database="$synapse_db_name" --sql="DROP OWNED BY \"$app\";"
ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP OWNED BY ""$app"";"
ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP USER ""$app"";"
ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP OWNED BY ""$bot_synapse_db_user"";"
ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP USER ""$bot_synapse_db_user"";"
ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP OWNED BY ""$botname"";"
ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP USER ""$botname"";"
ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP OWNED BY ""$signald_user"";"
ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP USER ""$signald_user"";"
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=8
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#================================================= #=================================================
# SPECIFIC REMOVE # SPECIFIC REMOVE
@ -106,17 +58,6 @@ ynh_secure_remove --file="/etc/matrix-$synapse_instance/app-service/$app.yaml"
# Remove the log files # Remove the log files
ynh_secure_remove --file="/var/log/$app" ynh_secure_remove --file="/var/log/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=5
# Delete a system user
ynh_system_user_delete --username=$app
ynh_system_user_delete --username=$signald_user
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -10,118 +10,26 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
server_name=$(ynh_app_setting_get --app=$app --key=server_name)
botname=$(ynh_app_setting_get --app=$app --key=botname)
synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
bot_synapse_adm=$(ynh_app_setting_get --app=$app --key=bot_synapse_adm)
encryption=$(ynh_app_setting_get --app=$app --key=encryption)
botusers=$(ynh_app_setting_get --app=$app --key=botusers)
botadmin=$(ynh_app_setting_get --app=$app --key=botadmin)
previous_mautrix_version=$(ynh_app_setting_get --app=$app --key=mautrix_version)
port=$(ynh_app_setting_get --app=$app --key=port)
mautrix_version=$(ynh_app_upstream_version) mautrix_version=$(ynh_app_upstream_version)
synapse_db_name="matrix_$synapse_instance" synapse_db_name="matrix_$synapse_instance"
bot_synapse_db_user="@$botname:$server_name" bot_synapse_db_user="@$botname:$server_name"
signald_data="/var/lib/signald"
#signald_exe="/usr/bin/signald"
signald_user="signald" # This is actually chosen by the signald dependency
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$install_dir"
chmod 750 "$final_path" chmod -R o-rwx "$install_dir"
chmod -R o-rwx "$final_path" chown -R "$app:$app" "$install_dir"
chown -R $app:$app "$final_path"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="https://updates.signald.org unstable main" --package="$extra_dependencies" --key="https://updates.signald.org/apt-signing-key.asc"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path" --groups="$signald_user"
#================================================= #=================================================
# RESTORE THE POSTGRESQL DATABASE # RESTORE THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=8 ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=8
ynh_psql_test_if_first_run ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
#=================================================
# INSTALL MAUTRIX-BRIDGE PYTHON MODULE
#=================================================
ynh_script_progression --message="Installing Mautrix-Bridge Python Module..." --weight=6
mkdir -p /var/log/$app
# Configure Mautrix-Bridge
python3 -m venv $final_path
export HOME=$final_path
$final_path/bin/pip3 install --upgrade pip setuptools wheel
#=================================================
# REGISTER SYNAPSE APP-SERVICE
#=================================================
ynh_script_progression --message="Registering Synapse app-service" --weight=1
$final_path/bin/python3 -m mautrix_signal -g -c $final_path/config.yaml -r /etc/matrix-$synapse_instance/app-service/$app.yaml
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die "Synapse can't restart with the appservice configuration"
#================================================= #=================================================
# RESTORE VARIOUS FILES # RESTORE VARIOUS FILES
@ -131,44 +39,57 @@ ynh_systemd_action --service_name=signald --action="stop"
ynh_restore_file --origin_path="$signald_data" ynh_restore_file --origin_path="$signald_data"
ynh_systemd_action --service_name=signald --action="start" ynh_systemd_action --service_name=signald --action="start"
ynh_restore_file --origin_path="/var/log/$app/"
#================================================= #=================================================
# RESTORE SYSTEMD # INSTALL MAUTRIX-BRIDGE PYTHON MODULE
#================================================= #=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 ynh_script_progression --message="Installing Mautrix-Bridge Python Module..." --weight=6
if [ "$YNH_ARCH" == "armhf" ] || [ "$YNH_ARCH" == "armel" ]; then
# Install rustup is not already installed
# We need this to be able to install cryptgraphy
_install_rustup
fi
_mautrix_signal_build_venv
#=================================================
# REGISTER SYNAPSE APP-SERVICE
#=================================================
ynh_script_progression --message="Registering Synapse app-service" --weight=1
"$install_dir/venv/bin/python3" -m mautrix_signal -g -c "$install_dir/config.yaml" -r "/etc/matrix-$synapse_instance/app-service/$app.yaml"
"/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh" || ynh_die "Synapse can't restart with the appservice configuration"
#=================================================
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
ynh_restore_file --origin_path="/etc/systemd/system/$app.service" ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet systemctl enable "$app.service" --quiet
yunohost service add "$app" --description="$app daemon for bridging Signal and Matrix messages" --log="/var/log/$app/$app.log"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="$app daemon for bridging Signal and Matrix messages" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting $app's systemd service..." --weight=1
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
# Wait until the synapse user is created # Wait until the synapse user is created
sleep 30 sleep 30
# (Note that, by default, non-admins might not have your homeserver's permission to create communities.) # (Note that, by default, non-admins might not have your homeserver's permission to create communities.)
if [ "$bot_synapse_adm" = true ] if [ "$bot_synapse_adm" = true ]; then
then ynh_psql_execute_as_root --database="$synapse_db_name" --sql="UPDATE users SET admin = 1 WHERE name = \"$botname\";"
ynh_psql_execute_as_root --database=$synapse_db_name --sql="UPDATE users SET admin = 1 WHERE name = ""$botname"";"
# #yunohost app action run $synapse_instance set_admin_user -a username=$botname # #yunohost app action run $synapse_instance set_admin_user -a username=$botname
fi fi
ynh_systemd_action --service_name=$app --action="restart"
ynh_systemd_action --service_name="$app" --action="restart" --log_path="/var/log/$app/$app.log"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -9,51 +9,10 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
botname=$(ynh_app_setting_get --app=$app --key=botname)
encryption=$(ynh_app_setting_get --app=$app --key=encryption)
botadmin=$(ynh_app_setting_get --app=$app --key=botadmin)
botusers=$(ynh_app_setting_get --app=$app --key=botusers)
domain=$(ynh_app_setting_get --app=$app --key=domain)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
previous_mautrix_version=$(ynh_app_setting_get --app=$app --key=mautrix_version)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
port=$(ynh_app_setting_get --app=$app --key=port)
synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
server_name=$(ynh_app_setting_get --app=$app --key=server_name)
mautrix_version=$(ynh_app_upstream_version) mautrix_version=$(ynh_app_upstream_version)
synapse_db_name="matrix_$synapse_instance" synapse_db_name="matrix_$synapse_instance"
signald_user="signald" # This is actually chosen by the signald dependency server_name=$(ynh_app_setting_get --app $synapse_instance --key server_name)
enable_relaybot=true domain=$(ynh_app_setting_get --app $synapse_instance --key domain)
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..." --weight=1
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=5
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
@ -69,121 +28,75 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Upgrade from >0.2.0
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
# Upgrade from <=0.2.0
if [ -z "$db_name" ]
then
db_name=$(ynh_app_setting_get --app=$app --key=$app)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
fi
if [ -z "$db_pwd" ]
then
db_pwd=$(ynh_app_setting_get --app=$app --key=mautrix_bridge_db_pwd)
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
fi
# Fix possible permission issues with a previous signald version, esp. with stickers # Fix possible permission issues with a previous signald version, esp. with stickers
mkdir -p /var/lib/signald/{avatars,attachments,stickers} mkdir -p /var/lib/signald/{avatars,attachments,stickers}
chown $signald_user:$signald_user /var/lib/signald/{avatars,attachments,stickers} chown "$signald_user:$signald_user" /var/lib/signald/{avatars,attachments,stickers}
chmod -R g+rwX /var/lib/signald/{avatars,attachments,stickers} chmod -R g+rwX /var/lib/signald/{avatars,attachments,stickers}
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path" --groups="$signald_user"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Upgrading source files..." --weight=1
if [ "$upgrade_type" == "UPGRADE_APP" ] # Download, check integrity, uncompress and patch the source from app.src
then ynh_setup_source --dest_dir="$install_dir/src" --full_replace=1
ynh_script_progression --message="Upgrading source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src chmod -R o-rwx "$install_dir"
ynh_setup_source --dest_dir="$final_path/src" chown -R "$app:$app" "$install_dir"
fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=5
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_install_extra_app_dependencies --repo="https://updates.signald.org unstable main" --package="$extra_dependencies" --key="https://updates.signald.org/apt-signing-key.asc"
#=================================================
# SPECIFIC UPGRADE
#================================================= #=================================================
# UPDATE A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=2 ynh_script_progression --message="Updating a configuration file..." --weight=2
ynh_add_config --template="../conf/config.yaml" --destination="$final_path/config.yaml" if [[ -z "$botusers" ]] || [ "$botusers" == "admin" ]; then
if_botusers="# "
else
if_botusers=""
fi
chmod 400 "$final_path/config.yaml" ynh_add_config --template="config.yaml" --destination="$install_dir/config.yaml"
chown $app:$app "$final_path/config.yaml"
chmod 400 "$install_dir/config.yaml"
chown "$app:$app" "$install_dir/config.yaml"
#================================================= #=================================================
# UPGRADE MAUTRIX-BRIDGE PYTHON MODULE # UPGRADE MAUTRIX-BRIDGE PYTHON MODULE
#================================================= #=================================================
ynh_script_progression --message="Upgrading Mautrix-Bridge Python Module..." --weight=2 ynh_script_progression --message="Upgrading Mautrix-Bridge Python Module..." --weight=2
python3 -m venv $final_path if [ "$YNH_ARCH" == "armhf" ] || [ "$YNH_ARCH" == "armel" ]; then
export HOME=$final_path # Install rustup is not already installed
$final_path/bin/pip3 install --upgrade pip setuptools wheel # We need this to be able to install cryptgraphy
$final_path/bin/pip3 install --upgrade $final_path/src/mautrix-signal.tar.gz[metrics,e2be,formattednumbers,qrlink,stickers] _install_rustup
fi
_mautrix_signal_build_venv
#================================================= #=================================================
# REGISTER SYNAPSE APP-SERVICE # REGISTER SYNAPSE APP-SERVICE
#================================================= #=================================================
ynh_script_progression --message="Registering Synapse app-service" --weight=1 ynh_script_progression --message="Registering Synapse app-service" --weight=1
$final_path/bin/python3 -m mautrix_signal -g -c $final_path/config.yaml -r /etc/matrix-$synapse_instance/app-service/$app.yaml "$install_dir/venv/bin/python3" -m mautrix_signal -g -c "$install_dir/config.yaml" -r "/etc/matrix-$synapse_instance/app-service/$app.yaml"
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die "Synapse can't restart with the appservice configuration" /opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die "Synapse can't restart with the appservice configuration"
# Set permissions on app files # Set permissions on app files
chown -R $app:$app "$final_path" chown -R "$app:$app" "$install_dir"
ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml" ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml"
ynh_store_file_checksum --file="$final_path/config.yaml" ynh_store_file_checksum --file="$install_dir/config.yaml"
#================================================= #=================================================
# SETUP SYSTEMD # REAPPLY SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=4 ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
yunohost service add "$app" --description="$app daemon for bridging Signal and Matrix messages" --log="/var/log/$app/$app.log"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
# Use logrotate to manage app-specific logfile(s) # Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --nonappend ynh_use_logrotate --nonappend
chmod -R 600 "/var/log/$app"
chmod 700 "/var/log/$app"
chown -R $app:$app /var/log/$app
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="$app daemon for bridging Signal and Matrix messages" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -191,7 +104,7 @@ yunohost service add $app --description="$app daemon for bridging Signal and Mat
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=$app --action="start" ynh_systemd_action --service_name="$app" --action="start"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

15
tests.toml Normal file
View file

@ -0,0 +1,15 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
test_format = 1.0
[default]
preinstall = """
sudo yunohost tools update apps
sudo yunohost app install --force https://github.com/YunoHost-Apps/synapse_ynh/ \
-a "domain=$domain&server_name=$server_name&is_free_registration=$is_free_registration&jitsi_server=$jitsi_server"
"""
args.botadmin = "@johndoe:synapsedomain.tld"
args.botusers = "synapsedomain.tld"
test_upgrade_from.40c16d3c8898196c6e1a43e8f0af70c052dd41f6.name = "0.2.3~ynh1"