mirror of
https://github.com/YunoHost-Apps/mautrix_facebook_ynh.git
synced 2024-09-03 19:36:33 +02:00
Manifest v2
This commit is contained in:
parent
7764e6c25b
commit
c19afa3ba3
17 changed files with 261 additions and 715 deletions
107
.github/workflows/updater.sh
vendored
107
.github/workflows/updater.sh
vendored
|
@ -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/$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
49
.github/workflows/updater.yml
vendored
|
@ -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@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
|
|
|
@ -1,33 +0,0 @@
|
||||||
;; Default test serie
|
|
||||||
; 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)
|
|
||||||
bot_synapse_adm=0
|
|
||||||
synapsenumber="1"
|
|
||||||
botname="facebookbot"
|
|
||||||
encryption=0
|
|
||||||
botadmin="@johndoe:synapsedomain.tld" (USER)
|
|
||||||
botusers="@johndoe:synapsedomain.tld"
|
|
||||||
; Checks
|
|
||||||
pkg_linter=1
|
|
||||||
setup_sub_dir=0
|
|
||||||
setup_root=0
|
|
||||||
setup_nourl=1
|
|
||||||
setup_private=0
|
|
||||||
setup_public=0
|
|
||||||
upgrade=1
|
|
||||||
# 0.2.0
|
|
||||||
upgrade=1 from_commit=c11342a1f14fe8b287dfcb025f8f8196b9097175
|
|
||||||
# 0.3.3~ynh1
|
|
||||||
upgrade=1 from_commit=95aae535122b98bd94c410e040891b81b15bd654
|
|
||||||
backup_restore=1
|
|
||||||
multi_instance=1
|
|
||||||
port_already_use=1
|
|
||||||
change_url=0
|
|
||||||
actions=0
|
|
||||||
config_panel=0
|
|
||||||
;;; Upgrade options
|
|
||||||
; commit=01514cf02f52773a8164d512d59687c121852152
|
|
||||||
name=0.2.0
|
|
|
@ -1,7 +0,0 @@
|
||||||
SOURCE_URL=https://github.com/mautrix/facebook/archive/v0.5.1.tar.gz
|
|
||||||
SOURCE_SUM=28fa1367c1108554e155b9b061adb6023fbde949b836db640bd74f5e88bf6249
|
|
||||||
SOURCE_SUM_PRG=sha256sum
|
|
||||||
SOURCE_FORMAT=tar.gz
|
|
||||||
SOURCE_IN_SUBDIR=true
|
|
||||||
SOURCE_FILENAME=mautrix-facebook.tar.gz
|
|
||||||
SOURCE_EXTRACT=false
|
|
|
@ -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_facebook
|
ExecStart=__INSTALL_DIR__/bin/python3 -m mautrix_facebook
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
|
@ -3,9 +3,11 @@
|
||||||
* Ask on one of the following rooms: #mautrix_yunohost:matrix.fdn.fr or #facebook:maunium.net
|
* Ask on one of the following rooms: #mautrix_yunohost:matrix.fdn.fr or #facebook:maunium.net
|
||||||
|
|
||||||
## Bridging usage
|
## 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. **
|
|
||||||
|
**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
|
### 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)
|
* 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)
|
* 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)
|
* If the Bot does bot accept, see the [troubleshooting page](https://docs.mau.fi/bridges/general/troubleshooting.html)
|
||||||
|
@ -17,13 +19,14 @@
|
||||||
See also [upstream wiki Authentication page](https://docs.mau.fi/bridges/python/facebook/authentication.html)
|
See also [upstream wiki Authentication page](https://docs.mau.fi/bridges/python/facebook/authentication.html)
|
||||||
|
|
||||||
### Double puppeting
|
### Double puppeting
|
||||||
|
|
||||||
* First login as described in the previous section
|
* 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``
|
* 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.
|
* 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.
|
* 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
|
### Relaybot: Bridge a group for several Matrix and several Facebook users to chat together
|
||||||
|
|
||||||
Not yet available
|
Not yet available
|
||||||
|
|
||||||
## Configuration of the bridge
|
## Configuration of the bridge
|
||||||
|
@ -35,15 +38,15 @@ and then restarting the mautrix_facebook service.
|
||||||
|
|
||||||
## 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 Facebook bot is a local Matrix-Synapse user, but accessible through federation (synapse public or private).
|
* 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.
|
* 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.
|
* 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
|
* 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 Facebook 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 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.
|
* 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.
|
||||||
|
@ -57,4 +60,4 @@ and then restarting the mautrix_facebook service.
|
||||||
* Other info you would like to add about this app.
|
* Other info you would like to add about this app.
|
||||||
|
|
||||||
**More info on the documentation page:**
|
**More info on the documentation page:**
|
||||||
https://docs.mau.fi/bridges/python/facebook/index.html
|
<https://docs.mau.fi/bridges/python/facebook/index.html>
|
|
@ -3,9 +3,11 @@
|
||||||
* Demandez sur un des salons suivants: #mautrix_yunohost:matrix.fdn.fr or #facebook:maunium.net
|
* Demandez sur un des salons suivants: #mautrix_yunohost:matrix.fdn.fr or #facebook:maunium.net
|
||||||
|
|
||||||
## Usages de la passerelle
|
## 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. **
|
|
||||||
|
**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
|
### 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)
|
* 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.
|
* 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".
|
* Ce nouveau salon d'administration du Robot Mautrix-Messenger est appelé "Administration Room".
|
||||||
|
@ -15,25 +17,27 @@ Voir aussi [upstream wiki Authentication page](https://docs.mau.fi/bridges/pytho
|
||||||
#### Relier la passerelle comme un appareil secondaire
|
#### 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
|
### 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
|
* 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_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:
|
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```
|
```sudo nano /opt/yunohost/mautrix_facebook/config.yaml```
|
||||||
puis en redémarrant le service:
|
puis en redémarrant le service:
|
||||||
``` sudo yunohost service restart mautrix_facebook```
|
```sudo yunohost service restart mautrix_facebook```
|
||||||
|
|
||||||
## 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 Messenger est un utilisateur Matrix-Synapse local, mais accessible via la fédération (Synapse public ou privé).
|
* 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.
|
* 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).
|
* 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
|
* 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 Messenger.
|
* 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.
|
* 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.
|
|
@ -1,4 +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.
|
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é.
|
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!**
|
**Attention : sauvegardez et restaurez toujours les deux applications Yunohost matrix-synapse et mautrix_facebook en même temps!**
|
||||||
|
|
103
manifest.json
103
manifest.json
|
@ -1,103 +0,0 @@
|
||||||
{
|
|
||||||
"name": "Matrix-Facebook bridge",
|
|
||||||
"id": "mautrix_facebook",
|
|
||||||
"packaging_format": 1,
|
|
||||||
"description": {
|
|
||||||
"en": "Facebook puppeting bridge for Matrix/Synapse.",
|
|
||||||
"fr": "Passerelle Facebook pour Matrix/Synapse."
|
|
||||||
},
|
|
||||||
"version": "0.5.1~ynh1",
|
|
||||||
"url": "https://github.com/mautrix/facebook",
|
|
||||||
"upstream": {
|
|
||||||
"license": "AGPL-3.0-or-later",
|
|
||||||
"admindoc": "https://docs.mau.fi/bridges/python/setup/index.html?bridge=facebook",
|
|
||||||
"userdoc": "https://docs.mau.fi/bridges/python/facebook/index.html",
|
|
||||||
"code": "https://github.com/mautrix/facebook"
|
|
||||||
},
|
|
||||||
"license": "AGPL-3.0-or-later",
|
|
||||||
"maintainer": {
|
|
||||||
"name": "Gredin67",
|
|
||||||
"email": "mautrix_facebook_ynh@sans-nuage.fr",
|
|
||||||
"url": "https://github.com/YunoHost-Apps/mautrix_facebook_ynh"
|
|
||||||
},
|
|
||||||
"requirements": {
|
|
||||||
"yunohost": ">= 11.1"
|
|
||||||
},
|
|
||||||
"multi_instance": true,
|
|
||||||
"services": [
|
|
||||||
"postgresql"
|
|
||||||
],
|
|
||||||
"arguments": {
|
|
||||||
"install": [
|
|
||||||
{
|
|
||||||
"name": "synapsenumber",
|
|
||||||
"type": "string",
|
|
||||||
"ask": {
|
|
||||||
"en": "Choose the local synapse instance number to communicate with mautrix_facebook",
|
|
||||||
"fr": "Choisissez le numéro de l'instance synapse qui doit communiquer avec mautrix_facebook"
|
|
||||||
},
|
|
||||||
"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 Facebook bot",
|
|
||||||
"fr": "Choisissez un nom d'utilisateur synapse local pour le robot Facebook"
|
|
||||||
},
|
|
||||||
"example": "facebookbot",
|
|
||||||
"help": {
|
|
||||||
"en": "A system user will be created. Invite @facebookbot: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 @facebookbot:localsynapse.servername depuis un compte Matrix autorisé pour démarrer une passerelle. Donner le nom du serveur matrix, pas le domaine/url complet."
|
|
||||||
},
|
|
||||||
"default": "facebookbot"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "encryption",
|
|
||||||
"type": "boolean",
|
|
||||||
"ask": {
|
|
||||||
"en": "Enable end-to-bridge encryption ?",
|
|
||||||
"fr": "Activer le chiffrement entre synapse et le bridge ?"
|
|
||||||
},
|
|
||||||
"help": {
|
|
||||||
"en": "Only activate if you know the prerequisites and constraints related to e2b.",
|
|
||||||
"fr": "N'activer que si vous connaissez les prérequis et constraintes liées à e2b."
|
|
||||||
},
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "botadmin",
|
|
||||||
"type": "string",
|
|
||||||
"ask": {
|
|
||||||
"en": "Choose the Matrix account administrator of the Facebook bot",
|
|
||||||
"fr": "Choisissez le compte Matrix administrateur du robot Facebook"
|
|
||||||
},
|
|
||||||
"example": "@johndoe:localsynapse.servername or @johndoe:matrix.org",
|
|
||||||
"help": {
|
|
||||||
"en": "The Facebook bot administrator does not need to be a local synapse account.",
|
|
||||||
"fr": "Le compte administrateur du robot Facebook 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 Facebook bot",
|
|
||||||
"fr": "Choisissez le/les compte(s) Matrix autorisés à utiliser le robot Facebook"
|
|
||||||
},
|
|
||||||
"example": "local or @johndoe:server.name or server.name or *",
|
|
||||||
"default": "local",
|
|
||||||
"help": {
|
|
||||||
"en": "All local synapse users (local), 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": "On peut autoriser tous les comptes synapse locaux (local), 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."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
95
manifest.toml
Normal file
95
manifest.toml
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
|
||||||
|
|
||||||
|
packaging_format = 2
|
||||||
|
|
||||||
|
id = "mautrix_facebook"
|
||||||
|
name = "Matrix-Facebook bridge"
|
||||||
|
description.en = "Facebook puppeting bridge for Matrix/Synapse."
|
||||||
|
description.fr = "Passerelle Facebook pour Matrix/Synapse."
|
||||||
|
|
||||||
|
version = "0.5.1~ynh1"
|
||||||
|
|
||||||
|
maintainers = ["Gredin67"]
|
||||||
|
|
||||||
|
[upstream]
|
||||||
|
license = "AGPL-3.0-or-later"
|
||||||
|
admindoc = "https://docs.mau.fi/bridges/python/setup/index.html?bridge=facebook"
|
||||||
|
userdoc = "https://docs.mau.fi/bridges/python/facebook/index.html"
|
||||||
|
code = "https://github.com/mautrix/facebook"
|
||||||
|
fund = "https://github.com/sponsors/tulir"
|
||||||
|
|
||||||
|
[integration]
|
||||||
|
yunohost = ">= 11.1"
|
||||||
|
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_facebook"
|
||||||
|
ask.fr = "Choisissez le numéro de l'instance synapse qui doit communiquer avec mautrix_facebook"
|
||||||
|
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 Facebook bot"
|
||||||
|
ask.fr = "Choisissez un nom d'utilisateur synapse local pour le robot Facebook"
|
||||||
|
help.en = "A system user will be created. Invite @facebookbot: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 @facebookbot: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 = "facebookbot"
|
||||||
|
default = "facebookbot"
|
||||||
|
|
||||||
|
[install.encryption]
|
||||||
|
ask.en = "Enable end-to-bridge encryption ?"
|
||||||
|
ask.fr = "Activer le chiffrement entre synapse et le bridge ?"
|
||||||
|
help.en = "Only activate if you know the prerequisites and constraints related to e2b."
|
||||||
|
help.fr = "N'activer que si vous connaissez les prérequis et constraintes liées à e2b."
|
||||||
|
type = "boolean"
|
||||||
|
default = false
|
||||||
|
|
||||||
|
[install.botadmin]
|
||||||
|
ask.en = "Choose the Matrix account administrator of the Facebook bot"
|
||||||
|
ask.fr = "Choisissez le compte Matrix administrateur du robot Facebook"
|
||||||
|
help.en = "The Facebook bot administrator does not need to be a local synapse account."
|
||||||
|
help.fr = "Le compte administrateur du robot Facebook 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 Facebook bot"
|
||||||
|
ask.fr = "Choisissez le/les compte(s) Matrix autorisés à utiliser le robot Facebook"
|
||||||
|
help.en = "All local synapse users (local), 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 = "On peut autoriser tous les comptes synapse locaux (local), 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 = "local or @johndoe:server.name or server.name or *"
|
||||||
|
default = "local"
|
||||||
|
|
||||||
|
[resources]
|
||||||
|
[resources.sources.main]
|
||||||
|
url = "https://github.com/mautrix/facebook/archive/v0.5.1.tar.gz"
|
||||||
|
sha256 = "28fa1367c1108554e155b9b061adb6023fbde949b836db640bd74f5e88bf6249"
|
||||||
|
|
||||||
|
|
||||||
|
[resources.system_user]
|
||||||
|
|
||||||
|
[resources.install_dir]
|
||||||
|
|
||||||
|
[resources.permissions]
|
||||||
|
|
||||||
|
[resources.ports]
|
||||||
|
main.default = 8449
|
||||||
|
|
||||||
|
[resources.apt]
|
||||||
|
packages = "postgresql, python3"
|
||||||
|
|
||||||
|
[resources.database]
|
||||||
|
type = "postgresql"
|
|
@ -4,13 +4,25 @@
|
||||||
# COMMON VARIABLES
|
# COMMON VARIABLES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# dependencies used by the app (must be on a single line)
|
|
||||||
pkg_dependencies="postgresql python3"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
_mautrix_facebook_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-facebook.tar.gz"
|
||||||
|
}
|
||||||
|
|
||||||
|
_mautrix_facebook_register_synapse() {
|
||||||
|
"$install_dir/venv/bin/python3" -m mautrix_facebook -g -c "$install_dir/config.yaml" -r "$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"
|
||||||
|
|
||||||
|
chown -R "$app:$app" "$install_dir"
|
||||||
|
ynh_store_file_checksum --file="$synapse_registration_path/$app.yaml"
|
||||||
|
ynh_store_file_checksum --file="$install_dir/config.yaml"
|
||||||
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# EXPERIMENTAL HELPERS
|
# EXPERIMENTAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -10,26 +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)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -39,21 +19,21 @@ 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/systemd/system/$app.service"
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP SYSTEMD
|
# BACKUP VARIOUS FILES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
ynh_backup --src_path="/var/log/$app/"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE POSTGRESQL DATABASE
|
# BACKUP THE POSTGRESQL DATABASE
|
||||||
|
|
145
scripts/install
145
scripts/install
|
@ -9,28 +9,6 @@
|
||||||
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
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
synapsenumber=$YNH_APP_ARG_SYNAPSENUMBER
|
|
||||||
botname=$YNH_APP_ARG_BOTNAME
|
|
||||||
encryption=$YNH_APP_ARG_ENCRYPTION
|
|
||||||
botadmin=$YNH_APP_ARG_BOTADMIN
|
|
||||||
botusers=$YNH_APP_ARG_BOTUSERS
|
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -43,148 +21,69 @@ domain=$(ynh_app_setting_get --app $synapse_instance --key domain)
|
||||||
synapse_registration_path="/etc/matrix-$synapse_instance/app-service"
|
synapse_registration_path="/etc/matrix-$synapse_instance/app-service"
|
||||||
synapse_db_name="matrix_$synapse_instance"
|
synapse_db_name="matrix_$synapse_instance"
|
||||||
|
|
||||||
#=================================================
|
ynh_app_setting_set --app="$app" --key="encryption" --value="$encryption"
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
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_script_progression --message="Validating installation parameters..." --weight=1
|
ynh_app_setting_set --app="$app" --key="domain" --value="$domain"
|
||||||
|
ynh_app_setting_set --app="$app" --key="synapse_registration_path" --value="$synapse_registration_path"
|
||||||
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=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=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
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Installing dependencies..." --weight=97
|
|
||||||
|
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CREATE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Configuring system user..." --weight=1
|
|
||||||
|
|
||||||
# Create a system user
|
|
||||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# 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
|
_mautrix_facebook_build_venv
|
||||||
# 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
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# 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_facebook -g -c $final_path/config.yaml -r $synapse_registration_path/$app.yaml
|
_mautrix_facebook_register_synapse
|
||||||
/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"
|
|
||||||
ynh_store_file_checksum --file="$synapse_registration_path/$app.yaml"
|
|
||||||
ynh_store_file_checksum --file="$final_path/config.yaml"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SYSTEM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring a systemd service..." --weight=20
|
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 FB 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 --logfile "/var/log/$app/$app.log"
|
ynh_use_logrotate --logfile "/var/log/$app/$app.log"
|
||||||
chown -R $app:$app /var/log/$app
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..."
|
|
||||||
|
|
||||||
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
|
||||||
#=================================================
|
#=================================================
|
||||||
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.)
|
||||||
|
@ -193,7 +92,7 @@ sleep 30
|
||||||
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=$facebookbot
|
# #yunohost app action run $synapse_instance set_admin_user -a username=$facebookbot
|
||||||
# fi
|
# fi
|
||||||
ynh_systemd_action --service_name=$app --action="restart"
|
ynh_systemd_action --service_name="$app" --action="restart"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
|
@ -12,75 +12,45 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
botname=$(ynh_app_setting_get --app=$app --key=botname)
|
#REMOVEME? botname=$(ynh_app_setting_get --app=$app --key=botname)
|
||||||
synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
|
#REMOVEME? synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
|
||||||
server_name=$(ynh_app_setting_get --app=$app --key=server_name)
|
#REMOVEME? server_name=$(ynh_app_setting_get --app=$app --key=server_name)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
#REMOVEME? db_user=$db_name
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||||
synapse_registration_path=$(ynh_app_setting_get --app=$app --key=synapse_registration_path)
|
#REMOVEME? synapse_registration_path=$(ynh_app_setting_get --app=$app --key=synapse_registration_path)
|
||||||
synapse_db_name="matrix_$synapse_instance"
|
synapse_db_name="matrix_$synapse_instance"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# 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
|
yunohost service remove "$app"
|
||||||
ynh_script_progression --message="Removing $app service integration..." --weight=3
|
|
||||||
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 a database if it exists, along with the associated 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 ""$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 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"";"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# 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
|
||||||
|
@ -96,16 +66,6 @@ ynh_secure_remove --file="$synapse_registration_path/$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
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
104
scripts/restore
104
scripts/restore
|
@ -10,129 +10,71 @@
|
||||||
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
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
#REMOVEME? db_user=$db_name
|
||||||
server_name=$(ynh_app_setting_get --app=$app --key=server_name)
|
#REMOVEME? server_name=$(ynh_app_setting_get --app=$app --key=server_name)
|
||||||
botname=$(ynh_app_setting_get --app=$app --key=botname)
|
#REMOVEME? botname=$(ynh_app_setting_get --app=$app --key=botname)
|
||||||
synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
|
#REMOVEME? synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
|
||||||
synapse_registration_path=$(ynh_app_setting_get --app=$app --key=synapse_registration_path)
|
#REMOVEME? synapse_registration_path=$(ynh_app_setting_get --app=$app --key=synapse_registration_path)
|
||||||
synapse_db_name="matrix_$synapse_instance"
|
# synapse_db_name="matrix_$synapse_instance"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# 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
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# 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
|
# 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
|
_mautrix_facebook_build_venv
|
||||||
# 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
|
# 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_facebook -g -c $final_path/config.yaml -r $synapse_registration_path/$app.yaml
|
_mautrix_facebook_register_synapse
|
||||||
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die "Synapse can't restart with the appservice configuration"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE SYSTEMD
|
# RESTORE SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
|
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 FB 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 FB 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.)
|
||||||
|
@ -141,7 +83,7 @@ sleep 30
|
||||||
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=$facebookbot
|
# #yunohost app action run $synapse_instance set_admin_user -a username=$facebookbot
|
||||||
# fi
|
# fi
|
||||||
ynh_systemd_action --service_name=$app --action="restart"
|
ynh_systemd_action --service_name="$app" --action="restart"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
132
scripts/upgrade
132
scripts/upgrade
|
@ -12,46 +12,25 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
botname=$(ynh_app_setting_get --app=$app --key=botname)
|
#REMOVEME? botname=$(ynh_app_setting_get --app=$app --key=botname)
|
||||||
encryption=$(ynh_app_setting_get --app=$app --key=encryption)
|
#REMOVEME? encryption=$(ynh_app_setting_get --app=$app --key=encryption)
|
||||||
botadmin=$(ynh_app_setting_get --app=$app --key=botadmin)
|
#REMOVEME? botadmin=$(ynh_app_setting_get --app=$app --key=botadmin)
|
||||||
botusers=$(ynh_app_setting_get --app=$app --key=botusers)
|
#REMOVEME? botusers=$(ynh_app_setting_get --app=$app --key=botusers)
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
#REMOVEME? db_user=$db_name
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
|
#REMOVEME? synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
|
||||||
server_name=$(ynh_app_setting_get --app=$app --key=server_name)
|
#REMOVEME? server_name=$(ynh_app_setting_get --app=$app --key=server_name)
|
||||||
synapse_registration_path=$(ynh_app_setting_get --app=$app --key=synapse_registration_path)
|
#REMOVEME? synapse_registration_path=$(ynh_app_setting_get --app=$app --key=synapse_registration_path)
|
||||||
synapse_db_name="matrix_$synapse_instance"
|
synapse_db_name="matrix_$synapse_instance"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# 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
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -59,112 +38,67 @@ 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="/var/log/$app/$app.log"
|
ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
# 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
|
||||||
#=================================================
|
#=================================================
|
||||||
|
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=1
|
|
||||||
|
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# 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"
|
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"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# 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
|
_mautrix_facebook_build_venv
|
||||||
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
|
# 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_facebook -g -c $final_path/config.yaml -r $synapse_registration_path/$app.yaml
|
_mautrix_facebook_register_synapse
|
||||||
/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
|
# REAPPLY SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
|
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 FB 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 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 -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 FB 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"
|
ynh_systemd_action --service_name="$app" --action="start"
|
||||||
# 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.)
|
||||||
|
@ -173,7 +107,7 @@ sleep 30
|
||||||
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=$facebookbot
|
# #yunohost app action run $synapse_instance set_admin_user -a username=$facebookbot
|
||||||
# fi
|
# fi
|
||||||
ynh_systemd_action --service_name=$app --action="restart"
|
ynh_systemd_action --service_name="$app" --action="restart"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
16
tests.toml
Normal file
16
tests.toml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#: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.c11342a1f14fe8b287dfcb025f8f8196b9097175.name = "0.2.0"
|
||||||
|
test_upgrade_from.95aae535122b98bd94c410e040891b81b15bd654.name = "0.3.3~ynh1"
|
Loading…
Add table
Reference in a new issue