1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mautrix_facebook_ynh.git synced 2024-09-03 19:36:33 +02:00

Merge pull request #9 from YunoHost-Apps/testing

Fix package check
This commit is contained in:
yalh76 2022-09-20 23:52:24 +02:00 committed by GitHub
commit c48dbe3c28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 725 additions and 538 deletions

View file

@ -8,7 +8,7 @@ about: When creating a bug report, please use the following template to provide
1. *Read this whole template first.* 1. *Read this whole template first.*
2. *Determine if you are on the right place:* 2. *Determine if you are on the right place:*
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!* - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!*
- *Otherwise, the issue may be due to mautrix-facebook itself. Refer to its documentation or repository for help.* - *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.*
- *When in doubt, post here and we will figure it out together.* - *When in doubt, post here and we will figure it out together.*
3. *Delete the italic comments as you write over them below, and remove this guide.* 3. *Delete the italic comments as you write over them below, and remove this guide.*
--- ---
@ -31,7 +31,7 @@ about: When creating a bug report, please use the following template to provide
- *If you performed a command from the CLI, the command itself is enough. For example:* - *If you performed a command from the CLI, the command itself is enough. For example:*
```sh ```sh
sudo yunohost app install mautrix_facebook sudo yunohost app install the_app
``` ```
- *If you used the webadmin, please perform the equivalent command from the CLI first.* - *If you used the webadmin, please perform the equivalent command from the CLI first.*
- *If the error occurs in your browser, explain what you did:* - *If the error occurs in your browser, explain what you did:*

16
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View file

@ -0,0 +1,16 @@
## Problem
- *Description of why you made this PR*
## Solution
- *And how do you fix that problem*
## PR Status
- [ ] Code finished and ready to be reviewed/tested
- [ ] The fix/enhancement were manually tested (if applicable)
## Automatic tests
Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization)

107
.github/workflows/updater.sh vendored Normal file
View file

@ -0,0 +1,107 @@
#!/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/$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-facebook.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

49
.github/workflows/updater.yml vendored Normal file
View file

@ -0,0 +1,49 @@
# 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@v2
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@v3
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

@ -15,9 +15,74 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
## Overview ## Overview
A Facebook puppeting bridge for Matrix/Synapse. A puppeting bridge between Matrix and Facebook packaged as a YunoHost service. Messages, notifications (and sometimes media) are bridged between a Facebook user and a Matrix user. Currently the Matrix user can NOT invite other Matrix user in a bridged Facebook room, so only someone with a Facebook account can participate to Facebook group conversations. The ["Mautrix-Facebook"](https://docs.mau.fi/bridges/python/facebook/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.3.3~ynh1 **Shipped version:** 0.3.3~ynh1
## Disclaimers / important information
## List of known public services
* Ask on one of the following rooms: #mautrix_yunohost:matrix.fdn.fr or #facebook:maunium.net
## Bridging usage
** Note that several Facebook and Matrix users can be bridged, each Facebook account has its own bot administration room. If they are in a same Facebook group, only one matrix room will be created. **
### Bridge a Facebook 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 @facebookbot:yoursynapse.domain)
* If the Bot does bot accept, see the [troubleshooting page](https://docs.mau.fi/bridges/general/troubleshooting.html)
* Type ``!fb login <email> <password>``, where ``<email>`` and ``<password>`` are your Facebook email and password, e.g. ``!fb login gafam@evil.com facebookpwd``
* If you have 2FA enabled, the bot will ask you to send the 2FA token.
* By defaults, only conversations with very recent messages will be bridged
* Accept invitations to the bridged chat rooms
* Send ``!fb help`` to the bot in this new Mautrix-Facebook bot administration room to know how to control the bot.
See also [upstream wiki Authentication page](https://docs.mau.fi/bridges/python/facebook/authentication.html)
### Double puppeting
* First login as described in the previous section
* Connect to the Matrix-Synapse Server to get an access token, for example with the command ``curl -XPOST -d '{"type":"m.login.password","identifier":{"type": "m.id.user", "user": "matrixusername"},"password":"matrixpassword","initial_device_display_name":"mautrix-facebook"}' https://yoursynapse.domain/_matrix/client/r0/login``
* Send ``login-matrix <access token>``, where ``<access token>`` is the token received from the Server.
* After logging in, the default Matrix puppet of your Facebook 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 Facebook users to chat together
Not yet available
## Configuration of the bridge
The bridge is [roughly configured at installation](https://github.com/YunoHost-Apps/mautrix_facebook_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_facebook/config.yaml```
and then restarting the mautrix_facebook service.
## 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 Facebook bot is a local Matrix-Synapse user, but accessible through federation (synapse public or private).
* Several Facebook 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 Facebook 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 Facebook 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.
## Additional information
* Other info you would like to add about this app.
**More info on the documentation page:**
https://docs.mau.fi/bridges/python/facebook/index.html
## Documentation and resources ## Documentation and resources
* Official user documentation: <https://docs.mau.fi/bridges/python/facebook/index.html> * Official user documentation: <https://docs.mau.fi/bridges/python/facebook/index.html>

View file

@ -15,9 +15,60 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
## Vue d'ensemble ## Vue d'ensemble
Passerelle Facebook pour Matrix/Synapse. Une passerelle entre Matrix et Messenger empaquetée comme un service YunoHost. Les messages, médias et notifications sont relayées entre un compte Messenger et un compte Matrix.
La passerelle ["Mautrix-Facebook"](https://docs.mau.fi/bridges/python/facebook/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_facebook en même temps!**
**Version incluse :** 0.3.3~ynh1
## Avertissements / informations importantes
## Liste de passerelles publiques
* Demandez sur un des salons suivants: #mautrix_yunohost:matrix.fdn.fr or #facebook:maunium.net
## Usages de la passerelle
** Notez que plusieurs comptes Messenger et Matrix peuvent être relayés, chaque compte Messenger connecté a son propre Salon d'Administration. Si plusieurs utilisateur.ice.s du Robot sont dans un même groupe Messenger, seul un Salon Matrix sera créé par la passerelle. **
### Relayer TOUTES les conversations entre UN compte Messenger 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 @facebookbot:synapse.votredomaine) à une nouvelle conversation.
* Ce nouveau salon d'administration du Robot Mautrix-Messenger 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/facebook/authentication.html)
#### Relier la passerelle comme un appareil secondaire
### Robot-Relai "Relaybot": Relayer les conversations de TOUS les comptes Matrix et TOUS les comptes Messenger 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_facebook_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_facebook/config.yaml```
puis en redémarrant le service:
``` sudo yunohost service restart mautrix_facebook```
## 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 Messenger est un utilisateur Matrix-Synapse local, mais accessible via la fédération (Synapse public ou privé).
* Plusieurs comptes Messenger 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 Messenger, seul un Salon Matrix sera créé par la passerelle. Autrement dit, la passerelle construit un seul miroir du réseau de discussion existant sur Messenger (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 Messenger.
* 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.
**Version incluse :** 0.3.3~ynh1
## Documentations et ressources ## Documentations et ressources
* Documentation officielle utilisateur : <https://docs.mau.fi/bridges/python/facebook/index.html> * Documentation officielle utilisateur : <https://docs.mau.fi/bridges/python/facebook/index.html>

View file

@ -1,15 +1,12 @@
# See here for more information
# https://github.com/YunoHost/package_check#syntax-check_process-file
;; Default test serie ;; Default test serie
; pre-install ; pre-install
sudo yunohost tools update apps sudo yunohost tools update apps
sudo yunohost app info synapse --quiet > /dev/null || sudo yunohost app install https://github.com/YunoHost-Apps/synapse_ynh/ -a "domain=$domain&server_name=$server_name&is_public=$is_public&jitsi_server=$jitsi_server" --force 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 ; Manifest
port="8449" (PORT) port="8449" (PORT)
bot_synapse_adm=0
synapsenumber="1" synapsenumber="1"
botname="facebookbot" botname="facebookbot"
bot_synapse_adm=0
encryption=0 encryption=0
botadmin="@johndoe:synapsedomain.tld" (USER) botadmin="@johndoe:synapsedomain.tld" (USER)
botusers="@johndoe:synapsedomain.tld" botusers="@johndoe:synapsedomain.tld"
@ -21,7 +18,10 @@
setup_private=0 setup_private=0
setup_public=0 setup_public=0
upgrade=1 upgrade=1
# 0.2.0
upgrade=1 from_commit=c11342a1f14fe8b287dfcb025f8f8196b9097175 upgrade=1 from_commit=c11342a1f14fe8b287dfcb025f8f8196b9097175
# 0.3.3~ynh1
upgrade=1 from_commit=95aae535122b98bd94c410e040891b81b15bd654
backup_restore=1 backup_restore=1
multi_instance=1 multi_instance=1
port_already_use=1 port_already_use=1

View file

@ -6,12 +6,11 @@ homeserver:
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: __VERIFY_SERVER_SSL_CERTIFICATES__ verify_ssl: true
# Whether or not the homeserver supports asmux-specific endpoints, # Whether or not the homeserver supports asmux-specific endpoints,
# such as /_matrix/client/unstable/net.maunium.asmux/dms for atomically # such as /_matrix/client/unstable/net.maunium.asmux/dms for atomically
# updating m.direct. # updating m.direct.
# asmux: false asmux: false
asmux: __MATRIX_SERVER_SUPPORTS_ASMUX__
# 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.
@ -41,7 +40,7 @@ appservice:
# Format examples: # Format examples:
# SQLite: sqlite:///filename.db # SQLite: sqlite:///filename.db
# Postgres: postgres://username:password@hostname/dbname # Postgres: postgres://username:password@hostname/dbname
database: postgres://__MAUTRIX_BRIDGE_USER__:__MAUTRIX_BRIDGE_DB_PWD__@localhost:5432/__MAUTRIX_BRIDGE_DB_NAME__ database: postgres://__DB_USER__:__DB_PWD__@localhost:5432/__DB_NAME__
# Additional arguments for asyncpg.create_pool() or sqlite3.connect # Additional arguments for asyncpg.create_pool() or sqlite3.connect
# 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
@ -311,7 +310,7 @@ logging:
file: file:
class: logging.handlers.RotatingFileHandler class: logging.handlers.RotatingFileHandler
formatter: normal formatter: normal
filename: __LOG_FILENAME__ filename: /var/log/__APP__/__APP__.log
maxBytes: 10485760 maxBytes: 10485760
backupCount: 10 backupCount: 10
console: console:
@ -319,11 +318,11 @@ logging:
formatter: colored formatter: colored
loggers: loggers:
mau: mau:
level: __LOG_LEVEL__ level: INFO
paho: paho:
level: INFO level: INFO
aiohttp: aiohttp:
level: INFO level: INFO
root: root:
level: __LOG_LEVEL__ level: INFO
handlers: [file, console] handlers: [file, console]

View file

@ -8,5 +8,6 @@ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__FINALPATH__/
ExecStart=__FINALPATH__/bin/python3 -m mautrix_facebook ExecStart=__FINALPATH__/bin/python3 -m mautrix_facebook
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

1
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1 @@
A puppeting bridge between Matrix and Facebook packaged as a YunoHost service. Messages, notifications (and sometimes media) are bridged between a Facebook user and a Matrix user. Currently the Matrix user can NOT invite other Matrix user in a bridged Facebook room, so only someone with a Facebook account can participate to Facebook group conversations. The ["Mautrix-Facebook"](https://docs.mau.fi/bridges/python/facebook/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.

4
doc/DESCRIPTION_fr.md Normal file
View file

@ -0,0 +1,4 @@
Une passerelle entre Matrix et Messenger empaquetée comme un service YunoHost. Les messages, médias et notifications sont relayées entre un compte Messenger et un compte Matrix.
La passerelle ["Mautrix-Facebook"](https://docs.mau.fi/bridges/python/facebook/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_facebook en même temps!**

60
doc/DISCLAIMER.md Normal file
View file

@ -0,0 +1,60 @@
## List of known public services
* Ask on one of the following rooms: #mautrix_yunohost:matrix.fdn.fr or #facebook:maunium.net
## Bridging usage
** Note that several Facebook and Matrix users can be bridged, each Facebook account has its own bot administration room. If they are in a same Facebook group, only one matrix room will be created. **
### Bridge a Facebook 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 @facebookbot:yoursynapse.domain)
* If the Bot does bot accept, see the [troubleshooting page](https://docs.mau.fi/bridges/general/troubleshooting.html)
* Type ``!fb login <email> <password>``, where ``<email>`` and ``<password>`` are your Facebook email and password, e.g. ``!fb login gafam@evil.com facebookpwd``
* If you have 2FA enabled, the bot will ask you to send the 2FA token.
* By defaults, only conversations with very recent messages will be bridged
* Accept invitations to the bridged chat rooms
* Send ``!fb help`` to the bot in this new Mautrix-Facebook bot administration room to know how to control the bot.
See also [upstream wiki Authentication page](https://docs.mau.fi/bridges/python/facebook/authentication.html)
### Double puppeting
* First login as described in the previous section
* Connect to the Matrix-Synapse Server to get an access token, for example with the command ``curl -XPOST -d '{"type":"m.login.password","identifier":{"type": "m.id.user", "user": "matrixusername"},"password":"matrixpassword","initial_device_display_name":"mautrix-facebook"}' https://yoursynapse.domain/_matrix/client/r0/login``
* Send ``login-matrix <access token>``, where ``<access token>`` is the token received from the Server.
* After logging in, the default Matrix puppet of your Facebook 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 Facebook users to chat together
Not yet available
## Configuration of the bridge
The bridge is [roughly configured at installation](https://github.com/YunoHost-Apps/mautrix_facebook_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_facebook/config.yaml```
and then restarting the mautrix_facebook service.
## 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 Facebook bot is a local Matrix-Synapse user, but accessible through federation (synapse public or private).
* Several Facebook 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 Facebook 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 Facebook 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.
## Additional information
* Other info you would like to add about this app.
**More info on the documentation page:**
https://docs.mau.fi/bridges/python/facebook/index.html

43
doc/DISCLAIMER_fr.md Normal file
View file

@ -0,0 +1,43 @@
## Liste de passerelles publiques
* Demandez sur un des salons suivants: #mautrix_yunohost:matrix.fdn.fr or #facebook:maunium.net
## Usages de la passerelle
** Notez que plusieurs comptes Messenger et Matrix peuvent être relayés, chaque compte Messenger connecté a son propre Salon d'Administration. Si plusieurs utilisateur.ice.s du Robot sont dans un même groupe Messenger, seul un Salon Matrix sera créé par la passerelle. **
### Relayer TOUTES les conversations entre UN compte Messenger 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 @facebookbot:synapse.votredomaine) à une nouvelle conversation.
* Ce nouveau salon d'administration du Robot Mautrix-Messenger 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/facebook/authentication.html)
#### Relier la passerelle comme un appareil secondaire
### Robot-Relai "Relaybot": Relayer les conversations de TOUS les comptes Matrix et TOUS les comptes Messenger 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_facebook_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_facebook/config.yaml```
puis en redémarrant le service:
``` sudo yunohost service restart mautrix_facebook```
## 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 Messenger est un utilisateur Matrix-Synapse local, mais accessible via la fédération (Synapse public ou privé).
* Plusieurs comptes Messenger 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 Messenger, seul un Salon Matrix sera créé par la passerelle. Autrement dit, la passerelle construit un seul miroir du réseau de discussion existant sur Messenger (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 Messenger.
* 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.

View file

@ -3,11 +3,11 @@
"id": "mautrix_facebook", "id": "mautrix_facebook",
"packaging_format": 1, "packaging_format": 1,
"description": { "description": {
"en": "A Facebook puppeting bridge for Matrix/Synapse.", "en": "Facebook puppeting bridge for Matrix/Synapse.",
"fr": "Passerelle Facebook pour Matrix/Synapse." "fr": "Passerelle Facebook pour Matrix/Synapse."
}, },
"version": "0.3.3~ynh1", "version": "0.3.3~ynh1",
"url": "https://github.com/tulir/mautrix-facebook", "url": "https://github.com/mautrix/facebook",
"upstream": { "upstream": {
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"admindoc": "https://docs.mau.fi/bridges/python/setup/index.html?bridge=facebook", "admindoc": "https://docs.mau.fi/bridges/python/setup/index.html?bridge=facebook",
@ -69,7 +69,6 @@
"fr": "N'activer que si vous connaissez les prérequis et constraintes liées à e2b." "fr": "N'activer que si vous connaissez les prérequis et constraintes liées à e2b."
}, },
"default": false "default": false
}, },
{ {
"name": "botadmin", "name": "botadmin",

View file

@ -1,18 +0,0 @@
## Problem
- *Description of why you made this PR*
## Solution
- *And how do you fix that problem*
## PR Status
- [ ] Code finished.
- [ ] Tested with Package_check.
- [ ] Fix or enhancement tested.
- [ ] Upgrade from last version tested.
- [ ] Can be reviewed and tested.
## Package_check results
---
*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results*
[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/mautrix_facebook_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/mautrix_facebook_ynh%20PR-NUM-%20(USERNAME)/)

View file

@ -4,7 +4,7 @@
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
# dependencies used by the app # dependencies used by the app (must be on a single line)
pkg_dependencies="postgresql python3" pkg_dependencies="postgresql python3"
#================================================= #=================================================

View file

@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_clean_setup () { ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
@ -28,45 +27,14 @@ ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# language=$(ynh_app_setting_get --app=$app --key=language) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
server_name=$(ynh_app_setting_get --app=$app --key=server_name)
port=$(ynh_app_setting_get --app=$app --key=port)
botname=$(ynh_app_setting_get --app=$app --key=botname)
synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
app_service_registration_path=$(ynh_app_setting_get --app=$app --key=app_service_registration_path)
# bot_is_synapse_admin=$(ynh_app_setting_get --app=$app --key=bot_is_synapse_admin)
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)
mautrix_config_path="$final_path/config.yaml"
mautrix_version=$(ynh_app_setting_get --app=$app --key=mautrix_version)
mautrix_bridge_db_pwd=$(ynh_app_setting_get --app=$app --key=mautrix_bridge_db_pwd)
#=================================================
# SET CONSTANTS
#=================================================
botname_synapse_db_user="@$botname:$server_name"
synapse_db_name="matrix_$synapse_instance"
mautrix_bridge_user=$app
mautrix_bridge_db_name=$app
mautrix_bridge_db_user=$app
upstream_version=$(ynh_app_upstream_version)
log_filename="/var/log/$app/$app.log"
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
#================================================= #=================================================
ynh_print_info --message="Declaring files to be backed up..." ynh_print_info --message="Declaring files to be backed up..."
### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs
### to be backuped and not an actual copy of any file. The actual backup that
### creates and fill the archive with the files happens in the core after this
### script is called. Hence ynh_backups calls takes basically 0 seconds to run.
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
@ -79,7 +47,7 @@ ynh_backup --src_path="$final_path"
# BACKUP LOGROTATE # BACKUP LOGROTATE
#================================================= #=================================================
ynh_backup --src_path="/var/log/$app" ynh_backup --src_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# BACKUP SYSTEMD # BACKUP SYSTEMD
@ -92,7 +60,7 @@ ynh_backup --src_path="/etc/systemd/system/$app.service"
#================================================= #=================================================
ynh_print_info --message="Backing up the PostgreSQL database..." ynh_print_info --message="Backing up the PostgreSQL database..."
ynh_psql_dump_db --database="$mautrix_bridge_db_name" > ${YNH_CWD}/dump.sql ynh_psql_dump_db --database="$db_name" > db.sql
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -14,7 +14,6 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_clean_setup () { ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
@ -31,121 +30,58 @@ botadmin=$YNH_APP_ARG_BOTADMIN
botusers=$YNH_APP_ARG_BOTUSERS botusers=$YNH_APP_ARG_BOTUSERS
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
final_path=/opt/yunohost/$app
# ToDo check (in manifest?) if the selected synapse instance is not already connected to a mautrix_facebook bridge # ToDo check (in manifest?) if the selected synapse instance is not already connected to a mautrix_facebook bridge
if [ $synapsenumber -eq "1" ] if [ $synapsenumber -eq "1" ]
then then
synapse_instance="synapse" synapse_instance="synapse"
else else
synapse_instance="synapse__$synapsenumber" synapse_instance="synapse__$synapsenumber"
fi 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)
synapse_config_path="/etc/matrix-$synapse_instance" synapse_registration_path="/etc/matrix-$synapse_instance/app-service"
app_service_registration_path="/etc/matrix-$synapse_instance/app-service"
synapse_name="matrix-$synapse_instance"
synapse_user="matrix-$synapse_instance"
synapse_db_name="matrix_$synapse_instance" synapse_db_name="matrix_$synapse_instance"
synapse_db_user="matrix_$synapse_instance"
#=================================================
# SET CONSTANTS
#=================================================
botname_synapse_db_user="@$botname:$server_name"
synapse_db_name="matrix_$synapse_instance"
mautrix_bridge_user=$app
mautrix_bridge_db_name=$app
mautrix_bridge_db_user=$app
upstream_version=$(ynh_app_upstream_version)
log_filename="/var/log/$app/$app.log"
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1 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" test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Configuring bridge 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)
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_script_progression --message="Storing installation settings..." --weight=7 ynh_script_progression --message="Storing installation settings..." --weight=7
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=server_name --value=$server_name
ynh_app_setting_set --app=$app --key=port --value=$port
ynh_app_setting_set --app=$app --key=botname --value=$botname ynh_app_setting_set --app=$app --key=botname --value=$botname
ynh_app_setting_set --app=$app --key=synapse_instance --value=$synapse_instance
ynh_app_setting_set --app=$app --key=app_service_registration_path --value=$app_service_registration_path
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=mautrix_bridge_db_name --value=$mautrix_bridge_db_name
ynh_app_setting_set --app=$app --key=botadmin --value=$botadmin 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=botusers --value=$botusers
ynh_app_setting_set --app=$app --key=mautrix_version --value=$upstream_version ynh_app_setting_set --app=$app --key=synapse_instance --value=$synapse_instance
ynh_app_setting_set --app=$app --key=final_path --value=$final_path 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=synapse_registration_path --value=$synapse_registration_path
#=================================================
# 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 # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." --weight=97 ynh_script_progression --message="Installing dependencies..." --weight=97
### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package. ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
### Those deb packages will be installed as dependencies of this package.
### If you're not using this helper:
### - Remove the section "REMOVE DEPENDENCIES" in the remove script
### - Remove the variable "pkg_dependencies" in _common.sh
### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE A POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=3
mautrix_bridge_db_pwd=$(ynh_string_random --length=30)
ynh_app_setting_set --app=$app --key=mautrix_bridge_db_pwd --value=$mautrix_bridge_db_pwd
# Create postgresql database
ynh_psql_test_if_first_run
ynh_psql_create_user $mautrix_bridge_db_user $mautrix_bridge_db_pwd
ynh_psql_execute_as_root \
--sql="CREATE DATABASE ""$mautrix_bridge_db_name"" ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER ""$mautrix_bridge_db_user"";"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=3
### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
### downloaded from an upstream source, like a git repository.
### `ynh_setup_source` use the file conf/app.src
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# WARNING : theses command are used in INSTALL, UPGRADE (2 times)
# For any update do it in all files
#if [ -n "$(uname -m | grep 64)" ]
#then
# ynh_setup_source --dest_dir=$final_path/ --source_id="amd64_$(lsb_release --codename --short)"
#else
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path/src"
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
@ -153,41 +89,49 @@ ynh_setup_source --dest_dir="$final_path/src"
ynh_script_progression --message="Configuring system user..." --weight=1 ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user # Create a system user
ynh_system_user_create --username=$mautrix_bridge_user ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# SETUP SYSTEMD # CREATE A POSTGRESQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=20 ynh_script_progression --message="Creating a PostgreSQL database..." --weight=3
# Create systemd config for Mautrix-Bridge db_name=$(ynh_sanitize_dbid --db_name=$app)
#cp ../conf/default_mautrix-facebook /etc/default/$app db_user=$db_name
ynh_add_systemd_config --service=$app 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
#=================================================
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
ynh_setup_source --dest_dir="$final_path/src"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
#================================================= #=================================================
# SET MAUTRIX-BRIDGE CONFIG # SPECIFIC SETUP
#================================================= #=================================================
ynh_script_progression --message="Configuring Mautrix-Bridge..." --weight=2 # ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=2
# WARNING : theses command are used in INSTALL, UPGRADE, CONFIG, CHANGE-URL (4 times) ynh_add_config --template="../conf/config.yaml" --destination="$final_path/config.yaml"
# For any update do it in all files
mautrix_config_path="$final_path/config.yaml"
verify_server_ssl_certificates="true"
matrix_server_supports_asmux="false"
log_filename="/var/log/$app/$app.log"
# https://docs.python.org/3.6/library/logging.html#logging-levels
log_level="INFO"
ynh_add_config --template="../conf/config.yaml" --destination="$mautrix_config_path"
chmod 400 "$final_path/config.yaml"
chown $app:$app "$final_path/config.yaml"
#================================================= #=================================================
# INSTALL MAUTRIX-BRIDGE PYTHON MODULE # INSTALL MAUTRIX-BRIDGE PYTHON MODULE
#================================================= #=================================================
ynh_script_progression --message="Installing Mautrix-Bridge Python Module..." --weight=6
mkdir -p /var/log/$app mkdir -p /var/log/$app
# Configure Mautrix-Bridge # Configure Mautrix-Bridge
@ -195,38 +139,29 @@ python3 -m venv $final_path
export HOME=$final_path export HOME=$final_path
$final_path/bin/pip3 install --upgrade pip setuptools wheel $final_path/bin/pip3 install --upgrade pip setuptools wheel
$final_path/bin/pip3 install --upgrade $final_path/src/mautrix-facebook.tar.gz $final_path/bin/pip3 install --upgrade $final_path/src/mautrix-facebook.tar.gz
$final_path/bin/python3 -m mautrix_facebook -g -c $mautrix_config_path -r $app_service_registration_path/$app.yaml
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \
|| ynh_die "Synapse can't restart with the appservice configuration"
# Handled by synapse: synapse_ynh adds all registration files added in $app_service_registration_path to the app_service_config_files list
#================================================= #=================================================
# STORE THE CONFIG FILE CHECKSUM # REGISTER SYNAPSE APP-SERVICE
#================================================= #=================================================
ynh_script_progression --message="Registering Synapse app-service" --weight=1
### `ynh_store_file_checksum` is used to store the checksum of a file. $final_path/bin/python3 -m mautrix_facebook -g -c $final_path/config.yaml -r $synapse_registration_path/$app.yaml
### That way, during the upgrade script, by using `ynh_backup_if_checksum_is_different`, /opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die --message="Synapse can't restart with the appservice configuration"
### you can make a backup of this file before modifying it again if the admin had modified it.
# Calculate and store the config file checksum into the app settings chown -R $app:$app "$final_path"
ynh_store_file_checksum --file="$app_service_registration_path/$app.yaml" ynh_store_file_checksum --file="$synapse_registration_path/$app.yaml"
ynh_store_file_checksum --file="$mautrix_config_path" ynh_store_file_checksum --file="$final_path/config.yaml"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=20
# Create a dedicated systemd config
ynh_add_systemd_config
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
### For security reason, any app should set the permissions to root: before anything else.
### Then, if write authorization is needed, any access should be given only to directories
### that really need such authorization.
# WARNING : theses command are used in INSTALL, UPGRADE, RESTORE
# For any update do it in all files
chown $mautrix_bridge_user:root -R $final_path
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
@ -234,14 +169,14 @@ 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 --logfile "/var/log/$app/$app.log" ynh_use_logrotate --logfile "/var/log/$app/$app.log"
chown $mautrix_bridge_user:root -R /var/log/$app chown -R $app:$app /var/log/$app
#================================================= #=================================================
# ADVERTISE SERVICE IN ADMIN PANEL # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
#yunohost service add $app --log "/var/log/$app/log.log" ynh_script_progression --message="Integrating service in YunoHost..."
# if using yunohost version 3.2 or more in the 'manifest.json', a description can be added
yunohost service add $app --description="$app daemon for bridging FB and Matrix messages" --log="$log_filename" yunohost service add $app --description="$app daemon for bridging FB and Matrix messages" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -249,7 +184,7 @@ yunohost service add $app --description="$app daemon for bridging FB and Matrix
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" --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.)

View file

@ -16,47 +16,25 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# language=$(ynh_app_setting_get --app=$app --key=language)
server_name=$(ynh_app_setting_get --app=$app --key=server_name)
port=$(ynh_app_setting_get --app=$app --key=port)
botname=$(ynh_app_setting_get --app=$app --key=botname) botname=$(ynh_app_setting_get --app=$app --key=botname)
synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance) synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
app_service_registration_path=$(ynh_app_setting_get --app=$app --key=app_service_registration_path) server_name=$(ynh_app_setting_get --app=$app --key=server_name)
# bot_is_synapse_admin=$(ynh_app_setting_get --app=$app --key=bot_is_synapse_admin) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
encryption=$(ynh_app_setting_get --app=$app --key=encryption) db_user=$db_name
botadmin=$(ynh_app_setting_get --app=$app --key=botadmin) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
botusers=$(ynh_app_setting_get --app=$app --key=botusers) synapse_registration_path=$(ynh_app_setting_get --app=$app --key=synapse_registration_path)
mautrix_config_path="$final_path/config.yaml"
mautrix_version=$(ynh_app_setting_get --app=$app --key=mautrix_version)
mautrix_bridge_db_pwd=$(ynh_app_setting_get --app=$app --key=mautrix_bridge_db_pwd)
#=================================================
# SET CONSTANTS
#=================================================
botname_synapse_db_user="@$botname:$server_name"
synapse_db_name="matrix_$synapse_instance" synapse_db_name="matrix_$synapse_instance"
mautrix_bridge_user=$app
mautrix_bridge_db_name=$app
mautrix_bridge_db_user=$app
upstream_version=$(ynh_app_upstream_version)
log_filename="/var/log/$app/$app.log"
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#================================================= #=================================================
# REMOVE SERVICE FROM ADMIN PANEL # REMOVE SERVICE INTEGRATION IN YUNOHOST
#================================================= #=================================================
# Remove a service from the admin panel, added by `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..." --weight=3 ynh_script_progression --message="Removing $app service integration..." --weight=3
yunohost service remove $app yunohost service remove $app
fi fi
@ -68,26 +46,25 @@ ynh_script_progression --message="Stopping and removing the systemd service..."
# 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
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 database..." --weight=4
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user=$mautrix_bridge_db_name --db_name=$mautrix_bridge_db_user 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 ""$mautrix_bridge_user"";" 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 ""$mautrix_bridge_user"";" 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 ""$botname"";" 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 USER ""$botname"";"
#yunohost app action run $synapse_instance drop_user -a username=$facebookbot
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=8
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
@ -98,23 +75,23 @@ ynh_script_progression --message="Removing app main directory..." --weight=1
ynh_secure_remove --file="$final_path" ynh_secure_remove --file="$final_path"
#================================================= #=================================================
# REMOVE LOGROTATE CONFIGURATION # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1 ynh_script_progression --message="Removing dependencies..." --weight=8
# Remove the app-specific logrotate config # Remove metapackage and its dependencies
ynh_remove_logrotate ynh_remove_app_dependencies
#================================================= #=================================================
# SPECIFIC REMOVE # SPECIFIC REMOVE
#================================================= #=================================================
ynh_script_progression --message="Removing synapse app service..." --weight=6 # REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..." --weight=6
# Remove a directory securely # Remove a directory securely
ynh_secure_remove --file="$app_service_registration_path/$app.yaml" ynh_secure_remove --file="$synapse_registration_path/$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 "Synapse can't restart with the appservice configuration"
# Remove the log files # Remove the log files
ynh_secure_remove --file="/var/log/$app" ynh_secure_remove --file="/var/log/$app"
@ -127,7 +104,7 @@ ynh_secure_remove --file="/var/log/$app"
ynh_script_progression --message="Removing the dedicated system user..." --weight=5 ynh_script_progression --message="Removing the dedicated system user..." --weight=5
# Delete a system user # Delete a system user
ynh_system_user_delete --username=$mautrix_bridge_user ynh_system_user_delete --username=$app
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_clean_setup () { ynh_clean_setup () {
#### Remove this function if there's nothing to clean before calling the remove script.
true true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
@ -29,27 +28,13 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# language=$(ynh_app_setting_get --app=$app --key=language) 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) server_name=$(ynh_app_setting_get --app=$app --key=server_name)
botname=$(ynh_app_setting_get --app=$app --key=botname) botname=$(ynh_app_setting_get --app=$app --key=botname)
synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance) synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
app_service_registration_path=$(ynh_app_setting_get --app=$app --key=app_service_registration_path) synapse_registration_path=$(ynh_app_setting_get --app=$app --key=synapse_registration_path)
mautrix_config_path="$final_path/config.yaml"
mautrix_bridge_db_pwd=$(ynh_app_setting_get --app=$app --key=mautrix_bridge_db_pwd)
#=================================================
# SET CONSTANTS
#=================================================
botname_synapse_db_user="@$botname:$server_name"
synapse_db_name="matrix_$synapse_instance" synapse_db_name="matrix_$synapse_instance"
mautrix_bridge_user=$app
mautrix_bridge_db_name=$app
mautrix_bridge_db_user=$app
upstream_version=$(ynh_app_upstream_version)
log_filename="/var/log/$app/$app.log"
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
@ -61,6 +46,14 @@ test ! -d $final_path \
#================================================= #=================================================
# STANDARD RESTORATION STEPS # 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
#================================================= #=================================================
@ -68,20 +61,9 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$final_path"
#================================================= chmod 750 "$final_path"
# RECREATE THE DEDICATED USER chmod -R o-rwx "$final_path"
#================================================= chown -R $app:$app "$final_path"
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$mautrix_bridge_user
#=================================================
# RESTORE USER RIGHTS
#=================================================
# Restore permissions on app files
chown $mautrix_bridge_user:root -R $final_path
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
@ -91,24 +73,25 @@ chown $mautrix_bridge_user:root -R $final_path
ynh_script_progression --message="Reinstalling dependencies..." --weight=1 ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies # Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# 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_test_if_first_run
ynh_psql_create_user $mautrix_bridge_db_user $mautrix_bridge_db_pwd db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
ynh_psql_execute_as_root \ ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
--sql="CREATE DATABASE ""$mautrix_bridge_db_name"" ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER ""$mautrix_bridge_db_user"";" ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
ynh_psql_execute_file_as_root --file="${YNH_CWD}/dump.sql" --database="$mautrix_bridge_db_name"
#================================================= #=================================================
# RESTORE MAUTRIX-BRIDGE PYTHON MODULE # INSTALL MAUTRIX-BRIDGE PYTHON MODULE
#================================================= #=================================================
ynh_script_progression --message="Installing Mautrix-Bridge Python Module..." --weight=6
ynh_restore_file --origin_path="/var/log/$app" mkdir -p /var/log/$app
# Configure Mautrix-Bridge
python3 -m venv $final_path python3 -m venv $final_path
export HOME=$final_path export HOME=$final_path
$final_path/bin/pip3 install --upgrade pip setuptools wheel $final_path/bin/pip3 install --upgrade pip setuptools wheel
@ -116,11 +99,10 @@ $final_path/bin/pip3 install --upgrade pip setuptools wheel
#================================================= #=================================================
# REGISTER SYNAPSE APP-SERVICE # REGISTER SYNAPSE APP-SERVICE
#================================================= #=================================================
$final_path/bin/python3 -m mautrix_facebook -g -c $mautrix_config_path -r $app_service_registration_path/$app.yaml ynh_script_progression --message="Registering Synapse app-service" --weight=1
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \ $final_path/bin/python3 -m mautrix_facebook -g -c $final_path/config.yaml -r $synapse_registration_path/$app.yaml
|| 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"
# Handled by synapse: synapse_ynh adds all registration files added in $app_service_registration_path to the app_service_config_files list
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
@ -133,16 +115,16 @@ systemctl enable $app.service --quiet
#================================================= #=================================================
# RESTORE THE LOGROTATE CONFIGURATION # RESTORE THE LOGROTATE CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
ynh_use_logrotate --logfile "/var/log/$app/$app.log" ynh_restore_file --origin_path="/etc/logrotate.d/$app"
chown $mautrix_bridge_user:root -R /var/log/$app
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="$app daemon for bridging FB and Matrix messages" --log="$log_filename" yunohost service add $app --description="$app daemon for bridging FB and Matrix messages" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -150,7 +132,7 @@ yunohost service add $app --description="$app daemon for bridging FB and Matrix
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" --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.)
@ -161,8 +143,6 @@ sleep 30
# fi # fi
ynh_systemd_action --service_name=$app --action="restart" ynh_systemd_action --service_name=$app --action="restart"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -16,75 +16,32 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# language=$(ynh_app_setting_get --app=$app --key=language)
server_name=$(ynh_app_setting_get --app=$app --key=server_name)
port=$(ynh_app_setting_get --app=$app --key=port)
botname=$(ynh_app_setting_get --app=$app --key=botname) botname=$(ynh_app_setting_get --app=$app --key=botname)
synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
app_service_registration_path=$(ynh_app_setting_get --app=$app --key=app_service_registration_path)
# bot_is_synapse_admin=$(ynh_app_setting_get --app=$app --key=bot_is_synapse_admin)
encryption=$(ynh_app_setting_get --app=$app --key=encryption) encryption=$(ynh_app_setting_get --app=$app --key=encryption)
botadmin=$(ynh_app_setting_get --app=$app --key=botadmin) botadmin=$(ynh_app_setting_get --app=$app --key=botadmin)
botusers=$(ynh_app_setting_get --app=$app --key=botusers) botusers=$(ynh_app_setting_get --app=$app --key=botusers)
mautrix_config_path="$final_path/config.yaml" domain=$(ynh_app_setting_get --app=$app --key=domain)
mautrix_version=$(ynh_app_setting_get --app=$app --key=mautrix_version) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
mautrix_bridge_db_pwd=$(ynh_app_setting_get --app=$app --key=mautrix_bridge_db_pwd) db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
#================================================= port=$(ynh_app_setting_get --app=$app --key=port)
# SET CONSTANTS synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
#================================================= server_name=$(ynh_app_setting_get --app=$app --key=server_name)
synapse_registration_path=$(ynh_app_setting_get --app=$app --key=synapse_registration_path)
botname_synapse_db_user="@$botname:$server_name"
synapse_db_name="matrix_$synapse_instance" synapse_db_name="matrix_$synapse_instance"
mautrix_bridge_user=$app
mautrix_bridge_db_name=$app
mautrix_bridge_db_user=$app
upstream_version=$(ynh_app_upstream_version)
log_filename="/var/log/$app/$app.log"
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
ynh_script_progression --message="Checking version..." --weight=1
### This helper will compare the version of the currently installed app and the version of the upstream package.
### $upgrade_type can have 2 different values
### - UPGRADE_APP if the upstream app version has changed
### - UPGRADE_PACKAGE if only the YunoHost package has changed
### ynh_check_app_version_changed will stop the upgrade if the app is up to date.
### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do.
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
#
# N.B. : the followings setting migrations snippets are provided as *EXAMPLES*
# of what you may want to do in some cases (e.g. a setting was not defined on
# some legacy installs and you therefore want to initiaze stuff during upgrade)
#
# If db_name doesn't exist, create it
#if [ -z "$db_name" ]; then
# db_name=$(ynh_sanitize_dbid --db_name=$app)
# ynh_app_setting_set --app=$app --key=db_name --value=$db_name
#fi
# If final_path doesn't exist, create it
#if [ -z "$final_path" ]; then
# final_path=/var/www/$app
# ynh_app_setting_set --app=$app --key=final_path --value=$final_path
#fi
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=5
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
@ -102,7 +59,20 @@ ynh_abort_if_errors
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="$log_filename" ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
#=================================================
# 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"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -116,26 +86,51 @@ then
ynh_setup_source --dest_dir="$final_path/src" ynh_setup_source --dest_dir="$final_path/src"
fi fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=1 ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#=================================================
# 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=$mautrix_bridge_user
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
#================================================= #=================================================
# ... # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=2
ynh_add_config --template="../conf/config.yaml" --destination="$final_path/config.yaml"
chmod 400 "$final_path/config.yaml"
chown $app:$app "$final_path/config.yaml"
#=================================================
# UPGRADE MAUTRIX-BRIDGE PYTHON MODULE
#=================================================
ynh_script_progression --message="Upgrading Mautrix-Bridge Python Module..." --weight=2
python3 -m venv $final_path
export HOME=$final_path
$final_path/bin/pip3 install --upgrade pip setuptools wheel
$final_path/bin/pip3 install --upgrade $final_path/src/mautrix-facebook.tar.gz
#=================================================
# REGISTER SYNAPSE APP-SERVICE
#=================================================
ynh_script_progression --message="Registering Synapse app-service" --weight=1
$final_path/bin/python3 -m mautrix_facebook -g -c $final_path/config.yaml -r $synapse_registration_path/$app.yaml
/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
chown -R $app:$app "$final_path"
ynh_store_file_checksum --file="$synapse_registration_path/$app.yaml"
ynh_store_file_checksum --file="$final_path/config.yaml"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
@ -145,68 +140,23 @@ ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
#=================================================
# SET MAUTRIX-BRIDGE CONFIG
#=================================================
ynh_script_progression --message="Configuring Mautrix-Bridge..." --weight=2
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
ynh_backup_if_checksum_is_different --file="$app_service_registration_path/$app.yaml"
ynh_backup_if_checksum_is_different --file="$mautrix_config_path"
verify_server_ssl_certificates="true"
matrix_server_supports_asmux="false"
# https://docs.python.org/3.6/library/logging.html#logging-levels
log_level="INFO"
ynh_add_config --template="../conf/config.yaml" --destination="$mautrix_config_path"
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$app_service_registration_path/$app.yaml"
ynh_store_file_checksum --file="$mautrix_config_path"
#=================================================
# UPGRADE MAUTRIX-BRIDGE PYTHON MODULE
#=================================================
ynh_script_progression --message="Upgrading Mautrix-Bridge..." --weight=2
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
$final_path/bin/pip3 install --upgrade $final_path/src/mautrix-facebook.tar.gz
$final_path/bin/python3 -m mautrix_facebook -g -c $mautrix_config_path -r $app_service_registration_path/$app.yaml
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \
|| ynh_die "Synapse can't restart with the appservice configuration"
# Handled by synapse: synapse_ynh adds all registration files added in $app_service_registration_path to the app_service_config_files list
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions on app files
chown $mautrix_bridge_user:root -R $final_path
#=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate --logfile "$log_filename" ynh_use_logrotate --logfile "/var/log/$app/$app.log"
chown $mautrix_bridge_user:root -R /var/log/$app chown -R $app:$app /var/log/$app
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="$app daemon for bridging FB and Matrix messages" --log="$log_filename" yunohost service add $app --description="$app daemon for bridging FB and Matrix messages" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE