mirror of
https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh.git
synced 2024-09-03 19:46:01 +02:00
commit
08b03ab50f
29 changed files with 431 additions and 916 deletions
25
.github/workflows/updater.sh
vendored
25
.github/workflows/updater.sh
vendored
|
@ -14,8 +14,8 @@
|
|||
#=================================================
|
||||
|
||||
# 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]')
|
||||
current_version=$(yq ".version" manifest.toml | cut -d '~' -f 1 -)
|
||||
repo=$(yq ".upstream.code" manifest.toml | sed 's/https:\/\/github.com\///')
|
||||
# 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=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'"))
|
||||
|
@ -31,9 +31,9 @@ fi
|
|||
# Setting up the environment variables
|
||||
echo "Current version: $current_version"
|
||||
echo "Latest release from upstream: $version"
|
||||
echo "VERSION=$version" >> $GITHUB_ENV
|
||||
echo "VERSION=$version" >> "$GITHUB_ENV"
|
||||
# For the time being, let's assume the script will fail
|
||||
echo "PROCEED=false" >> $GITHUB_ENV
|
||||
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
|
||||
|
@ -91,15 +91,8 @@ curl --silent -4 -L $tarball -o "$tempdir/$version"
|
|||
checksum=$(sha256sum "$tempdir/$filename" | head -c 64)
|
||||
|
||||
# Rewrite source file
|
||||
cat <<EOT > conf/$src.src
|
||||
SOURCE_URL=$asset_url
|
||||
SOURCE_SUM=$checksum
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_IN_SUBDIR=false
|
||||
SOURCE_FILENAME=mautrix-whatsapp
|
||||
SOURCE_EXTRACT=false
|
||||
EOT
|
||||
echo "... conf/$src.src updated"
|
||||
sed -i "s|$src.url.*|src.url = \"$asset_url\"|g" manifest.toml
|
||||
sed -i "s|$src.sha256.*|$src.sha256 = \"$checksum\"|g" manifest.toml
|
||||
|
||||
else
|
||||
echo "... asset ignored"
|
||||
|
@ -107,6 +100,8 @@ fi
|
|||
|
||||
done
|
||||
|
||||
echo "manifest.toml assets updated"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPDATE STEPS
|
||||
#=================================================
|
||||
|
@ -148,7 +143,7 @@ yq -i '.bridge.encryption.require = "__ENCRYPTION_REQUIRE__"' $configFilePath
|
|||
yq -i 'with(.bridge.permissions ; . = { "__LISTRELAY__": "relay", "__LISTUSER__": "user", "__LISTADMIN__": "admin" } | ... style="double")' $configFilePath
|
||||
yq -i '.bridge.relay.enabled = "__ENABLE_RELAYBOT__"' $configFilePath
|
||||
yq -i '.bridge.relay.admin_only = "__ADMIN_ONLY__"' $configFilePath
|
||||
yq -i '.logging.writers.filename = "/var/log/__APP__/__APP__.log"' $configFilePath
|
||||
yq -i '.logging.writers[1].filename = "/var/log/__APP__/__APP__.log"' $configFilePath
|
||||
yq -i '.logging.min_level = "__PRINT_LEVEL__"' $configFilePath
|
||||
|
||||
#=================================================
|
||||
|
@ -156,7 +151,7 @@ yq -i '.logging.min_level = "__PRINT_LEVEL__"' $configFilePath
|
|||
#=================================================
|
||||
|
||||
# Replace new version in manifest
|
||||
echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json
|
||||
sed -i "s|version.*|version = \"$version~ynh1\"|g" manifest.toml
|
||||
|
||||
# Delete temporary directory
|
||||
rm -rf $tempdir
|
||||
|
|
105
README.md
105
README.md
|
@ -26,111 +26,6 @@ Therefore, [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh)
|
|||
|
||||
|
||||
**Shipped version:** 0.9.0~ynh1
|
||||
## Disclaimers / important information
|
||||
|
||||
## List of known public services
|
||||
|
||||
* Ask on one of the following rooms: #mautrix_yunohost:matrix.fdn.fr or #whatsapp:maunium.net
|
||||
|
||||
## Bridging usage
|
||||
** Note that several WhatsApp and Matrix users can be bridged, each WhatsApp account has its own bot administration room. If they are in a same WhatsApp group, only one matrix room will be created. **
|
||||
|
||||
### Bridge a WhatsApp user and a Matrix user
|
||||
* First your matrix user or server has to be authorized in the bridge configuration (see below)
|
||||
* Then, invite the bot (default @whatsappbot:yoursynapse.domain)
|
||||
* The room with the Mautrix-WhatsApp bot is called "administration room".
|
||||
* Type ``login``
|
||||
* Capture the QR code with the camera in the whatsapp of your VM or smartphone (WhatsApp Web)
|
||||
* Send ``help`` to the bot in the created room to know how to control the bot.
|
||||
See also [upstream wiki Authentication page](https://docs.mau.fi/bridges/go/whatsapp/authentication.html)
|
||||
|
||||
### Bridge an existing room | Bridge Whatsapp to Signal over Matrix
|
||||
By default, the bridge creates a portal room for each WA group that the WA user actively uses.
|
||||
Your can also create a portal for an existing Matrix room. **Note that this can be a room created by another bridge, e.g. a Signal portal room**
|
||||
1. Invite the bridge bot to the room (with an authorized user)
|
||||
2. type `!wa create`
|
||||
3. Your logged in WA user creates a new corresponding group.
|
||||
4. Get the WA invite link `!wa invite-link` and share it with friends. Or invite Whatsapp puppets to room.
|
||||
5. Optional: Activate relaybot, see next section.
|
||||
|
||||
### Relaybot: Bridge a group for several Matrix and several WhatsApp users to chat together
|
||||
**When upgrading from <v0.2.0, the relaybot system changed. There is no relaybot administration room anymore. Relay must be re-activated in all rooms**.
|
||||
|
||||
To be able to bridge not only your logged in Matrix account but also Matrix friends you invite to a portal room, you need to:
|
||||
1. enable relaybot setting in the bridge configuration `relay: enabled: true`
|
||||
2. login to your WhatsApp account in the (main) administration room
|
||||
3. write `!wa set-relay` in each of the rooms you want to relay to (re-)activate the relaybot function. By default, only bridge admin can do this, see setting `admin_only: true`
|
||||
|
||||
* In WhatsApp: all messages will be seen as received from the account who is logged in with a prefix for the source matrix user.
|
||||
* On the matrix side: the bridge will create matrix puppets corresponding to the WhatsApp users when they send a message.
|
||||
See also [upstream wiki Relaybot page](https://docs.mau.fi/bridges/general/relay-mode.html)
|
||||
|
||||
## Configuration of the bridge
|
||||
|
||||
The bridge is [roughly configured at installation](https://github.com/YunoHost-Apps/mautrix_whatsapp_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_whatsapp/config.yaml```
|
||||
and then restarting the mautrix_whatsapp service.
|
||||
|
||||
#### End-to-bridge encryption
|
||||
The bridge can optionally encrypt messages between Matrix users and the bridge to hide messages from the homeserver. Using Postgres is strongly recommended when using end-to-bridge encryption.
|
||||
|
||||
If you want to enable it, look for the option ```bridge → encryption``` in the config file. If you only set ```allow: true```, the bridge won't enable encryption on its own, but will work in encrypted rooms. If you set ```default: true```, the bridge will automatically enable encryption in new portals.
|
||||
There is also the possibility to set ```require: true``` to enforce encryption on any of the messages that you send (this will drop any unencrypted messages).
|
||||
|
||||
## 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 WhatsApp bot is a local Matrix-Synapse user, but accessible through federation (synapse public or private).
|
||||
* Several Signal and Matrix users can be bridged with one bridge, each user has its own bot administration room.
|
||||
* If several bot users are in a same WhatsApp 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 WhatsApp 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.
|
||||
|
||||
### Supported architectures
|
||||
|
||||
ARM, ARM64, AMD64
|
||||
|
||||
## Limitations
|
||||
|
||||
* Audio/Video calls are not bridged yet.
|
||||
* If WhatsApp loses connection, e.g. the phone is set in flight mode or push notifications are deactivated, the bot has sometimes to be restarted manually by sending a reconnnect message in the matrix administration room.
|
||||
|
||||
### Additional information
|
||||
|
||||
* It is recommended to install WhatsApp on a virtual android running on a server, see [upstream wiki Android-VM-Setup page](https://docs.mau.fi/bridges/go/whatsapp/android-vm-setup.html)
|
||||
**More information on the documentation page:**
|
||||
https://docs.mau.fi/bridges/go/whatsapp/index.html
|
||||
|
||||
To test communication between the App Service and Matrix-Synapse on a VM (e.g. with domain name: synapse.vm), you must install a certificate:
|
||||
```
|
||||
echo | openssl s_client -showcerts -servername synapse.vm -connect synapse.vm:443 2>/dev/null | awk '/-----BEGIN CERTIFICATE-----/, /-----END CERTIFICATE-----/' >> /usr/local/share/ca-certificates/synapse.vm.crt
|
||||
update-ca-certificates
|
||||
```
|
||||
|
||||
### Miscellaneous information
|
||||
|
||||
* Matrix room (matrix bridges in YunoHost): #mautrix_yunohost:matrix.fdn.fr
|
||||
* Matrix room (upstream app): #whatsapp:maunium.net
|
||||
In case you need to upload your logs somewhere, be aware that they contain your contacts' and your phone numbers. Strip them out with
|
||||
``| sed -r 's/[0-9]{10,}/📞/g' ``
|
||||
* "Mautrix-WhatsApp" bridge is based on the [Rhymen/go-whatsapp](https://github.com/Rhymen/go-whatsapp) implementation of the [sigalor/whatsapp-web-reveng](https://github.com/sigalor/whatsapp-web-reveng) project.
|
||||
|
||||
## Development code quality
|
||||
|
||||
The `.github/workflows/updater.sh` script needs to be synced with changes in `conf/config.yaml` therefore a `pre-commit`
|
||||
hook is used to display a reminder to update `.github/workflows/updater.sh` (if needed) when `conf/config.yaml` has been modified.
|
||||
|
||||
Please enable Git hooks using following command to ensure code quality and stability.
|
||||
``` bash
|
||||
git config --local core.hooksPath .githooks
|
||||
```
|
||||
## Documentation and resources
|
||||
|
||||
* Official app website: <https://maunium.net/go/mautrix-whatsapp/>
|
||||
|
|
89
README_fr.md
89
README_fr.md
|
@ -26,95 +26,6 @@ C'est pourquoi [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_y
|
|||
|
||||
|
||||
**Version incluse :** 0.9.0~ynh1
|
||||
## Avertissements / informations importantes
|
||||
|
||||
## Liste de passerelles publiques
|
||||
|
||||
* Demandez sur un des salons suivants: #mautrix_yunohost:matrix.fdn.fr or #whatsapp:maunium.net
|
||||
|
||||
## Usages de la passerelle
|
||||
** Notez que plusieurs comptes WhatsApp et Matrix peuvent être relayés, chaque compte WhatsApp connecté a son propre Salon d'Administration. Si plusieurs utilisateur.ice.s du Robot sont dans un même groupe WhatsApp, seul un Salon Matrix sera créé par la passerelle. **
|
||||
|
||||
### Relayer TOUTES les conversations entre UN compte WhatsApp 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 @whatsappbot:synapse.votredomaine) à une nouvelle conversation.
|
||||
* Ce nouveau salon d'administration du Robot Mautrix-WhatsApp est appelé "Administration Room".
|
||||
* Tapez ``login``
|
||||
* Scannez le QR-code avec la caméra Whatsapp de votre Machine Virtuelle ou ordiphone (option WhatsApp Web dans l'appli)
|
||||
* 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/go/whatsapp/authentication.html)
|
||||
|
||||
#### Robot-Relai "Relaybot": Relayer les conversations de TOUS les comptes Matrix et TOUS les comptes WhatsApp présents dans UN groupe/salon
|
||||
|
||||
* Prérequis : Créer un nouveau salon vide "Relaybot Administration Room" et rechercher son identifiant.
|
||||
* Activer l'option Robot-Relai "Relaybot" dans la configuration de la passerelle (default=disabled, voir ci-dessous) et ajouter l'identifiant du salon d'administration du Relaybot "Relaybot Administration Room".
|
||||
* Redémarrer le service mautrix_whatsapp
|
||||
* Vous pouvez maintenant relayer un groupe WhatsApp en y invitant le numéro de téléphone du compte WhatsApp connecté au RobotRelai. Côté WhatsApp, tous les messages venant de Matrix seront vus comme envoyés depuis le compte WhatsApp connecté, avec un préfix indiquant le compte Matrix correspondant. Côté Matrix, la passerelle va créer des comptes Matrix pour chaque compte WhatsApp présent dans le groupe relayé. Les messages sont indiqués comme provenant soit du numéro de téléphone, soit du pseudo WhatsApp.
|
||||
Voir aussi [la page wiki principale sur le Robot-Relai](https://docs.mau.fi/bridges/go/whatsapp/relaybot.html)
|
||||
|
||||
### 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_whatsapp_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_whatsapp/config.yaml```
|
||||
puis en redémarrant le service:
|
||||
``` sudo yunohost service restart mautrix_whatsapp```
|
||||
|
||||
#### End-to-bridge encryption
|
||||
Le robot peut éventuellement chiffrer les messages entre les utilisateurs de Matrix et la passarelle pour cacher les messages du serveur domestique. L'utilisation de Postgres est fortement recommandée lors de l'utilisation du chiffrement end-to-bridge.
|
||||
|
||||
Si vous voulez l'activer, cherchez l'option ```bridge → encryption``` dans le fichier de configuration. Si vous définissez uniquement l'option ``allow: true``, le robot n'activera pas le chiffrement de lui-même, mais travaillera dans les portails chiffrés. Si vous définissez ```default: true```, la passerelle activera automatiquement le chiffrement dans les nouveaux portails.
|
||||
Il y a également la possibilité de définir ```require: true``` pour imposer le chiffrement sur tous les messages que vous envoyez (cela interdira tous les messages non chiffrés).
|
||||
|
||||
### 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 WhatsApp est un utilisateur Matrix-Synapse local, mais accessible via la fédération (Synapse public ou privé).
|
||||
* Plusieurs comptes WhatsApp 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 WhatsApp, seul un Salon Matrix sera créé par la passerelle. Autrement dit, la passerelle construit un seul miroir du réseau de discussion existant sur WhatsApp (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 WhatsApp.
|
||||
* 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.
|
||||
|
||||
### Architectures supportées
|
||||
|
||||
ARM, ARM64, AMD64
|
||||
|
||||
### Limitations
|
||||
|
||||
* Les appels Audio/Video ne sont pas relayés. Seule une notification apparait.
|
||||
* Si WhatsApp perd la connexion, par ex. l'ordiphone est mis en mode avion ou les notifications poussées sont désactivées, le robot doit parfois être redémarré à la main en envoyant un message ``wa !reconnnect`` dans le salon d'administration.
|
||||
|
||||
### Informations additionnelles
|
||||
|
||||
* Il est recommandé d'installer WhatsApp sur une machine Android virtuelle tournant sur un serveur, cf. le [page Android-VM-Setup du wiki](https://docs.mau.fi/bridges/go/whatsapp/android-vm-setup.html)
|
||||
|
||||
Pour tester la communication entre le Service d'Application et Matrix-Synapse sur une Machine Virtuelle (ex. avec un nom de domaine: synapse.vm), vous devez installer un certificat:
|
||||
```
|
||||
echo | openssl s_client -showcerts -servername synapse.vm -connect synapse.vm:443 2>/dev/null | awk '/-----BEGIN CERTIFICATE-----/, /-----END CERTIFICATE-----/' >> /usr/local/share/ca-certificates/synapse.vm.crt
|
||||
update-ca-certificates
|
||||
```
|
||||
|
||||
### Informations diverses
|
||||
|
||||
* Salon Matrix sur les Passerelles dans Yunohost): #mautrix_yunohost:matrix.fdn.fr
|
||||
* Salon Matrix (application principale): #whatsapp:maunium.net
|
||||
Si vous devez téléverser vos fichiers log quelque-part, soyez avertis qu'ils contiennent des informations sur vos contacts et vos numéros de téléphone. Effacez-les avec
|
||||
``| sed -r 's/[0-9]{10,}/📞/g' ``
|
||||
* La passerelle "Mautrix-WhatsApp" repose sur l'implémentation [Rhymen/go-whatsapp](https://github.com/Rhymen/go-whatsapp) du projet [sigalor/whatsapp-web-reveng](https://github.com/sigalor/whatsapp-web-reveng).
|
||||
|
||||
## Development code quality
|
||||
|
||||
Le script `.github/workflows/updater.sh` doit être synchronisé avec les changements dans `conf/config.yaml`,
|
||||
donc un hook `pre-commit` est utilisé pour afficher un rappel pour mettre à jour
|
||||
`.github/workflows/updater.sh` (si nécessaire) lorsque `conf/config.yaml` a été modifié.
|
||||
|
||||
Veuillez activer les hooks Git en utilisant la commande suivante pour assurer la qualité et la stabilité du code.
|
||||
``` bash
|
||||
git config --local core.hooksPath .githooks
|
||||
```
|
||||
## Documentations et ressources
|
||||
|
||||
* Site officiel de l’app : <https://maunium.net/go/mautrix-whatsapp/>
|
||||
|
|
|
@ -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
|
||||
synapsenumber="1"
|
||||
whatsappbot="whatsappbot"
|
||||
bot_synapse_adm=0
|
||||
encryption=0
|
||||
botadmin="@johndoe:synapsedomain.tld"
|
||||
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.4.0
|
||||
upgrade=1 from_commit=717b32f454819c1bb936152c69d9693d34434741
|
||||
# 0.6.1
|
||||
upgrade=1 from_commit=fdd1e0ff652ae47b5e3c62477eea678c465659cf
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
;;; Options
|
||||
Email=
|
||||
Notification=none
|
||||
;;; Upgrade options
|
||||
; commit=717b32f454819c1bb936152c69d9693d34434741
|
||||
name=0.4.0
|
||||
; commit=fdd1e0ff652ae47b5e3c62477eea678c465659cf
|
||||
name=0.6.1
|
|
@ -1,6 +0,0 @@
|
|||
SOURCE_URL=https://github.com/mautrix/whatsapp/releases/download/v0.9.0/mautrix-whatsapp-amd64
|
||||
SOURCE_SUM=27b5d3ee0cada177207b662072b42923956e38a9c10c4e167eeca17881f3bffb
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_IN_SUBDIR=false
|
||||
SOURCE_FILENAME=mautrix-whatsapp
|
||||
SOURCE_EXTRACT=false
|
|
@ -1,6 +0,0 @@
|
|||
SOURCE_URL=https://github.com/mautrix/whatsapp/releases/download/v0.9.0/mautrix-whatsapp-arm64
|
||||
SOURCE_SUM=dc475a2af45988d6d428af18c5f2a30da24930201e0e667a0b749a198a3bd02d
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_IN_SUBDIR=false
|
||||
SOURCE_FILENAME=mautrix-whatsapp
|
||||
SOURCE_EXTRACT=false
|
|
@ -1,6 +0,0 @@
|
|||
SOURCE_URL=https://github.com/mautrix/whatsapp/releases/download/v0.9.0/mautrix-whatsapp-arm
|
||||
SOURCE_SUM=22c28d17ec868c4579e8ed64e092b0947a268c82ed9714d3ae45ace05b477fd8
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_IN_SUBDIR=false
|
||||
SOURCE_FILENAME=mautrix-whatsapp
|
||||
SOURCE_EXTRACT=false
|
|
@ -6,13 +6,13 @@ After=matrix-synapse.service
|
|||
Type=simple
|
||||
User=__APP__
|
||||
Group=__APP__
|
||||
WorkingDirectory=__FINALPATH__/
|
||||
ExecStart=__FINALPATH__/mautrix-whatsapp -c=__FINALPATH__/config.yaml
|
||||
WorkingDirectory=__INSTALL_DIR__/
|
||||
ExecStart=__INSTALL_DIR__/mautrix-whatsapp -c=__INSTALL_DIR__/config.yaml
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
|
||||
# Optional hardening to improve security
|
||||
ReadWritePaths=__FINALPATH__/ /var/log/__APP__
|
||||
ReadWritePaths=__INSTALL_DIR__/ /var/log/__APP__
|
||||
NoNewPrivileges=yes
|
||||
MemoryDenyWriteExecute=true
|
||||
PrivateDevices=yes
|
||||
|
|
|
@ -42,7 +42,7 @@ services = ["__APP__"]
|
|||
yes = "true"
|
||||
no = "false"
|
||||
help = "If allowed, '!wa set-relay' can be used to turn any Bridge User into a RelayBot for that chat. This allows people to talk on WhatsApp without an own account."
|
||||
bind = "relay>enabled:__FINALPATH__/config.yaml"
|
||||
bind = "relay>enabled:__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[main.bridge.admin_only]
|
||||
ask = "Should only Bridge Admins be allowed to set themselves as Relay Users?"
|
||||
|
@ -50,7 +50,7 @@ services = ["__APP__"]
|
|||
yes = "true"
|
||||
no = "false"
|
||||
help = "See User management -> Admins"
|
||||
bind = ":__FINALPATH__/config.yaml"
|
||||
bind = ":__INSTALL_DIR__/config.yaml"
|
||||
visible = "enable_relaybot"
|
||||
|
||||
[main.bot]
|
||||
|
@ -60,19 +60,19 @@ services = ["__APP__"]
|
|||
ask = "Username of the AppService Bot"
|
||||
type = "string"
|
||||
help = "Sets bot username. Please keep in mind that the bot admin room for previous bot username will stop working so you may need to create a new one using the new username"
|
||||
bind = "bot>username:__FINALPATH__/config.yaml"
|
||||
bind = "bot>username:__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[main.bot.displayname]
|
||||
ask = "Display name for Bot"
|
||||
type = "string"
|
||||
help = "Set to 'remove' to remove display name, leave empty to set default 'WhatsApp bridge bot'"
|
||||
bind = ":__FINALPATH__/config.yaml"
|
||||
bind = ":__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[main.bot.avatar]
|
||||
ask = "Avatar for Bot"
|
||||
type = "string"
|
||||
help = "Should be in format 'mxc://server_name/NeXNQarUbrlYBiPCpprYsRqr', see README for tutorial. Set to 'remove' to remove avatar, leave empty to use standard WhatsApp logo."
|
||||
bind = ":__FINALPATH__/config.yaml"
|
||||
bind = ":__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[privacy]
|
||||
name = "Privacy"
|
||||
|
@ -95,7 +95,7 @@ services = ["__APP__"]
|
|||
yes = "true"
|
||||
no = "false"
|
||||
help = "Enable so-called End-to-Bridge (e2b) Encryption. For the Bridge to work in group chat Rooms with End-to-End Encryption (e2ee) enabled."
|
||||
bind = "encryption>allow:__FINALPATH__/config.yaml"
|
||||
bind = "encryption>allow:__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[privacy.portal_rooms.encryption_default]
|
||||
ask = "Force-enable Encryption in all Portal Rooms the Bridge creates?"
|
||||
|
@ -103,7 +103,7 @@ services = ["__APP__"]
|
|||
yes = "true"
|
||||
no = "false"
|
||||
help = "This will cause the Bridge Bot to be in private chats for the Encryption to work properly."
|
||||
bind = "encryption>default:__FINALPATH__/config.yaml"
|
||||
bind = "encryption>default:__INSTALL_DIR__/config.yaml"
|
||||
visible = "encryption"
|
||||
|
||||
[privacy.portal_rooms.encryption_require]
|
||||
|
@ -112,7 +112,7 @@ services = ["__APP__"]
|
|||
yes = "true"
|
||||
no = "false"
|
||||
help = "Require encryption, drop any unencrypted messages."
|
||||
bind = "encryption>require:__FINALPATH__/config.yaml"
|
||||
bind = "encryption>require:__INSTALL_DIR__/config.yaml"
|
||||
visible = "encryption"
|
||||
|
||||
[privacy.config]
|
||||
|
@ -124,7 +124,7 @@ services = ["__APP__"]
|
|||
yes = "true"
|
||||
no = "false"
|
||||
help = "Should the bridge send a read Receipt from the bridge bot when a message has been sent to WhatsApp?"
|
||||
bind = ":__FINALPATH__/config.yaml"
|
||||
bind = ":__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[privacy.config.send_presence_on_typing]
|
||||
ask = "Send Presence on typing?"
|
||||
|
@ -132,7 +132,7 @@ services = ["__APP__"]
|
|||
yes = "true"
|
||||
no = "false"
|
||||
help = "Send the Presence as 'available' to WhatsApp when Users start typing on a Portal."
|
||||
bind = ":__FINALPATH__/config.yaml"
|
||||
bind = ":__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[privacy.config.url_previews]
|
||||
ask = "Enable URL Preview?"
|
||||
|
@ -140,7 +140,7 @@ services = ["__APP__"]
|
|||
yes = "true"
|
||||
no = "false"
|
||||
help = "Should the Bridge detect URLs in outgoing messages, ask the HomeServer to generate a Preview, and send it to WhatsApp?"
|
||||
bind = ":__FINALPATH__/config.yaml"
|
||||
bind = ":__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[advanced]
|
||||
name = "Advanced Settings"
|
||||
|
@ -160,19 +160,19 @@ services = ["__APP__"]
|
|||
ask = "Localpart template of MXIDs for WhatsApp users"
|
||||
type = "string"
|
||||
help = "Defaults to 'whatsapp_{{.}}'. '{{.}}' is replaced with the phone number 'msidsn' of the WhatsApp user."
|
||||
bind = ":__FINALPATH__/config.yaml"
|
||||
bind = ":__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[advanced.whatsapp.os_name]
|
||||
ask = "Device name in the 'WhatsApp Web' section of the smartphone app"
|
||||
type = "string"
|
||||
bind = ":__FINALPATH__/config.yaml"
|
||||
bind = ":__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[advanced.whatsapp.browser_name]
|
||||
ask = "Browser name that determines the logo shown in the smartphone app"
|
||||
type = "select"
|
||||
choices = ["unknown", "chrome", "firefox", "ie", "opera", "safari", "edge", "desktop", "ipad", "android_tablet", "ohana", "aloha", "catalina", "tcl_tv"]
|
||||
help = "Must be 'unknown' for a generic icon or a valid browser name if you want a specific logo."
|
||||
bind = ":__FINALPATH__/config.yaml"
|
||||
bind = ":__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[advanced.appservice]
|
||||
name = "HomeServer Application Service"
|
||||
|
@ -183,7 +183,7 @@ services = ["__APP__"]
|
|||
yes = "true"
|
||||
no = "false"
|
||||
help = "Enable only if HomeServer supports https://github.com/matrix-org/matrix-spec-proposals/pull/2246?"
|
||||
bind = ":__FINALPATH__/config.yaml"
|
||||
bind = ":__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[advanced.appservice.ephemeral_events]
|
||||
ask = "Receive Ephemeral Events via AppService transactions?"
|
||||
|
@ -191,14 +191,14 @@ services = ["__APP__"]
|
|||
yes = "true"
|
||||
no = "false"
|
||||
help = "Enable only if HomeServer supports MSC2409 (i.e. Synapse 1.22+). If enabled, you should disable bridge -> 'sync_with_custom_puppets'."
|
||||
bind = ":__FINALPATH__/config.yaml"
|
||||
bind = ":__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[advanced.appservice.min_level]
|
||||
ask = "Logging print level for Standard Output"
|
||||
type = "select"
|
||||
choices = ["debug", "info", "warn", "error", "fatal"]
|
||||
help = "Minimum severity for log messages printed to stdout/stderr. This doesn't affect the log file."
|
||||
bind = ":__FINALPATH__/config.yaml"
|
||||
bind = ":__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[advanced.metrics]
|
||||
name = "Prometheus Metrics"
|
||||
|
@ -208,12 +208,12 @@ services = ["__APP__"]
|
|||
type = "boolean"
|
||||
yes = "true"
|
||||
no = "false"
|
||||
bind = "metrics>enabled:__FINALPATH__/config.yaml"
|
||||
bind = "metrics>enabled:__INSTALL_DIR__/config.yaml"
|
||||
|
||||
[advanced.metrics.listen_port]
|
||||
ask = "IP and Port for the Metrics listener?"
|
||||
type = "string"
|
||||
help = "Defaults to: '127.0.0.1:8001'. The path is always /metrics"
|
||||
bind = "metrics>listen:__FINALPATH__/config.yaml"
|
||||
bind = "metrics>listen:__INSTALL_DIR__/config.yaml"
|
||||
visible = "enable_metrics"
|
||||
|
||||
|
|
18
doc/ADMIN.md
Normal file
18
doc/ADMIN.md
Normal file
|
@ -0,0 +1,18 @@
|
|||
## Configuration of the bridge
|
||||
|
||||
The bridge is [roughly configured at installation](https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh/blob/master/conf/config.yaml), e.g. allowed admin and user of the bot.
|
||||
Finer configuration can be done by using the existing config panel in the Yunohost admin panel or by modifying the
|
||||
following configuration file with SSH:
|
||||
```/opt/yunohost/mautrix_whatsapp/config.yaml```
|
||||
and then restarting the mautrix_whatsapp service.
|
||||
|
||||
#### User permissions
|
||||
|
||||
|
||||
#### End-to-bridge encryption
|
||||
The bridge can optionally encrypt messages between Matrix users and the bridge to hide messages from the homeserver. Using Postgres is strongly recommended when using end-to-bridge encryption.
|
||||
|
||||
If you want to enable it, go to the config panel section `Privacy -> Portal Rooms & Encryption Settings`. If you enable `Allow Encryption between Matrix Client and Bridge Server?`, the bridge won't enable encryption on its own, but will work in encrypted rooms.
|
||||
Alternatively two more options will appear, `Force-enable Encryption in all Portal Rooms the Bridge creates?` which will automatically enable encryption in new portals and `Require encryption?` which will enforce encryption on any of the messages that you send (this will make the bridge drop any future unencrypted messages).
|
||||
|
||||
There is also the possibity to configure it in the bridge configuration YAML file in the section `bridge: encryption`.
|
17
doc/ADMIN_fr.md
Normal file
17
doc/ADMIN_fr.md
Normal file
|
@ -0,0 +1,17 @@
|
|||
### 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_whatsapp_ynh/blob/master/conf/config.yaml).
|
||||
Une configuration plus fine peut être effectuée en utilisant le panneau de configuration existant dans le panneau d'administration de Yunohost ou en modifiant le fichier de configuration suivant avec SSH:
|
||||
``` /opt/yunohost/mautrix_whatsapp/config.yaml```
|
||||
puis en redémarrant le service mautrix_whatsapp.
|
||||
|
||||
#### User permissions
|
||||
|
||||
|
||||
#### End-to-bridge encryption
|
||||
Le robot peut éventuellement chiffrer les messages entre les utilisateurs de Matrix et la passarelle pour cacher les messages du serveur domestique. L'utilisation de Postgres est fortement recommandée lors de l'utilisation du chiffrement end-to-bridge.
|
||||
|
||||
Si vous voulez l'activer, allez dans la section `Privacy -> Portal Rooms & Encryption Settings` du panneau de configuration. Si vous activez `Allow Encryption between Matrix Client and Bridge Server?`, la passarelle n'activera pas le cryptage d'elle-même, mais fonctionnera dans les salles cryptées.
|
||||
Sinon, deux autres options apparaissent, `Force-enable Encryption in all Portal Rooms the Bridge creates?` qui activera automatiquement le cryptage dans les nouveaux portails et `Require encryption?` qui imposera le cryptage sur tous les messages que vous envoyez (ce qui fera que le robot abandonnera tous les messages non cryptés à l'avenir).
|
||||
|
||||
Il est également possible de le configurer dans le fichier YAML de configuration du robot dans la section `bridge: encryption`.
|
9
doc/DEVELOPMENT.md
Normal file
9
doc/DEVELOPMENT.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
## Development code quality
|
||||
|
||||
The `.github/workflows/updater.sh` script needs to be synced with changes in `conf/config.yaml` therefore a `pre-commit`
|
||||
hook is used to display a reminder to update `.github/workflows/updater.sh` (if needed) when `conf/config.yaml` has been modified.
|
||||
|
||||
Please enable Git hooks using following command to ensure code quality and stability.
|
||||
``` bash
|
||||
git config --local core.hooksPath .githooks
|
||||
```
|
10
doc/DEVELOPMENT_fr.md
Normal file
10
doc/DEVELOPMENT_fr.md
Normal file
|
@ -0,0 +1,10 @@
|
|||
## Development code quality
|
||||
|
||||
Le script `.github/workflows/updater.sh` doit être synchronisé avec les changements dans `conf/config.yaml`,
|
||||
donc un hook `pre-commit` est utilisé pour afficher un rappel pour mettre à jour
|
||||
`.github/workflows/updater.sh` (si nécessaire) lorsque `conf/config.yaml` a été modifié.
|
||||
|
||||
Veuillez activer les hooks Git en utilisant la commande suivante pour assurer la qualité et la stabilité du code.
|
||||
``` bash
|
||||
git config --local core.hooksPath .githooks
|
||||
```
|
|
@ -1,103 +0,0 @@
|
|||
## List of known public services
|
||||
|
||||
* Ask on one of the following rooms: #mautrix_yunohost:matrix.fdn.fr or #whatsapp:maunium.net
|
||||
|
||||
## Bridging usage
|
||||
** Note that several WhatsApp and Matrix users can be bridged, each WhatsApp account has its own bot administration room. If they are in a same WhatsApp group, only one matrix room will be created. **
|
||||
|
||||
### Bridge a WhatsApp user and a Matrix user
|
||||
* First your matrix user or server has to be authorized in the bridge configuration (see below)
|
||||
* Then, invite the bot (default @whatsappbot:yoursynapse.domain)
|
||||
* The room with the Mautrix-WhatsApp bot is called "administration room".
|
||||
* Type ``login``
|
||||
* Capture the QR code with the camera in the whatsapp of your VM or smartphone (WhatsApp Web)
|
||||
* Send ``help`` to the bot in the created room to know how to control the bot.
|
||||
See also [upstream wiki Authentication page](https://docs.mau.fi/bridges/go/whatsapp/authentication.html)
|
||||
|
||||
### Bridge an existing room | Bridge Whatsapp to Signal over Matrix
|
||||
By default, the bridge creates a portal room for each WA group that the WA user actively uses.
|
||||
Your can also create a portal for an existing Matrix room. **Note that this can be a room created by another bridge, e.g. a Signal portal room**
|
||||
1. Invite the bridge bot to the room (with an authorized user)
|
||||
2. type `!wa create`
|
||||
3. Your logged in WA user creates a new corresponding group.
|
||||
4. Get the WA invite link `!wa invite-link` and share it with friends. Or invite Whatsapp puppets to room.
|
||||
5. Optional: Activate relaybot, see next section.
|
||||
|
||||
### Relaybot: Bridge a group for several Matrix and several WhatsApp users to chat together
|
||||
**When upgrading from <v0.2.0, the relaybot system changed. There is no relaybot administration room anymore. Relay must be re-activated in all rooms**.
|
||||
|
||||
To be able to bridge not only your logged in Matrix account but also Matrix friends you invite to a portal room, you need to:
|
||||
1. enable relaybot setting in the bridge configuration `relay: enabled: true`
|
||||
2. login to your WhatsApp account in the (main) administration room
|
||||
3. write `!wa set-relay` in each of the rooms you want to relay to (re-)activate the relaybot function. By default, only bridge admin can do this, see setting `admin_only: true`
|
||||
|
||||
* In WhatsApp: all messages will be seen as received from the account who is logged in with a prefix for the source matrix user.
|
||||
* On the matrix side: the bridge will create matrix puppets corresponding to the WhatsApp users when they send a message.
|
||||
See also [upstream wiki Relaybot page](https://docs.mau.fi/bridges/general/relay-mode.html)
|
||||
|
||||
## Configuration of the bridge
|
||||
|
||||
The bridge is [roughly configured at installation](https://github.com/YunoHost-Apps/mautrix_whatsapp_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_whatsapp/config.yaml```
|
||||
and then restarting the mautrix_whatsapp service.
|
||||
|
||||
#### End-to-bridge encryption
|
||||
The bridge can optionally encrypt messages between Matrix users and the bridge to hide messages from the homeserver. Using Postgres is strongly recommended when using end-to-bridge encryption.
|
||||
|
||||
If you want to enable it, look for the option ```bridge → encryption``` in the config file. If you only set ```allow: true```, the bridge won't enable encryption on its own, but will work in encrypted rooms. If you set ```default: true```, the bridge will automatically enable encryption in new portals.
|
||||
There is also the possibility to set ```require: true``` to enforce encryption on any of the messages that you send (this will drop any unencrypted messages).
|
||||
|
||||
## 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 WhatsApp bot is a local Matrix-Synapse user, but accessible through federation (synapse public or private).
|
||||
* Several Signal and Matrix users can be bridged with one bridge, each user has its own bot administration room.
|
||||
* If several bot users are in a same WhatsApp 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 WhatsApp 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.
|
||||
|
||||
### Supported architectures
|
||||
|
||||
ARM, ARM64, AMD64
|
||||
|
||||
## Limitations
|
||||
|
||||
* Audio/Video calls are not bridged yet.
|
||||
* If WhatsApp loses connection, e.g. the phone is set in flight mode or push notifications are deactivated, the bot has sometimes to be restarted manually by sending a reconnnect message in the matrix administration room.
|
||||
|
||||
### Additional information
|
||||
|
||||
* It is recommended to install WhatsApp on a virtual android running on a server, see [upstream wiki Android-VM-Setup page](https://docs.mau.fi/bridges/go/whatsapp/android-vm-setup.html)
|
||||
**More information on the documentation page:**
|
||||
https://docs.mau.fi/bridges/go/whatsapp/index.html
|
||||
|
||||
To test communication between the App Service and Matrix-Synapse on a VM (e.g. with domain name: synapse.vm), you must install a certificate:
|
||||
```
|
||||
echo | openssl s_client -showcerts -servername synapse.vm -connect synapse.vm:443 2>/dev/null | awk '/-----BEGIN CERTIFICATE-----/, /-----END CERTIFICATE-----/' >> /usr/local/share/ca-certificates/synapse.vm.crt
|
||||
update-ca-certificates
|
||||
```
|
||||
|
||||
### Miscellaneous information
|
||||
|
||||
* Matrix room (matrix bridges in YunoHost): #mautrix_yunohost:matrix.fdn.fr
|
||||
* Matrix room (upstream app): #whatsapp:maunium.net
|
||||
In case you need to upload your logs somewhere, be aware that they contain your contacts' and your phone numbers. Strip them out with
|
||||
``| sed -r 's/[0-9]{10,}/📞/g' ``
|
||||
* "Mautrix-WhatsApp" bridge is based on the [Rhymen/go-whatsapp](https://github.com/Rhymen/go-whatsapp) implementation of the [sigalor/whatsapp-web-reveng](https://github.com/sigalor/whatsapp-web-reveng) project.
|
||||
|
||||
## Development code quality
|
||||
|
||||
The `.github/workflows/updater.sh` script needs to be synced with changes in `conf/config.yaml` therefore a `pre-commit`
|
||||
hook is used to display a reminder to update `.github/workflows/updater.sh` (if needed) when `conf/config.yaml` has been modified.
|
||||
|
||||
Please enable Git hooks using following command to ensure code quality and stability.
|
||||
``` bash
|
||||
git config --local core.hooksPath .githooks
|
||||
```
|
|
@ -1,87 +0,0 @@
|
|||
## Liste de passerelles publiques
|
||||
|
||||
* Demandez sur un des salons suivants: #mautrix_yunohost:matrix.fdn.fr or #whatsapp:maunium.net
|
||||
|
||||
## Usages de la passerelle
|
||||
** Notez que plusieurs comptes WhatsApp et Matrix peuvent être relayés, chaque compte WhatsApp connecté a son propre Salon d'Administration. Si plusieurs utilisateur.ice.s du Robot sont dans un même groupe WhatsApp, seul un Salon Matrix sera créé par la passerelle. **
|
||||
|
||||
### Relayer TOUTES les conversations entre UN compte WhatsApp 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 @whatsappbot:synapse.votredomaine) à une nouvelle conversation.
|
||||
* Ce nouveau salon d'administration du Robot Mautrix-WhatsApp est appelé "Administration Room".
|
||||
* Tapez ``login``
|
||||
* Scannez le QR-code avec la caméra Whatsapp de votre Machine Virtuelle ou ordiphone (option WhatsApp Web dans l'appli)
|
||||
* 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/go/whatsapp/authentication.html)
|
||||
|
||||
#### Robot-Relai "Relaybot": Relayer les conversations de TOUS les comptes Matrix et TOUS les comptes WhatsApp présents dans UN groupe/salon
|
||||
|
||||
* Prérequis : Créer un nouveau salon vide "Relaybot Administration Room" et rechercher son identifiant.
|
||||
* Activer l'option Robot-Relai "Relaybot" dans la configuration de la passerelle (default=disabled, voir ci-dessous) et ajouter l'identifiant du salon d'administration du Relaybot "Relaybot Administration Room".
|
||||
* Redémarrer le service mautrix_whatsapp
|
||||
* Vous pouvez maintenant relayer un groupe WhatsApp en y invitant le numéro de téléphone du compte WhatsApp connecté au RobotRelai. Côté WhatsApp, tous les messages venant de Matrix seront vus comme envoyés depuis le compte WhatsApp connecté, avec un préfix indiquant le compte Matrix correspondant. Côté Matrix, la passerelle va créer des comptes Matrix pour chaque compte WhatsApp présent dans le groupe relayé. Les messages sont indiqués comme provenant soit du numéro de téléphone, soit du pseudo WhatsApp.
|
||||
Voir aussi [la page wiki principale sur le Robot-Relai](https://docs.mau.fi/bridges/go/whatsapp/relaybot.html)
|
||||
|
||||
### 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_whatsapp_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_whatsapp/config.yaml```
|
||||
puis en redémarrant le service:
|
||||
``` sudo yunohost service restart mautrix_whatsapp```
|
||||
|
||||
#### End-to-bridge encryption
|
||||
Le robot peut éventuellement chiffrer les messages entre les utilisateurs de Matrix et la passarelle pour cacher les messages du serveur domestique. L'utilisation de Postgres est fortement recommandée lors de l'utilisation du chiffrement end-to-bridge.
|
||||
|
||||
Si vous voulez l'activer, cherchez l'option ```bridge → encryption``` dans le fichier de configuration. Si vous définissez uniquement l'option ``allow: true``, le robot n'activera pas le chiffrement de lui-même, mais travaillera dans les portails chiffrés. Si vous définissez ```default: true```, la passerelle activera automatiquement le chiffrement dans les nouveaux portails.
|
||||
Il y a également la possibilité de définir ```require: true``` pour imposer le chiffrement sur tous les messages que vous envoyez (cela interdira tous les messages non chiffrés).
|
||||
|
||||
### 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 WhatsApp est un utilisateur Matrix-Synapse local, mais accessible via la fédération (Synapse public ou privé).
|
||||
* Plusieurs comptes WhatsApp 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 WhatsApp, seul un Salon Matrix sera créé par la passerelle. Autrement dit, la passerelle construit un seul miroir du réseau de discussion existant sur WhatsApp (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 WhatsApp.
|
||||
* 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.
|
||||
|
||||
### Architectures supportées
|
||||
|
||||
ARM, ARM64, AMD64
|
||||
|
||||
### Limitations
|
||||
|
||||
* Les appels Audio/Video ne sont pas relayés. Seule une notification apparait.
|
||||
* Si WhatsApp perd la connexion, par ex. l'ordiphone est mis en mode avion ou les notifications poussées sont désactivées, le robot doit parfois être redémarré à la main en envoyant un message ``wa !reconnnect`` dans le salon d'administration.
|
||||
|
||||
### Informations additionnelles
|
||||
|
||||
* Il est recommandé d'installer WhatsApp sur une machine Android virtuelle tournant sur un serveur, cf. le [page Android-VM-Setup du wiki](https://docs.mau.fi/bridges/go/whatsapp/android-vm-setup.html)
|
||||
|
||||
Pour tester la communication entre le Service d'Application et Matrix-Synapse sur une Machine Virtuelle (ex. avec un nom de domaine: synapse.vm), vous devez installer un certificat:
|
||||
```
|
||||
echo | openssl s_client -showcerts -servername synapse.vm -connect synapse.vm:443 2>/dev/null | awk '/-----BEGIN CERTIFICATE-----/, /-----END CERTIFICATE-----/' >> /usr/local/share/ca-certificates/synapse.vm.crt
|
||||
update-ca-certificates
|
||||
```
|
||||
|
||||
### Informations diverses
|
||||
|
||||
* Salon Matrix sur les Passerelles dans Yunohost): #mautrix_yunohost:matrix.fdn.fr
|
||||
* Salon Matrix (application principale): #whatsapp:maunium.net
|
||||
Si vous devez téléverser vos fichiers log quelque-part, soyez avertis qu'ils contiennent des informations sur vos contacts et vos numéros de téléphone. Effacez-les avec
|
||||
``| sed -r 's/[0-9]{10,}/📞/g' ``
|
||||
* La passerelle "Mautrix-WhatsApp" repose sur l'implémentation [Rhymen/go-whatsapp](https://github.com/Rhymen/go-whatsapp) du projet [sigalor/whatsapp-web-reveng](https://github.com/sigalor/whatsapp-web-reveng).
|
||||
|
||||
## Development code quality
|
||||
|
||||
Le script `.github/workflows/updater.sh` doit être synchronisé avec les changements dans `conf/config.yaml`,
|
||||
donc un hook `pre-commit` est utilisé pour afficher un rappel pour mettre à jour
|
||||
`.github/workflows/updater.sh` (si nécessaire) lorsque `conf/config.yaml` a été modifié.
|
||||
|
||||
Veuillez activer les hooks Git en utilisant la commande suivante pour assurer la qualité et la stabilité du code.
|
||||
``` bash
|
||||
git config --local core.hooksPath .githooks
|
||||
```
|
37
doc/POST_INSTALL.md
Normal file
37
doc/POST_INSTALL.md
Normal file
|
@ -0,0 +1,37 @@
|
|||
## List of known public services
|
||||
|
||||
* Ask on one of the following rooms: #mautrix_yunohost:matrix.fdn.fr or #whatsapp:maunium.net
|
||||
|
||||
## Bridging usage
|
||||
** Note that several WhatsApp and Matrix users can be bridged, each WhatsApp account has its own bot administration room. If they are in a same WhatsApp group, only one matrix room will be created. **
|
||||
|
||||
### Bridge a WhatsApp user and a Matrix user
|
||||
* First your matrix user or server has to be authorized in the bridge configuration (see below)
|
||||
* Then, invite the bot (default @whatsappbot:yoursynapse.domain)
|
||||
* The room with the Mautrix-WhatsApp bot is called "administration room".
|
||||
* Type ``login``
|
||||
* Capture the QR code with the camera in the WhatsApp of your VM or smartphone (WhatsApp Web)
|
||||
* Send ``help`` to the bot in the created room to know how to control the bot.
|
||||
See also [upstream wiki Authentication page](https://docs.mau.fi/bridges/go/whatsapp/authentication.html)
|
||||
|
||||
### Bridge an existing room
|
||||
By default, the bridge creates a portal room for each WhatsApp group that the WhatsApp user actively uses.
|
||||
Your can also create a portal for an existing Matrix room. **Note that this can be a room created by another bridge, e.g. a Signal portal room**
|
||||
1. Invite the bridge bot to the room (with an authorized user)
|
||||
2. Type `!wa create`
|
||||
3. Your logged in WA user creates a new corresponding group.
|
||||
4. Get the WA invite link `!wa invite-link` and share it with friends. Or invite WhatsApp puppets to room.
|
||||
5. Optional: Activate relaybot, see next section.
|
||||
|
||||
### Relaybot: Bridge a group for several Matrix and several WhatsApp users to chat together
|
||||
|
||||
To be able to bridge not only your logged in Matrix account but also Matrix friends you invite to a portal room, you need to:
|
||||
1. Enable relaybot setting in the config panel section `Main Settings -> Puppetting Bridge Settings` or in the bridge configuration YAML file `relay: enabled: true`. Also make sure that the users you want to invite have at least the `relay` level in the `permissions` section (this can be configured in the config panel section `Main Settings -> Permissions for using the bridge`).
|
||||
2. Login to your WhatsApp account in the (main) administration room
|
||||
3. Depending on what has been selected during installation this could be done only by admins, but can also be changed in the config panel section `Main Settings -> Puppetting Bridge Settings` or in the bridge configuration YAML file `relay: admin_only`.
|
||||
4. Write `!wa set-relay` in each of the rooms you want to relay to (re-)activate the relaybot function.
|
||||
|
||||
|
||||
* In WhatsApp: all messages will be seen as received from the account who is logged in with a prefix for the source matrix user.
|
||||
* On the matrix side: the bridge will create matrix puppets corresponding to the WhatsApp users when they send a message.
|
||||
See also [upstream wiki Relaybot page](https://docs.mau.fi/bridges/general/relay-mode.html)
|
24
doc/POST_INSTALL_fr.md
Normal file
24
doc/POST_INSTALL_fr.md
Normal file
|
@ -0,0 +1,24 @@
|
|||
## Liste de passerelles publiques
|
||||
|
||||
* Demandez sur un des salons suivants: #mautrix_yunohost:matrix.fdn.fr or #whatsapp:maunium.net
|
||||
|
||||
## Usages de la passerelle
|
||||
** Notez que plusieurs comptes WhatsApp et Matrix peuvent être relayés, chaque compte WhatsApp connecté a son propre Salon d'Administration. Si plusieurs utilisateur.ice.s du Robot sont dans un même groupe WhatsApp, seul un Salon Matrix sera créé par la passerelle. **
|
||||
|
||||
### Relayer TOUTES les conversations entre UN compte WhatsApp 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 @whatsappbot:synapse.votredomaine) à une nouvelle conversation.
|
||||
* Ce nouveau salon d'administration du Robot Mautrix-WhatsApp est appelé "Administration Room".
|
||||
* Tapez ``login``
|
||||
* Scannez le QR-code avec la caméra Whatsapp de votre Machine Virtuelle ou ordiphone (option WhatsApp Web dans l'appli)
|
||||
* 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/go/whatsapp/authentication.html)
|
||||
|
||||
### Robot-Relai "Relaybot": Relayer les conversations de TOUS les comptes Matrix et TOUS les comptes WhatsApp présents dans UN groupe/salon
|
||||
|
||||
1. Activer l'option `Should Relay Mode be allowed?` dans le panneau de configuration (section `Main Settings -> Puppetting Bridge Settings`) ou dans le fichier YAML de configuration du robot `relay: enabled: true`. Assurez-vous également que les utilisateurs que vous voulez inviter ont au moins le niveau `relay` dans la section `permissions` (ceci peut être configuré dans la section `Main Settings -> Permissions for using the bridge` du panneau de configuration).
|
||||
2. En fonction de ce qui a été sélectionné lors de l'installation, cela peut être fait uniquement par les administrateurs, mais peut également être modifié dans la section `Main Settings -> Puppetting Bridge Settings` du panneau de configuration ou dans le fichier YAML de configuration du robot `relay: admin_only`
|
||||
3. Ecrivez `!wa set-relay` dans chacune des pièces que vous voulez relayer pour (ré)activer la fonction de relaybot.
|
||||
|
||||
* Vous pouvez maintenant relayer un groupe WhatsApp en y invitant le numéro de téléphone du compte WhatsApp connecté au RobotRelai. Côté WhatsApp, tous les messages venant de Matrix seront vus comme envoyés depuis le compte WhatsApp connecté, avec un préfix indiquant le compte Matrix correspondant. Côté Matrix, la passerelle va créer des comptes Matrix pour chaque compte WhatsApp présent dans le groupe relayé. Les messages sont indiqués comme provenant soit du numéro de téléphone, soit du pseudo WhatsApp.
|
||||
Voir aussi [la page wiki principale sur le Robot-Relai](https://docs.mau.fi/bridges/go/whatsapp/relaybot.html)
|
33
doc/PRE_INSTALL.md
Normal file
33
doc/PRE_INSTALL.md
Normal file
|
@ -0,0 +1,33 @@
|
|||
## 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 WhatsApp bot is a local Matrix-Synapse user, but accessible through federation (synapse public or private).
|
||||
* Several WhatsApp 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 WhatsApp group, only one Matrix room will be created by the bridge.
|
||||
* See https://github.com/YunoHost-Apps/synapse_ynh#multi-users-support
|
||||
|
||||
## Limitations
|
||||
|
||||
* Audio/Video calls are not bridged yet.
|
||||
* If WhatsApp loses connection, e.g. the phone is set in flight mode or push notifications are deactivated, the bot has sometimes to be restarted manually by sending a reconnnect message in the matrix administration room.
|
||||
* WhatsApp needs to get presence from the official app every two weeks at least, so bridge will send a reminder in the administration room.
|
||||
|
||||
## Additional information
|
||||
|
||||
* It is recommended to install WhatsApp on a virtual android running on a server, see [upstream wiki Android-VM-Setup page](https://docs.mau.fi/bridges/go/whatsapp/android-vm-setup.html)
|
||||
**More information on the documentation page:**
|
||||
https://docs.mau.fi/bridges/go/whatsapp/index.html
|
||||
|
||||
To test communication between the App Service and Matrix-Synapse on a VM (e.g. with domain name: synapse.vm), you must install a certificate:
|
||||
```
|
||||
echo | openssl s_client -showcerts -servername synapse.vm -connect synapse.vm:443 2>/dev/null | awk '/-----BEGIN CERTIFICATE-----/, /-----END CERTIFICATE-----/' >> /usr/local/share/ca-certificates/synapse.vm.crt
|
||||
update-ca-certificates
|
||||
```
|
||||
|
||||
## Miscellaneous information
|
||||
|
||||
* Matrix room (matrix bridges in YunoHost): #mautrix_yunohost:matrix.fdn.fr
|
||||
* Matrix room (upstream app): #whatsapp:maunium.net
|
||||
In case you need to upload your logs somewhere, be aware that they contain your contacts' and your phone numbers. Strip them out with
|
||||
``| sed -r 's/[0-9]{10,}/📞/g' ``
|
||||
* "Mautrix-WhatsApp" bridge is based on the [Rhymen/go-whatsapp](https://github.com/Rhymen/go-whatsapp) implementation of the [sigalor/whatsapp-web-reveng](https://github.com/sigalor/whatsapp-web-reveng) project.
|
31
doc/PRE_INSTALL_fr.md
Normal file
31
doc/PRE_INSTALL_fr.md
Normal file
|
@ -0,0 +1,31 @@
|
|||
## 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 WhatsApp est un utilisateur Matrix-Synapse local, mais accessible via la fédération (Synapse public ou privé).
|
||||
* Plusieurs comptes WhatsApp 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 WhatsApp, seul un Salon Matrix sera créé par la passerelle. Autrement dit, la passerelle construit un seul miroir du réseau de discussion existant sur WhatsApp (utilisateurs et salons).
|
||||
* Voir https://github.com/YunoHost-Apps/synapse_ynh#multi-users-support
|
||||
|
||||
## Limitations
|
||||
|
||||
* Les appels Audio/Video ne sont pas relayés. Seule une notification apparait.
|
||||
* Si WhatsApp perd la connexion, par ex. l'ordiphone est mis en mode avion ou les notifications poussées sont désactivées, le robot doit parfois être redémarré à la main en envoyant un message ``wa !reconnnect`` dans le salon d'administration.
|
||||
* WhatsApp doit obtenir la présence de l'application officielle toutes les deux semaines au moins, c'est pourquoi le robot enverra un rappel dans la salle d'administration.
|
||||
|
||||
## Informations additionnelles
|
||||
|
||||
* Il est recommandé d'installer WhatsApp sur une machine Android virtuelle tournant sur un serveur, cf. le [page Android-VM-Setup du wiki](https://docs.mau.fi/bridges/go/whatsapp/android-vm-setup.html)
|
||||
|
||||
Pour tester la communication entre le Service d'Application et Matrix-Synapse sur une Machine Virtuelle (ex. avec un nom de domaine: synapse.vm), vous devez installer un certificat:
|
||||
```
|
||||
echo | openssl s_client -showcerts -servername synapse.vm -connect synapse.vm:443 2>/dev/null | awk '/-----BEGIN CERTIFICATE-----/, /-----END CERTIFICATE-----/' >> /usr/local/share/ca-certificates/synapse.vm.crt
|
||||
update-ca-certificates
|
||||
```
|
||||
|
||||
## Informations diverses
|
||||
|
||||
* Salon Matrix sur les Passerelles dans Yunohost): #mautrix_yunohost:matrix.fdn.fr
|
||||
* Salon Matrix (application principale): #whatsapp:maunium.net
|
||||
Si vous devez téléverser vos fichiers log quelque-part, soyez avertis qu'ils contiennent des informations sur vos contacts et vos numéros de téléphone. Effacez-les avec
|
||||
``| sed -r 's/[0-9]{10,}/📞/g' ``
|
||||
* La passerelle "Mautrix-WhatsApp" repose sur l'implémentation [Rhymen/go-whatsapp](https://github.com/Rhymen/go-whatsapp) du projet [sigalor/whatsapp-web-reveng](https://github.com/sigalor/whatsapp-web-reveng).
|
114
manifest.json
114
manifest.json
|
@ -1,114 +0,0 @@
|
|||
{
|
||||
"name": "Matrix-WhatsApp bridge",
|
||||
"id": "mautrix_whatsapp",
|
||||
"packaging_format": 1,
|
||||
"description": {
|
||||
"en": "Matrix / Synapse puppeting bridge for WhatsApp",
|
||||
"fr": "Passerelle Matrix / Synapse pour WhatsApp"
|
||||
},
|
||||
"version": "0.9.0~ynh1",
|
||||
"url": "https://github.com/mautrix/whatsapp",
|
||||
"upstream": {
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"website": "https://maunium.net/go/mautrix-whatsapp/",
|
||||
"admindoc": "https://docs.mau.fi/bridges/go/whatsapp/index.html",
|
||||
"code": "https://github.com/mautrix/whatsapp"
|
||||
},
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"maintainer": {
|
||||
"name": "thardev",
|
||||
"email": "",
|
||||
"url": "https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 4.3.0"
|
||||
},
|
||||
"multi_instance": true,
|
||||
"services": [
|
||||
"postgresql"
|
||||
],
|
||||
"arguments": {
|
||||
"install": [
|
||||
{
|
||||
"name": "synapsenumber",
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "Choose the local Synapse instance number to communicate with mautrix_whatsapp.",
|
||||
"fr": "Choisissez le numéro de l'instance Synapse qui doit communiquer avec mautrix_whatsapp."
|
||||
},
|
||||
"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 WhatsApp bot",
|
||||
"fr": "Choisissez un nom d'utilisateur Synapse local pour le robot WhatsApp"
|
||||
},
|
||||
"example": "whatsappbot",
|
||||
"help": {
|
||||
"en": "A system user will be created. Invite @whatsappbot:localsynapse.servername from an authorized Matrix account to start bridging.\nGive the Matrix server_name, not the full domain/URL.",
|
||||
"fr": "Un utilisateur système sera créé. Inviter @whatsappbot:localsynapse.servername depuis un compte Matrix autorisé pour démarrer une passerelle.\nDonner le nom du serveur Matrix, pas le domaine/URL complet."
|
||||
},
|
||||
"default": "whatsappbot"
|
||||
},
|
||||
{
|
||||
"name": "bot_synapse_adm",
|
||||
"type": "boolean",
|
||||
"ask": {
|
||||
"en": "Give the WhatsApp bot administrator rights to the Synapse instance?",
|
||||
"fr": "Donner au robot WhatsApp des droits administrateur à l'instance Synapse ?"
|
||||
},
|
||||
"help": {
|
||||
"en": "If true, the bot can group WhatsApp chats in a Matrix space.\nNot required if you set up Synapse so that non-admins are authorized to create communities.",
|
||||
"fr": "Si true, le robot groupera les conversations WhatsApp dans une communauté Matrix.\nPas nécessaire si vous avez réglé Synapse pour qu'il autorise les non-admin à créer des communautés."
|
||||
},
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"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 WhatsApp bot",
|
||||
"fr": "Choisissez le compte Matrix administrateur du robot WhatsApp"
|
||||
},
|
||||
"example": "@johndoe:localsynapse.servername or @johndoe:matrix.org",
|
||||
"help": {
|
||||
"en": "The administrator does not need to be a local Synapse account. Valid formats are @johndoe:localsynapse.servername or @johndoe:matrix.org",
|
||||
"fr": "L'administrateur peut ne pas être un compte local Synapse. Les formats valables sont @johndoe:localsynapse.servername or @johndoe:matrix.org"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "botusers",
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "Choose Matrix user(s) authorized to bridge with the WhatsApp bot.",
|
||||
"fr": "Choisissez le/les compte(s) Matrix autorisés à utiliser la passerelle WhatsApp."
|
||||
},
|
||||
"example": "@johndoe:server.name or server.name or *",
|
||||
"help": {
|
||||
"en": "A remote or local user (@johndoe:server.name),the local server (server.name), a remote server (matrix.org), or all remote/local servers (*) can be authorized.\nGive the Matrix server_name, not the full domain/URL.\nIt is also possible to specify multiple values by separating them with comma. Example: @johndoe:server.name,domain.tld,matrix.org",
|
||||
"fr": "Un compte local ou distant (@johndoe:server.name), le serveur local (server.name), un serveur distant (matrix.org), ou tous les serveurs remote/local (*).\nDonner le nom du serveur Matrix, pas le domaine/URL complet\nIl est également possible de spécifier plusieurs valeurs en les séparant par une virgule. Exemple : @johndoe:server.name,domain.tld,matrix.org"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
115
manifest.toml
Normal file
115
manifest.toml
Normal file
|
@ -0,0 +1,115 @@
|
|||
packaging_format = 2
|
||||
id = "mautrix_whatsapp"
|
||||
name = "Matrix-WhatsApp bridge"
|
||||
description.en = "Matrix / Synapse puppeting bridge for WhatsApp"
|
||||
description.fr = "Passerelle Matrix / Synapse pour WhatsApp"
|
||||
version = "0.9.0~ynh1"
|
||||
maintainers = ["thardev"]
|
||||
|
||||
[upstream]
|
||||
license = "AGPL-3.0-or-later"
|
||||
website = "https://maunium.net/go/mautrix-whatsapp/"
|
||||
code = "https://github.com/mautrix/whatsapp"
|
||||
admindoc = "https://docs.mau.fi/bridges/go/whatsapp/index.html"
|
||||
|
||||
[integration]
|
||||
yunohost = ">= 11.1"
|
||||
architectures = ["amd64", "arm64", "armhf"]
|
||||
multi_instance = true
|
||||
ldap = false
|
||||
sso = false
|
||||
disk = "100M"
|
||||
ram.build = "256M"
|
||||
ram.runtime = "1024M"
|
||||
|
||||
[install]
|
||||
|
||||
[install.synapse_instance]
|
||||
ask.en = "Choose the local Synapse instance to communicate with mautrix_whatsapp."
|
||||
ask.fr = "Choisissez l'instance Synapse qui doit communiquer avec mautrix_whatsapp."
|
||||
type = "app"
|
||||
pattern.regexp = "synapse(__)*[0-9]*"
|
||||
pattern.error = "Invalid app selected. Please select a Synapse instance."
|
||||
help.en = "Usually the Synapse instances contain a number after it is installed more than one time. E.g. synapse__1 will be the second instance."
|
||||
help.fr = "En général, les instances de Synapse contiennent un numéro après avoir été installées plus d'une fois. Par exemple, synapse__1 sera la deuxième instance."
|
||||
default = "synapse"
|
||||
|
||||
[install.botname]
|
||||
ask.en = "Choose a local Synapse user name for the WhatsApp bot"
|
||||
ask.fr = "Choisissez un nom d'utilisateur Synapse local pour le robot WhatsApp"
|
||||
type = "string"
|
||||
example = "whatsappbot"
|
||||
help.en = "A system user will be created. Invite @whatsappbot: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 @whatsappbot:localsynapse.servername depuis un compte Matrix autorisé pour démarrer une passerelle.Donner le nom du serveur Matrix, pas le domaine/URL complet."
|
||||
default = "whatsappbot"
|
||||
|
||||
[install.bot_synapse_adm]
|
||||
ask.en = "Give the WhatsApp bot administrator rights to the Synapse instance?"
|
||||
ask.fr = "Donner au robot WhatsApp des droits administrateur à l'instance Synapse ?"
|
||||
type = "boolean"
|
||||
help.en = "If true, the bot can group WhatsApp chats in a Matrix space.Not required if you set up Synapse so that non-admins are authorized to create communities."
|
||||
help.fr = "Si true, le robot groupera les conversations WhatsApp dans une communauté Matrix.Pas nécessaire si vous avez réglé Synapse pour qu'il autorise les non-admin à créer des communautés."
|
||||
default = true
|
||||
|
||||
[install.encryption]
|
||||
ask.en = "Enable end-to-bridge encryption?"
|
||||
ask.fr = "Activer le chiffrement entre Synapse et le bridge ?"
|
||||
type = "boolean"
|
||||
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."
|
||||
default = true
|
||||
|
||||
[install.botadmin]
|
||||
ask.en = "Choose the Matrix account administrator of the WhatsApp bot"
|
||||
ask.fr = "Choisissez le compte Matrix administrateur du robot WhatsApp"
|
||||
type = "string"
|
||||
example = "@johndoe:localsynapse.servername or @johndoe:matrix.org"
|
||||
help.en = "The administrator does not need to be a local Synapse account. Valid formats are @johndoe:localsynapse.servername or @johndoe:matrix.org"
|
||||
help.fr = "L'administrateur peut ne pas être un compte local Synapse. Les formats valables sont @johndoe:localsynapse.servername or @johndoe:matrix.org"
|
||||
|
||||
[install.botusers]
|
||||
ask.en = "Choose Matrix user(s) authorized to bridge with the WhatsApp bot."
|
||||
ask.fr = "Choisissez le/les compte(s) Matrix autorisés à utiliser la passerelle WhatsApp."
|
||||
type = "string"
|
||||
example = "@johndoe:server.name or server.name or *"
|
||||
help.en = """
|
||||
A remote or local user (@johndoe:server.name),the local server (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.
|
||||
It is also possible to specify multiple values by separating them with comma. Example: @johndoe:server.name,domain.tld,matrix.org"""
|
||||
help.fr = """Un compte local ou distant (@johndoe:server.name), le serveur local (server.name), un serveur distant (matrix.org), ou tous les serveurs remote/local (*).
|
||||
Donner le nom du serveur Matrix, pas le domaine/URL complet.
|
||||
Il est également possible de spécifier plusieurs valeurs en les séparant par une virgule. Exemple : @johndoe:server.name,domain.tld,matrix.org"""
|
||||
|
||||
[resources]
|
||||
|
||||
[resources.apt]
|
||||
packages = "g++, postgresql, ffmpeg"
|
||||
|
||||
[resources.database]
|
||||
type = "postgresql"
|
||||
|
||||
[resources.permissions]
|
||||
main.allowed = "all_users"
|
||||
main.auth_header = false
|
||||
|
||||
[resources.system_user]
|
||||
home = "/opt/yunohost/__APP__"
|
||||
|
||||
[resources.install_dir]
|
||||
dir = "/opt/yunohost/__APP__"
|
||||
|
||||
[resources.ports]
|
||||
main.default = 8449
|
||||
|
||||
[resources.sources]
|
||||
|
||||
[resources.sources.main]
|
||||
in_subdir = false
|
||||
extract = false
|
||||
rename = "mautrix-whatsapp"
|
||||
amd64.url = "https://github.com/mautrix/whatsapp/releases/download/v0.9.0/mautrix-whatsapp-amd64"
|
||||
amd64.sha256 = "27b5d3ee0cada177207b662072b42923956e38a9c10c4e167eeca17881f3bffb"
|
||||
arm64.url = "https://github.com/mautrix/whatsapp/releases/download/v0.9.0/mautrix-whatsapp-arm64"
|
||||
arm64.sha256 = "dc475a2af45988d6d428af18c5f2a30da24930201e0e667a0b749a198a3bd02d"
|
||||
armhf.url = "https://github.com/mautrix/whatsapp/releases/download/v0.9.0/mautrix-whatsapp-arm"
|
||||
armhf.sha256 = "22c28d17ec868c4579e8ed64e092b0947a268c82ed9714d3ae45ace05b477fd8"
|
|
@ -1,12 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
# dependencies used by the app (must be on a single line)
|
||||
pkg_dependencies="g++ postgresql ffmpeg"
|
||||
|
||||
#=================================================
|
||||
# CONFIG PANEL SETTERS
|
||||
#=================================================
|
||||
|
@ -22,24 +15,24 @@ apply_permissions() {
|
|||
then
|
||||
#ynh_systemd_action --service_name="$app" --action=stop
|
||||
# Get all entries between "permissions:" and "relay:" keys, remove the role part, remove commented parts, format it with newlines and clean whitespaces and double quotes.
|
||||
allDefinedEntries=$(awk '/permissions:/{flag=1; next} /relay:/{flag=0} flag' "$final_path/config.yaml" | sed "/: $role/d" | sed -r 's/: (admin|user|relay)//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr ',' '\n' )
|
||||
allDefinedEntries=$(awk '/permissions:/{flag=1; next} /relay:/{flag=0} flag' "$install_dir/config.yaml" | sed "/: $role/d" | sed -r 's/: (admin|user|relay)//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr ',' '\n' )
|
||||
# Delete everything from the corresponding role to insert the new defined values. This way we also handle deletion of users.
|
||||
sed -i "/permissions:/,/relay:/{/: $role/d;}" "$final_path/config.yaml"
|
||||
sed -i "/permissions:/,/relay:/{/: $role/d;}" "$install_dir/config.yaml"
|
||||
# Ensure that entries with value surrounded with quotes are deleted too. E.g. "users".
|
||||
sed -i "/permissions:/,/relay:/{/: \"$role\"/d;}" "$final_path/config.yaml"
|
||||
sed -i "/permissions:/,/relay:/{/: \"$role\"/d;}" "$install_dir/config.yaml"
|
||||
for user in "${usersArray[@]}"
|
||||
do
|
||||
if grep -q -x "${user}" <<< "$allDefinedEntries"
|
||||
then
|
||||
ynh_print_info "User $user already defined in another role."
|
||||
else
|
||||
sed -i "/permissions:/a \ \\\"$user\": $role" "$final_path/config.yaml" # Whitespaces are needed so that the file can be correctly parsed
|
||||
sed -i "/permissions:/a \ \\\"$user\": $role" "$install_dir/config.yaml" # Whitespaces are needed so that the file can be correctly parsed
|
||||
fi
|
||||
done
|
||||
fi
|
||||
set +o noglob
|
||||
|
||||
ynh_print_info "Users with role $role added in $final_path/config.yaml"
|
||||
ynh_print_info "Users with role $role added in $install_dir/config.yaml"
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,19 +41,19 @@ set__listuser() {
|
|||
role="user"
|
||||
ynh_app_setting_set --app=$app --key=listuser --value="$listuser"
|
||||
apply_permissions
|
||||
ynh_store_file_checksum --file="$final_path/config.yaml"
|
||||
ynh_store_file_checksum --file="$install_dir/config.yaml"
|
||||
}
|
||||
|
||||
set__listrelay() {
|
||||
role="relay"
|
||||
ynh_app_setting_set --app=$app --key=listrelay --value="$listrelay"
|
||||
apply_permissions
|
||||
ynh_store_file_checksum --file="$final_path/config.yaml"
|
||||
ynh_store_file_checksum --file="$install_dir/config.yaml"
|
||||
}
|
||||
|
||||
set__listadmin() {
|
||||
role="admin"
|
||||
ynh_app_setting_set --app=$app --key=listadmin --value="$listadmin"
|
||||
apply_permissions
|
||||
ynh_store_file_checksum --file="$final_path/config.yaml"
|
||||
ynh_store_file_checksum --file="$install_dir/config.yaml"
|
||||
}
|
|
@ -10,26 +10,6 @@
|
|||
source ../settings/scripts/_common.sh
|
||||
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
|
||||
#=================================================
|
||||
|
@ -39,7 +19,7 @@ ynh_print_info --message="Declaring files to be backed up..."
|
|||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$final_path"
|
||||
ynh_backup --src_path="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
|
|
|
@ -3,8 +3,6 @@ source _common.sh
|
|||
source /usr/share/yunohost/helpers
|
||||
ynh_abort_if_errors
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC GETTERS FOR TOML SHORT KEY
|
||||
#=================================================
|
||||
|
@ -15,7 +13,7 @@ get__botname() {
|
|||
}
|
||||
|
||||
get__listuser() {
|
||||
existingUsers=$(grep -- "\".*: user" "$final_path/config.yaml" | sed -r 's/: user//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr '\n' ',')
|
||||
existingUsers=$(grep -- "\".*: user" "$install_dir/config.yaml" | sed -r 's/: user//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr '\n' ',')
|
||||
|
||||
cat <<EOF
|
||||
"$existingUsers"
|
||||
|
@ -23,7 +21,7 @@ EOF
|
|||
}
|
||||
|
||||
get__listrelay() {
|
||||
existingRelayUsers=$(grep -- "\".*: relay" "$final_path/config.yaml" | sed -r 's/: relay//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr '\n' ',')
|
||||
existingRelayUsers=$(grep -- "\".*: relay" "$install_dir/config.yaml" | sed -r 's/: relay//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr '\n' ',')
|
||||
|
||||
cat <<EOF
|
||||
"$existingRelayUsers"
|
||||
|
@ -31,7 +29,7 @@ EOF
|
|||
}
|
||||
|
||||
get__listadmin() {
|
||||
existingAdmins=$(grep -- "\".*: admin" "$final_path/config.yaml" | sed -r 's/: admin//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr '\n' ',')
|
||||
existingAdmins=$(grep -- "\".*: admin" "$install_dir/config.yaml" | sed -r 's/: admin//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr '\n' ',')
|
||||
|
||||
cat <<EOF
|
||||
"$existingAdmins"
|
||||
|
@ -56,12 +54,12 @@ set__botname() {
|
|||
ynh_app_setting_set --app=$app --key=botname --value="$botname"
|
||||
synapse_instance=$(ynh_app_setting_get --app $app --key synapse_instance)
|
||||
|
||||
sed -i "s/username:.*/username: $botname/" "$final_path/config.yaml"
|
||||
"$final_path/mautrix-whatsapp" -g -c "$final_path/config.yaml" -r "/etc/matrix-$synapse_instance/app-service/$app.yaml"
|
||||
sed -i "s/username:.*/username: $botname/" "$install_dir/config.yaml"
|
||||
"$install_dir/mautrix-whatsapp" -g -c "$install_dir/config.yaml" -r "/etc/matrix-$synapse_instance/app-service/$app.yaml"
|
||||
"/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh" || ynh_die --message="Synapse can't restart with the appservice configuration"
|
||||
chown -R "$app:$app" "$final_path"
|
||||
chown -R "$app:$app" "$install_dir"
|
||||
ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml"
|
||||
ynh_store_file_checksum --file="$final_path/config.yaml"
|
||||
ynh_store_file_checksum --file="$install_dir/config.yaml"
|
||||
}
|
||||
|
||||
ynh_app_config_run $1
|
||||
|
|
120
scripts/install
120
scripts/install
|
@ -9,39 +9,11 @@
|
|||
source _common.sh
|
||||
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
|
||||
#=================================================
|
||||
|
||||
appserviceid=$YNH_APP_INSTANCE_NAME
|
||||
synapsenumber=$YNH_APP_ARG_SYNAPSENUMBER
|
||||
botname=$YNH_APP_ARG_BOTNAME
|
||||
bot_synapse_adm=$YNH_APP_ARG_BOT_SYNAPSE_ADM
|
||||
encryption=$YNH_APP_ARG_ENCRYPTION
|
||||
listadmin=$YNH_APP_ARG_BOTADMIN
|
||||
listuser=$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_whatsapp bridge
|
||||
if [ $synapsenumber -eq "1" ]
|
||||
then
|
||||
synapse_instance="synapse"
|
||||
else
|
||||
synapse_instance="synapse__$synapsenumber"
|
||||
fi
|
||||
# Retrieve some values from selected Synapse instance and store them
|
||||
server_name=$(ynh_app_setting_get --app $synapse_instance --key server_name)
|
||||
domain=$(ynh_app_setting_get --app $synapse_instance --key domain)
|
||||
ynh_app_setting_set --app=$app --key=server_name --value=$server_name
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
synapse_db_name="matrix_$synapse_instance"
|
||||
|
||||
# This is needed to convert the value from the manifest to a valid value for the config.yaml file.
|
||||
|
@ -57,6 +29,7 @@ fi
|
|||
# SET STANDARD SETTINGS FROM DEFAULT CONFIG
|
||||
#=================================================
|
||||
|
||||
appserviceid=$app
|
||||
async_media="false"
|
||||
displayname="WhatsApp bridge bot"
|
||||
avatar="mxc://maunium.net/NeXNQarUbrlYBiPCpprYsRqr"
|
||||
|
@ -76,7 +49,10 @@ admin_only="true"
|
|||
print_level="info"
|
||||
enable_relaybot="true"
|
||||
listrelay="*"
|
||||
listadmin="$botadmin"
|
||||
listuser="$botusers"
|
||||
|
||||
ynh_app_setting_set --app=$app --key=appserviceid --value=$appserviceid
|
||||
ynh_app_setting_set --app=$app --key=async_media --value=$async_media
|
||||
ynh_app_setting_set --app=$app --key=displayname --value=$displayname
|
||||
ynh_app_setting_set --app=$app --key=avatar --value=$avatar
|
||||
|
@ -97,79 +73,17 @@ ynh_app_setting_set --app=$app --key=admin_only --value=$admin_only
|
|||
ynh_app_setting_set --app=$app --key=print_level --value=$print_level
|
||||
ynh_app_setting_set --app=$app --key=listrelay --value=$listrelay
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
||||
|
||||
final_path=/opt/yunohost/$app
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing installation settings..." --weight=7
|
||||
|
||||
ynh_app_setting_set --app=$app --key=appserviceid --value=$appserviceid
|
||||
ynh_app_setting_set --app=$app --key=botname --value=$botname
|
||||
ynh_app_setting_set --app=$app --key=bot_synapse_adm --value=$bot_synapse_adm
|
||||
ynh_app_setting_set --app=$app --key=encryption --value=$encryption
|
||||
ynh_app_setting_set --app=$app --key=listuser --value=$listuser
|
||||
ynh_app_setting_set --app=$app --key=listadmin --value=$listadmin
|
||||
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
|
||||
|
||||
#=================================================
|
||||
# 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_whatsapp.
|
||||
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
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --weight=5
|
||||
|
||||
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" --source_id=$YNH_ARCH
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R 750 "$final_path"
|
||||
chown -R $app:$app "$final_path"
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R 750 "$install_dir"
|
||||
chown -R $app:$app "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
|
@ -178,10 +92,10 @@ chown -R $app:$app "$final_path"
|
|||
#=================================================
|
||||
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="../conf/config.yaml" --destination="$install_dir/config.yaml"
|
||||
|
||||
chmod 400 "$final_path/config.yaml"
|
||||
chown $app:$app "$final_path/config.yaml"
|
||||
chmod 400 "$install_dir/config.yaml"
|
||||
chown $app:$app "$install_dir/config.yaml"
|
||||
|
||||
# This calls allows to set multiple users during install question "botusers" specifying them separated by a comma
|
||||
set__listuser
|
||||
|
@ -193,12 +107,12 @@ set__listadmin
|
|||
#=================================================
|
||||
ynh_script_progression --message="Registering Synapse app-service" --weight=1
|
||||
|
||||
$final_path/mautrix-whatsapp -g -c $final_path/config.yaml -r /etc/matrix-$synapse_instance/app-service/$app.yaml
|
||||
$install_dir/mautrix-whatsapp -g -c $install_dir/config.yaml -r /etc/matrix-$synapse_instance/app-service/$app.yaml
|
||||
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die --message="Synapse can't restart with the appservice configuration"
|
||||
|
||||
chown -R $app:$app "$final_path"
|
||||
chown -R $app:$app "$install_dir"
|
||||
ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml"
|
||||
ynh_store_file_checksum --file="$final_path/config.yaml"
|
||||
ynh_store_file_checksum --file="$install_dir/config.yaml"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
|
|
|
@ -16,13 +16,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=5
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
appserviceid=$(ynh_app_setting_get --app=$app --key=appserviceid)
|
||||
botname=$(ynh_app_setting_get --app=$app --key=botname)
|
||||
synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
|
||||
server_name=$(ynh_app_setting_get --app=$app --key=server_name)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
synapse_db_name="matrix_$synapse_instance"
|
||||
bot_synapse_db_user="@""$botname"":""$server_name"
|
||||
|
||||
|
@ -55,46 +49,6 @@ ynh_script_progression --message="Removing logrotate configuration..." --weight=
|
|||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=4
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name"
|
||||
|
||||
if ynh_psql_user_exists --user="$app"; then
|
||||
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\";"
|
||||
fi
|
||||
|
||||
if ynh_psql_user_exists --user="$bot_synapse_db_user"; then
|
||||
ynh_psql_execute_as_root --database="$synapse_db_name" --sql="DROP OWNED BY \"$bot_synapse_db_user\";"
|
||||
ynh_psql_execute_as_root --database="$synapse_db_name" --sql="DROP USER \"$bot_synapse_db_user\";"
|
||||
fi
|
||||
|
||||
if ynh_psql_user_exists --user="$botname"; then
|
||||
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\";"
|
||||
fi
|
||||
#yunohost app action run $synapse_instance drop_user -a username=$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
|
||||
#=================================================
|
||||
|
@ -109,16 +63,6 @@ ynh_secure_remove --file="/etc/matrix-$synapse_instance/app-service/$app.yaml"
|
|||
# Remove the log files
|
||||
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
|
||||
#=================================================
|
||||
|
|
|
@ -10,87 +10,29 @@
|
|||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=5
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
server_name=$(ynh_app_setting_get --app=$app --key=server_name)
|
||||
appserviceid=$(ynh_app_setting_get --app=$app --key=appserviceid)
|
||||
botname=$(ynh_app_setting_get --app=$app --key=botname)
|
||||
synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
|
||||
bot_synapse_adm=$(ynh_app_setting_get --app=$app --key=bot_synapse_adm)
|
||||
encryption=$(ynh_app_setting_get --app=$app --key=encryption)
|
||||
botusers=$(ynh_app_setting_get --app=$app --key=botusers)
|
||||
botadmin=$(ynh_app_setting_get --app=$app --key=botadmin)
|
||||
previous_mautrix_version=$(ynh_app_setting_get --app=$app --key=mautrix_version)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
|
||||
synapse_db_name="matrix_$synapse_instance"
|
||||
bot_synapse_db_user="@$botname:$server_name"
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
#=================================================
|
||||
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 750 "$final_path"
|
||||
chown -R $app:$app "$final_path"
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R 750 "$install_dir"
|
||||
chown -R $app:$app "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=100
|
||||
|
||||
# Define and install dependencies
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=8
|
||||
|
||||
ynh_psql_test_if_first_run
|
||||
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
|
||||
|
||||
#=================================================
|
||||
|
@ -98,9 +40,12 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
|
|||
#=================================================
|
||||
ynh_script_progression --message="Registering Synapse app-service" --weight=1
|
||||
|
||||
$final_path/mautrix-whatsapp -g -c $final_path/config.yaml -r /etc/matrix-$synapse_instance/app-service/$app.yaml
|
||||
$install_dir/mautrix-whatsapp -g -c $install_dir/config.yaml -r /etc/matrix-$synapse_instance/app-service/$app.yaml
|
||||
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die "Synapse can't restart with the appservice configuration"
|
||||
|
||||
chmod 400 "$install_dir/config.yaml"
|
||||
chown $app:$app "$install_dir/config.yaml"
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
#=================================================
|
||||
|
@ -115,7 +60,7 @@ systemctl enable $app.service --quiet
|
|||
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
mkdir -p /var/log/$app
|
||||
mkdir --parents "/var/log/$app"
|
||||
chmod -R 600 "/var/log/$app"
|
||||
chmod 700 "/var/log/$app"
|
||||
chown -R $app:$app /var/log/$app
|
||||
|
|
|
@ -9,24 +9,8 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=5
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
appserviceid=$(ynh_app_setting_get --app=$app --key=appserviceid)
|
||||
botname=$(ynh_app_setting_get --app=$app --key=botname)
|
||||
encryption=$(ynh_app_setting_get --app=$app --key=encryption)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
|
||||
server_name=$(ynh_app_setting_get --app=$app --key=server_name)
|
||||
|
||||
synapse_db_name="matrix_$synapse_instance"
|
||||
bot_synapse_db_user="@$botname:$server_name"
|
||||
|
||||
|
@ -63,20 +47,6 @@ 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=10
|
||||
|
||||
# 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
|
||||
#=================================================
|
||||
|
@ -228,19 +198,6 @@ then
|
|||
ynh_app_setting_delete --app=$app --key=botadmin
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=8
|
||||
|
||||
# Create a dedicated user (if not existing) and set home dir to /opt/yunohost/$app so systemd hardening works
|
||||
# See more: https://docs.mau.fi/bridges/go/setup.html?bridge=whatsapp#systemd-service
|
||||
if ynh_system_user_exists -u "$app"; then
|
||||
usermod --home "$final_path" $app
|
||||
else
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
@ -250,19 +207,12 @@ then
|
|||
ynh_script_progression --message="Upgrading source files..." --weight=2
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path" --source_id=$YNH_ARCH
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
fi
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chmod -R 750 "$final_path"
|
||||
chown -R $app:$app "$final_path"
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..." --weight=100
|
||||
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R 750 "$install_dir"
|
||||
chown -R $app:$app "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
|
@ -279,10 +229,10 @@ listrelay="*"
|
|||
listuser="@user:domain.tld"
|
||||
listadmin="@admin:domain.tld"
|
||||
|
||||
ynh_add_config --template="../conf/config.yaml" --destination="$final_path/config.yaml"
|
||||
ynh_add_config --template="../conf/config.yaml" --destination="$install_dir/config.yaml"
|
||||
|
||||
chmod 400 "$final_path/config.yaml"
|
||||
chown $app:$app "$final_path/config.yaml"
|
||||
chmod 400 "$install_dir/config.yaml"
|
||||
chown $app:$app "$install_dir/config.yaml"
|
||||
|
||||
listrelay=$listrelay_
|
||||
listuser=$listuser_
|
||||
|
@ -298,13 +248,13 @@ set__listadmin
|
|||
#=================================================
|
||||
ynh_script_progression --message="Registering Synapse app-service" --weight=1
|
||||
|
||||
$final_path/mautrix-whatsapp -g -c $final_path/config.yaml -r /etc/matrix-$synapse_instance/app-service/$app.yaml
|
||||
$install_dir/mautrix-whatsapp -g -c $install_dir/config.yaml -r /etc/matrix-$synapse_instance/app-service/$app.yaml
|
||||
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die "Synapse can't restart with the appservice configuration"
|
||||
|
||||
# Set permissions on app files
|
||||
chown -R $app:$app "$final_path"
|
||||
chown -R $app:$app "$install_dir"
|
||||
ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml"
|
||||
ynh_store_file_checksum --file="$final_path/config.yaml"
|
||||
ynh_store_file_checksum --file="$install_dir/config.yaml"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
|
|
51
tests.toml
Normal file
51
tests.toml
Normal file
|
@ -0,0 +1,51 @@
|
|||
test_format = 1.0
|
||||
|
||||
[default]
|
||||
|
||||
# ------------
|
||||
# Tests to run
|
||||
# ------------
|
||||
|
||||
# For special usecases, sometimes you need to setup other things on the machine
|
||||
# prior to installing the app (such as installing another app)
|
||||
# (Remove this key entirely if not needed)
|
||||
preinstall = """
|
||||
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
|
||||
"""
|
||||
|
||||
# -------------------------------
|
||||
# Default args to use for install
|
||||
# -------------------------------
|
||||
|
||||
# By default, the CI will automagically fill the 'standard' args
|
||||
# such as domain, path, admin, is_public and password with relevant values
|
||||
# and also install args with a "default" provided in the manifest..
|
||||
# It should only make sense to declare custom args here for args with no default values
|
||||
|
||||
args.botadmin = "@johndoe:server.name"
|
||||
args.botusers = "server.name"
|
||||
|
||||
# -------------------------------
|
||||
# Commits to test upgrade from
|
||||
# -------------------------------
|
||||
|
||||
test_upgrade_from.1d57a3b.name = "Upgrade from 0.7.2" # After config panel was implemented
|
||||
|
||||
test_upgrade_from.ede12ed.name = "Upgrade from 0.8.0"
|
||||
|
||||
|
||||
# This is an additional test suite
|
||||
[multiple_botusers]
|
||||
|
||||
preinstall = """
|
||||
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
|
||||
"""
|
||||
|
||||
# On additional tests suites, you can decide to run only specific tests
|
||||
|
||||
only = ["install.subdir"]
|
||||
|
||||
args.botadmin = "@johndoe:server.name"
|
||||
args.botusers = "@john:server.name,@jdoe:server.name,@janedoe:server.name"
|
Loading…
Add table
Reference in a new issue