diff --git a/README.md b/README.md
index 2149d38..40f4fb6 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
*[Lire ce readme en français.](./README_fr.md)*
-> *This package allows you to install Mautrix-WhatsApp quickly and simply on a YunoHost server.
+> *This package allows you to install a Mautrix-WhatsApp bridge quickly and simply on a YunoHost server alongside Matrix-Synapse.
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
## Overview
@@ -20,37 +20,67 @@ A puppeting bridge between Matrix and WhatsApp packaged as a YunoHost service. M
## Demo
-* [Official demo](Link to a demo site for this app)
+* If you want to test the bridge, send an email to the App maintainer with the matrix user account you want to bridge to WhatsApp.
-## Configuration
+## Bridging usage
+### 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) in this new matrix-whatsapp bot 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://github.com/tulir/mautrix-whatsapp/wiki/Authentication)
-How to configure this app: by an admin panel, a plain file with SSH, or any other way.
+** Note that several WhatsApp and Matrix users can be bridge, each users has its own bot administration room. If they are in a same WhatsApp group, only one matrix room will be created. **
+
+### Bridge a WhatsApp group in Matrix "Relaybot"
+* First Relaybot option should be enabled in the bridge configuration (default=disabled, see below)
+* Once the bot administration room is setup, you can also bridge all messages between a Matrix room and a WhatsApp room/group.
+In whatsapp all messages will be sent by the account who is logged in with a prefix for the source matrix user. On the matrix side the bridge will still create matrix users corresponding to the whatsapp users when they send a message.
+See also [upstream wiki Relaybot page](https://github.com/tulir/mautrix-whatsapp/wiki/Relaybot)
+
+## Configuration of the bridge
+
+The bridge is roughly configured at installation, 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.
## Documentation
- * Official documentation: https://github.com/tulir/mautrix-whatsapp/wiki
+ * Official "mautrix-whatsapp" documentation: https://github.com/tulir/mautrix-whatsapp/wiki
+ * Matrix room: #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.
* YunoHost documentation: If specific documentation is needed, feel free to contribute.
## YunoHost specific features
#### Multi-users support
-Are LDAP and HTTP auth supported?
-Can the app be used by multiple users?
+* Bot users are not related to Yunohost users. Any matrix account or server autorized in the configuration of the bridge can 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.
+
+Multi-instance installation should work, but was not tested yet. A priori it makes only sense if several synapse instances are installed.
#### Supported architectures
-* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/REPLACEBYYOURAPP/)
-* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/REPLACEBYYOURAPP/)
-* Jessie x86-64b - [](https://ci-stretch.nohost.me/ci/apps/REPLACEBYYOURAPP/)
+* Tested on ARMv7 in April 2020
+* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/mautrix-whatsapp_ynh/)
+* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/mautrix-whatsapp_ynh/)
+* Jessie x86-64b - [](https://ci-stretch.nohost.me/ci/apps/mautrix-whatsapp_ynh/)
## Limitations
-* Audio/Video calls are not bridged yet. It is recommended to install whatsapp on a virtual android running on a server. If whatsapp loses connection, e.g. the phone is set in flight mode, the bot has to be restarted by sending a reconnnect message in the matrix administration room.
+* 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
-* Other information you would add about this application
+* It is recommended to install whatsapp on a virtual android running on a server, see [upstream wiki Android-VM-Setup page](https://github.com/tulir/mautrix-whatsapp/wiki/Android-VM-Setup)
**More information on the documentation page:**
https://github.com/tulir/mautrix-whatsapp/wiki
@@ -60,6 +90,8 @@ https://github.com/tulir/mautrix-whatsapp/wiki
* Report a bug: https://github.com/YunoHost-Apps/mautrix-whatsapp_ynh/issues
* App website: https://github.com/Gredin67/mautrix-whatsapp_ynh
* Upstream app repository: https://github.com/tulir/mautrix-whatsapp
+ * Up-Upstream repository: https://github.com/Rhymen/go-whatsapp
+ * Up-Up-Upstream repository: https://github.com/sigalor/whatsapp-web-reveng
* YunoHost website: https://yunohost.org/
---
@@ -67,12 +99,8 @@ https://github.com/tulir/mautrix-whatsapp/wiki
Developers info
----------------
-**Only if you want to use a testing branch for coding, instead of merging directly into master.**
-Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/tree/testing).
-
-To try the testing branch, please proceed like that.
+To test communication between the app service and synapse on a VM, you must install a certificate:
```
-sudo yunohost app install https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/tree/testing --debug
-or
-sudo yunohost app upgrade REPLACEBYYOURAPP -u https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/tree/testing --debug
+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
```
diff --git a/check_process.default b/check_process
similarity index 53%
rename from check_process.default
rename to check_process
index 97a2bc5..bda783c 100644
--- a/check_process.default
+++ b/check_process
@@ -4,37 +4,46 @@
# Move this file from check_process.default to check_process when you have filled it.
;; Test complet
+ auto_remove=1
; Manifest
domain="domain.tld" (DOMAIN)
- path="/path" (PATH)
- admin="john" (USER)
- language="fr"
+ #path="/_matrix/static/" (PATH)
+ #admin="john" (USER)
+ #language="en"
is_public=1 (PUBLIC|public=1|private=0)
- password="pass"
- port="666" (PORT)
+ #password="pass"
+ #port="666" (PORT)
+
+ whatsappbot="whatsappbot"
+ botadmin="@johndoe:domain.tld"
+ botusers="@johndoe:domain.tld"
+ ; pre-install
+ sudo yunohost app fetchlist
+ #sudo yunohost domain add baikaldomain.tld --admin-password $PASSWORD
+ sudo yunohost app install synapse -a "domain=domain.tld&server_name="Same than the domain"&is_public=1"
; Checks
pkg_linter=1
setup_sub_dir=1
setup_root=1
setup_nourl=0
- setup_private=1
+ setup_private=0
setup_public=1
- upgrade=1
- upgrade=1 from_commit=CommitHash
- backup_restore=1
+ upgrade=0
+ #upgrade=1 from_commit=CommitHash
+ backup_restore=0
multi_instance=1
# This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
# incorrect_path=1
port_already_use=0
- change_url=1
+ change_url=0
;;; Levels
# If the level 5 (Package linter) is forced to 1. Please add justifications here.
Level 5=auto
;;; Options
-Email=
+#Email=
Notification=none
;;; Upgrade options
; commit=CommitHash
- name=Name and date of the commit.
- manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&
+ #name=Name and date of the commit.
+ #manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&
diff --git a/conf/systemd.service b/conf/systemd.service
index 417e8c1..30624b1 100644
--- a/conf/systemd.service
+++ b/conf/systemd.service
@@ -6,7 +6,7 @@ After=matrix-synapse.service
Type=simple
User=__APP__
WorkingDirectory=/opt/yunohost/__APP__
-ExecStart=/opt/yunohost/__APP__/mautrix-whatsapp -c=/opt/yunohost/__APP__/config.yaml >> /var/log/__APP__/__APP__.log 2>&1
+ExecStart=/opt/yunohost/__APP__/mautrix-whatsapp -c=/opt/yunohost/__APP__/config.yaml >> /var/log/__APP__/log.log 2>&1
Restart=always
RestartSec=3
diff --git a/manifest.json b/manifest.json
index 1e76581..b3e9752 100644
--- a/manifest.json
+++ b/manifest.json
@@ -11,8 +11,8 @@
"license": "AGPL3",
"maintainer": {
"name": "Gredin67",
- "email": "ghentz@mailz.org",
- "url": "https://github.com/YunoHost-Apps/mautrix-whatsapp_ynh"
+ "email": "mautrix_whatsapp@neutralite.org",
+ "url": "https://github.com/Gredin67/mautrix_whatsapp_ynh"
},
"requirements": {
"yunohost": ">= 3.5"
@@ -23,55 +23,70 @@
],
"arguments": {
"install": [
- {
- "name": "domain",
- "type": "domain",
+ {
+ "name": "port",
+ "type": "string",
"ask": {
- "en": "Choose the domain name where Synapse is installed.",
- "fr": "Choisissez le nom de domaine associé à Synapse."
+ "en": "Choose a port for communication between mautrix_whatsapp (app service) and synapse (home server)",
+ "fr": "Choisissez un port pour la communication entre mautrix_whatsapp (app service) et synapse (home server)"
},
- "example": "domain.org"
+ "example": "29318",
+ "default": "8449"
+ },
+ {
+ "name": "synapsenumber",
+ "type": "string",
+ "ask": {
+ "en": "Choose the local synapse instance number to communicate with app service",
+ "fr": "Choisissez le numéro de l'instance synapse qui doit communiquer avec l'app service"
+ },
+ "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": "whatsappbot",
"type": "string",
"ask": {
- "en": "Choose the user name of the whatsapp bot for which to create a YunoHost and a local synapse server account.",
- "fr": "Choisissez le nom d'utilisateur du robot whatsapp pour lequel un compte sera créé sur YunoHost et le serveur local synapse."
+ "en": "Choose a local Matrix/Synapse user name for the WhatsApp bot",
+ "fr": "Choisissez un nom d'utilisateur local Matrix/Synapse 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. Give 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. Donner le nom du serveur matrix, pas le domaine/url complet."
+ },
"default": "whatsappbot"
},
{
"name": "botadmin",
"type": "string",
"ask": {
- "en": "Choose the matrix account administrator of the whatsapp bot.",
- "fr": "Choisissez le compte matrix administrateur du robot whatsapp."
+ "en": "Choose the Matrix account administrator of the WhatsApp bot",
+ "fr": "Choisissez le compte Matrix administrateur du robot WhatsApp"
},
- "example": "@johndoe:domain.org or @johndoe:matrix.org",
- "default": "Your main matrix account"
+ "example": "@johndoe:localsynapse.servername or @johndoe:matrix.org",
+ "help": {
+ "en": "The WhatsApp bot administrator does not need to be a local Matrix/Synapse account.",
+ "fr": "Le compte administrateur du robot WhatsApp peut ne pas être un compte local Matrix/Synapse."
+ },
+ "default": "Your main Matrix account"
},
{
"name": "botusers",
"type": "string",
"ask": {
- "en": "Choose a matrix server authorized to use the whatsapp bot.",
- "fr": "Choisissez un serveur matrix dont tous les utilisateurs sont autorisés à utiliser le robot whatsapp."
+ "en": "Choose Matrix user(s) authorized to bridge with the WhatsApp bot",
+ "fr": "Choisissez le/les compte(s) Matrix autorisés à utiliser le robot WhatsApp"
},
- "example": "matrix.org"
- },
- {
- "name": "is_public",
- "type": "boolean",
- "ask": {
- "en": "Is it a public bot?",
- "fr": "Est-ce un robot public ?"
- },
- "default": true,
+ "example": "admin or local or @johndoe:server.name or server.name or *",
+ "default": "admin",
"help": {
- "en": "A public bot means anyone with a matrix account on the synapse server will be able to use the bot.",
- "fr": "Un robot public signifie que chaque compte matrix du serveur synapse pourra utiliser le robot."
+ "en": "Either the administrator only (admin), all local Matrix/Synapse users (local), a remote or local user (@johndoe:server.name), a remote server (matrix.org), or all remote/local servers (*) can be authorized. Give the matrix server_name, not the full domain/url.",
+ "fr": "On peut autoriser le compte administrateur seul (admin), tous les comptes Matrix/Synapse locaux (local), un compte local ou distant (@johndoe:server.name), un serveur distant (matrix.org), ou tous les serveurs remote/local (*). Donner le nom du serveur matrix, pas le domaine/url complet."
}
}
]
diff --git a/scripts/_common.sh b/scripts/_common.sh
index 4a4af3a..471f4f6 100644
--- a/scripts/_common.sh
+++ b/scripts/_common.sh
@@ -6,7 +6,8 @@
# dependencies used by the app
pkg_dependencies=""
-GO_VERSION="1.14.2"
+GO_VERSION="1.11"
+GO_PATH="/usr/lib/go-$GO_VERSION/bin"
#=================================================
# PERSONAL HELPERS
diff --git a/scripts/install b/scripts/install
index 7e911e8..b7d3c27 100755
--- a/scripts/install
+++ b/scripts/install
@@ -8,7 +8,7 @@
source _common.sh
#source /opt/yunohost/mautrix-whatsapp/_ynh_install_extra_app_dependencies
-#source _ynh_install_extra_app_dependencies
+source _ynh_install_extra_app_dependencies
source /usr/share/yunohost/helpers
#=================================================
@@ -26,12 +26,14 @@ ynh_abort_if_errors
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
-domain=$YNH_APP_ARG_DOMAIN
+#domain=$YNH_APP_ARG_DOMAIN
#path_url=$YNH_APP_ARG_PATH
+port=$YNH_APP_ARG_PORT
+synapsenumber=$YNH_APP_ARG_SYNAPSENUMBER
whatsappbot=$YNH_APP_ARG_WHATSAPPBOT
botadmin=$YNH_APP_ARG_BOTADMIN
botusers=$YNH_APP_ARG_BOTUSERS
-is_public=$YNH_APP_ARG_IS_PUBLIC
+#is_public=$YNH_APP_ARG_IS_PUBLIC
#language=$YNH_APP_ARG_LANGUAGE
#password=$YNH_APP_ARG_PASSWORD
@@ -47,6 +49,17 @@ is_public=$YNH_APP_ARG_IS_PUBLIC
### db names, ...
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
+server_name=$(ynh_app_setting_get --app synapse --key server_name)
+domain=$(ynh_app_setting_get --app synapse --key domain)
+else
+server_name=$(ynh_app_setting_get --app synapse__$synapsenumber --key server_name)
+domain=$(ynh_app_setting_get --app synapse__$synapsenumber --key domain)
+fi
+
+
#=================================================
# SET CONSTANTS
#=================================================
@@ -86,13 +99,15 @@ test ! -e "$final_path" || ynh_die --message="This path already contains a folde
ynh_script_progression --message="Storing installation settings..." --time --weight=1
ynh_app_setting_set --app=$app --key=domain --value=$domain
+ynh_app_setting_set --app=$app --key=server_name --value=$server_name
+ynh_app_setting_set --app=$app --key=port --value=$port
#ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=whatsappbot --value=$whatsappbot
ynh_app_setting_set --app=$app --key=botadmin --value=$botadmin
ynh_app_setting_set --app=$app --key=botusers --value=$botusers
ynh_app_setting_set --app=$app --key=mautrix_version --value=$upstream_version
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
-ynh_app_setting_set --app=$app --key=is_public --value=$is_public
+#ynh_app_setting_set --app=$app --key=is_public --value=$is_public
#ynh_app_setting_set --app=$app --key=language --value=$language
#=================================================
@@ -126,7 +141,7 @@ ynh_script_progression --message="Installing dependencies..." --time --weight=1
### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
-#ynh_install_extra_app_dependencies --repo="http://http.debian.net/debian stretch-backports main" --package="golang-1.11"
+ynh_install_extra_app_dependencies --repo="http://http.debian.net/debian stretch-backports main" --package="golang-1.11"
#ynh_install_extra_app_dependencies --repo="http://http.debian.net/debian $(lsb_release -sc)" --package="golang-1.11"
ynh_install_app_dependencies $pkg_dependencies
@@ -135,12 +150,12 @@ ynh_install_app_dependencies $pkg_dependencies
# INSTALL GO
#=================================================
-type /usr/local/go/bin/go > /dev/null || {
- ynh_script_progression --message="Installing go..." --time --weight=1
- wget https://dl.google.com/go/go$GO_VERSION.linux-$architecture.tar.gz -q
- tar -C /usr/local -xzf go$GO_VERSION.linux-$architecture.tar.gz
-}
-export PATH=$PATH:/usr/local/go/bin
+#type /usr/lib/go-$GO_VERSION/bin/go > /dev/null || {
+# ynh_script_progression --message="Installing go..." --time --weight=1
+# wget https://dl.google.com/go/go$GO_VERSION.linux-$architecture.tar.gz -q
+# tar -C /usr/lib -xzf go$GO_VERSION.linux-$architecture.tar.gz
+#}
+export PATH=$PATH:/usr/lib/go-$GO_VERSION/bin
#=================================================
# CREATE A POSTGRESQL DATABASE
@@ -217,6 +232,7 @@ ynh_add_systemd_config --service=$app
cd $final_path
#echo 'export PATH=$PATH:/usr/lib/go-1.11/bin/' >> /etc/profile
#source /etc/profile
+export PATH=$PATH:/usr/lib/go-$GO_VERSION/bin
go build
#Copy example-config.yaml to config.yaml
cp example-config.yaml config.yaml
@@ -241,17 +257,17 @@ cp example-config.yaml config.yaml
ynh_replace_string --match_string="address: https://example.com" --replace_string="address: https://$domain" --target_file="$final_path/config.yaml"
# The domain of the homeserver (for MXIDs, etc).
#"domain: example.com"
-ynh_replace_string --match_string="domain: example.com" --replace_string="domain: $domain" --target_file="$final_path/config.yaml"
+ynh_replace_string --match_string="domain: example.com" --replace_string="domain: $server_name" --target_file="$final_path/config.yaml"
# Application service host/registration related details.
# Changing these values requires regeneration of the registration.
#appservice:
# The address that the homeserver can use to connect to this appservice.
-ynh_replace_string --match_string="address: http://localhost:29318" --replace_string="address: http://0.0.0.0:8449" --target_file="$final_path/config.yaml"
+ynh_replace_string --match_string="address: http://localhost:29318" --replace_string="address: http://localhost:$port" --target_file="$final_path/config.yaml"
# The hostname and port where this appservice should listen.
#ynh_replace_string --match_string="hostname: 0.0.0.0" --replace_string="hostname: 0.0.0.0" --target_file="$final_path/config.yaml"
-ynh_replace_string --match_string="port: 29318" --replace_string="port: 8449" --target_file="$final_path/config.yaml"
+ynh_replace_string --match_string="port: 29318" --replace_string="port: $port" --target_file="$final_path/config.yaml"
# Database config.
#database:
@@ -264,17 +280,25 @@ ynh_replace_string --match_string="uri: mautrix-whatsapp.db" --replace_string="u
# The unique ID of this appservice.
#id: whatsapp
- ynh_replace_string --match_string="id: whatsapp" --replace_string="id: $app" --target_file="$final_path/config.yaml"
+ ynh_replace_string --match_string="id: whatsapp" --replace_string="id: $whatsappbot" --target_file="$final_path/config.yaml"
# Appservice bot details.
#bot:
# Username of the appservice bot.
#username: whatsappbot
- ynh_replace_string --match_string="username: whatsappbot" --replace_string="username: $mautrix_whatsapp_user" --target_file="$final_path/config.yaml"
-
-
+ ynh_replace_string --match_string="username: whatsappbot" --replace_string="username: $whatsappbot" --target_file="$final_path/config.yaml"
+# Bridge config
+#bridge:
+ # Localpart template of MXIDs for WhatsApp users.
+ # {{.}} is replaced with the phone number of the WhatsApp user.
+ #username_template: whatsapp_{{.}}
+ #ynh_replace_string --match_string="username_template: whatsapp" --replace_string="username_template: $whatsappbot" --target_file="$final_path/config.yaml"
+ # {{.Localpart}} is the MXID localpart and {{.Server}} is the MXID server part of the user.
+ #community_template: whatsapp_{{.Localpart}}={{.Server}}
+ #ynh_replace_string --match_string="community_template: whatsapp" --replace_string="community_template: $whatsappbot" --target_file="$final_path/config.yaml"
+
# Maximum number of connections. Mostly relevant for Postgres.
-ynh_replace_string --match_string="max_open_conns: 20" --replace_string="max_open_conns: 20" --target_file="$final_path/config.yaml"
-ynh_replace_string --match_string="max_idle_conns: 2" --replace_string="max_idle_conns: 2" --target_file="$final_path/config.yaml"
+#ynh_replace_string --match_string="max_open_conns: 20" --replace_string="max_open_conns: 20" --target_file="$final_path/config.yaml"
+#ynh_replace_string --match_string="max_idle_conns: 2" --replace_string="max_idle_conns: 2" --target_file="$final_path/config.yaml"
#You will also need to add your user of admin user under the permissions section.
# Permissions for using the bridge.
@@ -288,18 +312,21 @@ ynh_replace_string --match_string="max_idle_conns: 2" --replace_string="max_idle
# mxid - Specific user
#permissions:
# "*": relaybot
-# "example.com": user
+#ynh_replace_string --match_string="'*': relaybot" --replace_string="'': relaybot" --target_file="$final_path/config.yaml"
# "@admin:example.com": admin
-#ynh_replace_string --match_string=""*": relaybot" --replace_string=""*": relaybot" --target_file="$final_path/config.yaml"
ynh_replace_string --match_string="@admin:example.com" --replace_string="$botadmin" --target_file="$final_path/config.yaml"
-# Make app public if necessary
-if [ $is_public -eq 1 ]
+# "example.com": user
+if [ "$botusers" = "domain" ]
then
-ynh_replace_string --match_string="example.com" --replace_string="domain" --target_file="$final_path/config.yaml"
+ynh_replace_string --match_string="example.com" --replace_string="$server_name" --target_file="$final_path/config.yaml"
+elif [ "$botusers" = "admin" ]
+then
+ynh_replace_string --match_string="'example.com': user" --replace_string="#'example.com': user" --target_file="$final_path/config.yaml"
else
ynh_replace_string --match_string="example.com" --replace_string="$botusers" --target_file="$final_path/config.yaml"
fi
+
# relaybot:
# # Whether or not relaybot support is enabled.
# enabled: false
@@ -320,6 +347,27 @@ fi
# m.video: "{{ .Sender.Displayname }} sent a video"
# m.location: "{{ .Sender.Displayname }} sent a location"
+# Logging config.
+#logging:
+ # The directory for log files. Will be created if not found.
+ #directory: ./logs
+ ynh_replace_string --match_string="directory: ./logs" --replace_string="directory: /var/log/$app" --target_file="$final_path/config.yaml"
+ # Available variables: .Date for the file date and .Index for different log files on the same day.
+ #file_name_format: "{{.Date}}-{{.Index}}.log"
+ ynh_replace_string --match_string="{{.Date}}-{{.Index}}.log" --replace_string="log.log" --target_file="$final_path/config.yaml"
+ # Date format for file names in the Go time format: https://golang.org/pkg/time/#pkg-constants
+ #file_date_format: 2006-01-02
+ ynh_replace_string --match_string="file_date_format: 2006-01-02" --replace_string="#file_date_format: 2006-01-02" --target_file="$final_path/config.yaml"
+ # Log file permissions.
+ #file_mode: 0600
+ #ynh_replace_string --match_string="file_mode: 0600" --replace_string="file_mode: 384" --target_file="$final_path/config.yaml"
+ # Timestamp format for log entries in the Go time format.
+ #timestamp_format: Jan _2, 2006 15:04:05
+ # Minimum severity for log messages.
+ # Options: debug, info, warn, error, fatal
+ #print_level: debug
+ ynh_replace_string --match_string="print_level: debug" --replace_string="print_level: warn" --target_file="$final_path/config.yaml"
+
#Generate the appservice registration file by running ./mautrix-whatsapp -g.
#You can use the -c and -r flags to change the location of the config and registration files. They default to config.yaml and registration.yaml respectively.
./mautrix-whatsapp -g -r /etc/matrix-synapse/$app-registration.yaml
@@ -332,12 +380,8 @@ fi
ynh_replace_string --match_string="#app_service_config_files:" --replace_string="app_service_config_files:" --target_file="/etc/matrix-synapse/homeserver.yaml"
ynh_replace_string --match_string="# - app_service_1.yaml" --replace_string=" - '/etc/matrix-synapse/$app-registration.yaml'" --target_file="/etc/matrix-synapse/homeserver.yaml"
#You will then need to restart the synapse server. Remember to restart it every time the registration file is regenerated.
-service matrix-synapse restart
-#Run the bridge with
-#service mautrix-whatsapp restart
-#./mautrix-whatsapp.
-
+
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
@@ -377,6 +421,11 @@ chown $mautrix_whatsapp_user:root -R $final_path
chown /etc/matrix-synapse/$app-registration.yaml --reference="/etc/matrix-synapse/homeserver.yaml"
chmod u=rwX,g=rX,o= /etc/matrix-synapse/$app-registration.yaml
+#You will then need to restart the synapse server. Remember to restart it every time the registration file is regenerated.
+service matrix-synapse restart
+#Run the bridge with
+#service mautrix-whatsapp restart
+#./mautrix-whatsapp.
#=================================================
# SETUP LOGROTATE
@@ -392,7 +441,8 @@ ynh_script_progression --message="Configuring log rotation..." --time --weight=1
### - And the section "SETUP LOGROTATE" in the upgrade script
# Use logrotate to manage application logfile(s)
-ynh_use_logrotate --logfile "/var/log/$app"
+ynh_use_logrotate --logfile "/var/log/$app/log.log"
+chown $mautrix_whatsapp_user:root -R /var/log/$app
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
@@ -406,7 +456,7 @@ ynh_use_logrotate --logfile "/var/log/$app"
### - Remove the section "REMOVE SERVICE FROM ADMIN PANEL" in the remove script
### - As well as the section "ADVERTISE SERVICE IN ADMIN PANEL" in the restore script
-yunohost service add $app --log "/var/log/$app/$app.log"
+yunohost service add $app --log "/var/log/$app/log.log"
# if using yunohost version 3.2 or more in the 'manifest.json', a description can be added
#yunohost service add $app --description "$app daemon for XXX" --log "/var/log/$app/$app.log"
@@ -424,12 +474,12 @@ ynh_script_progression --message="Starting a systemd service..." --time --weight
### - And the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the change_url script
# Start a systemd service
-ynh_systemd_action --service_name=$app --action="start" --line_match="Bot now ready to bridge Whatsapp and Matrix users from $botusers" --log_path="/var/log/$app/$app.log" --timeout=300
+ynh_systemd_action --service_name=$app --action="start"
#=================================================
# SETUP FAIL2BAN
#=================================================
-ynh_script_progression --message="Configuring fail2ban..." --time --weight=1
+#ynh_script_progression --message="Configuring fail2ban..." --time --weight=1
# Create a dedicated fail2ban config
#ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
diff --git a/scripts/remove b/scripts/remove
index 3f147ca..9423376 100755
--- a/scripts/remove
+++ b/scripts/remove
@@ -16,12 +16,20 @@ ynh_script_progression --message="Loading installation settings..." --time --wei
app=$YNH_APP_INSTANCE_NAME
-domain=$(ynh_app_setting_get --app=$app --key=domain)
-port=$(ynh_app_setting_get --app=$app --key=port)
-db_name=$(ynh_app_setting_get --app=$app --key=db_name)
-db_user=$db_name
+#domain=$(ynh_app_setting_get --app=$app --key=domain)
+#port=$(ynh_app_setting_get --app=$app --key=port)
+#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)
+#=================================================
+# SET CONSTANTS
+#=================================================
+
+mautrix_whatsapp_user=$app
+#mautrix_whatsapp_db_name=$app
+#mautrix_whatsapp_db_user=$app
+
#=================================================
# STANDARD REMOVE
#=================================================
@@ -46,10 +54,10 @@ ynh_remove_systemd_config
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
-ynh_script_progression --message="Removing the MySQL database..." --time --weight=1
+ynh_script_progression --message="Removing the PostgreSQL database..." --time --weight=1
# Remove a database if it exists, along with the associated user
-ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
+#ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
ynh_psql_drop_db $app
ynh_psql_drop_user $app
@@ -70,22 +78,24 @@ ynh_script_progression --message="Removing app main directory..." --time --weigh
ynh_secure_remove --file="$final_path"
ynh_secure_remove --file="/etc/matrix-synapse/$app-registration.yaml"
+ynh_replace_string --match_string=" - '/etc/matrix-synapse/$app-registration.yaml'" --replace_string="# - app_service_1.yaml" --target_file="/etc/matrix-synapse/homeserver.yaml"
+service matrix-synapse restart
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
-ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1
+#ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1
# Remove the dedicated nginx config
-ynh_remove_nginx_config
+#ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
-ynh_script_progression --message="Removing php-fpm configuration..." --time --weight=1
+#ynh_script_progression --message="Removing php-fpm configuration..." --time --weight=1
# Remove the dedicated php-fpm config
-ynh_remove_fpm_config
+#ynh_remove_fpm_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
@@ -99,19 +109,19 @@ ynh_remove_logrotate
# CLOSE A PORT
#=================================================
-if yunohost firewall list | grep -q "\- $port$"
-then
- ynh_script_progression --message="Closing port $port..."
- ynh_exec_warn_less yunohost firewall disallow TCP $port
-fi
+#if yunohost firewall list | grep -q "\- $port$"
+#then
+# ynh_script_progression --message="Closing port $port..."
+# ynh_exec_warn_less yunohost firewall disallow TCP $port
+#fi
#=================================================
# REMOVE FAIL2BAN CONFIGURATION
#=================================================
-ynh_script_progression --message="Removing fail2ban configuration..." --time --weight=1
+#ynh_script_progression --message="Removing fail2ban configuration..." --time --weight=1
# Remove the dedicated fail2ban config
-ynh_remove_fail2ban_config
+#ynh_remove_fail2ban_config
#=================================================
# SPECIFIC REMOVE
@@ -120,13 +130,13 @@ ynh_remove_fail2ban_config
#=================================================
# Remove a cron file
-ynh_secure_remove --file="/etc/cron.d/$app"
+#ynh_secure_remove --file="/etc/cron.d/$app"
# Remove a directory securely
-ynh_secure_remove --file="/etc/$app/"
+#ynh_secure_remove --file="/etc/$app/"
# Remove the log files
-ynh_secure_remove --file="/var/log/$app/"
+#ynh_secure_remove --file="/var/log/$app/"
#=================================================
# GENERIC FINALIZATION
@@ -136,7 +146,7 @@ ynh_secure_remove --file="/var/log/$app/"
ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1
# Delete a system user
-ynh_system_user_delete --username=$app
+ynh_system_user_delete --username=$mautrix_whatsapp_user
#=================================================
# END OF SCRIPT