1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh.git synced 2024-09-03 19:46:01 +02:00
* ynh_add_config in install

* upgrade ynh_add_config

* Testing Upgrade 0.1.7 (#25)

* Update README.md

* Update README_fr.md

* Update config.yaml

* go build inspired by dendrite

* bot_synapse_adm

* erase upstream erased go file

Co-authored-by: oufmilo <44617467+oufmilo@users.noreply.github.com>
Co-authored-by: ljf (zamentur) <zamentur@users.noreply.github.com>
This commit is contained in:
Gredin67 2021-06-28 22:07:04 +02:00 committed by GitHub
parent 636be2f9f9
commit 01514cf02f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 257 additions and 240 deletions

View file

@ -14,7 +14,8 @@ A puppeting bridge between Matrix and WhatsApp packaged as a YunoHost service. M
** Attention: always backup and restore the Yunohost matrix_synapse et mautrix_whatsapp apps together!** ** Attention: always backup and restore the Yunohost matrix_synapse et mautrix_whatsapp apps together!**
**Shipped version:** 0.1.6 **Shipped version:** 0.1.7
## Screenshots ## Screenshots

View file

@ -13,7 +13,7 @@ Une passerelle entre Matrix et WhatsApp empaquetée comme un service YunoHost. L
** Attention : sauvegardez et restaurez toujours les deux applications Yunohost matrix_synapse et mautrix_whatsapp en même temps!** ** Attention : sauvegardez et restaurez toujours les deux applications Yunohost matrix_synapse et mautrix_whatsapp en même temps!**
**Version incluse:** 0.1.6 **Version incluse:** 0.1.7
## Captures d'écran ## Captures d'écran

View file

@ -1,32 +1,13 @@
# See here for more information ;; Default test serie
# https://github.com/YunoHost/package_check#syntax-check_process-file
# Move this file from check_process.default to check_process when you have filled it.
;; Test complet
auto_remove=1
; pre-install ; pre-install
# synapse parameters sudo yunohost tools update apps
domain="domain.tld"
path="/_matrix/static/"
is_public=1
server_name="domain2.tld"
jitsi_server="jitsi.riot.im"
#admin="john" (USER)
#language="en"
#password="pass"
#port="666" (PORT)
sudo yunohost tools update --apps
sudo yunohost domain add $domain
sudo yunohost domain add $server_name
sudo yunohost app install https://github.com/YunoHost-Apps/synapse_ynh/ -a "domain=$domain&server_name=$server_name&is_public=$is_public&jitsi_server=$jitsi_server" --force sudo yunohost app install https://github.com/YunoHost-Apps/synapse_ynh/ -a "domain=$domain&server_name=$server_name&is_public=$is_public&jitsi_server=$jitsi_server" --force
; Manifest ; Manifest
# mautrix_whatsapp manifest parameters
port="8449" (PORT) port="8449" (PORT)
synapsenumber="1" synapsenumber="1"
whatsappbot="whatsappbot" whatsappbot="whatsappbot"
bot_is_synapse_admin="yes" bot_synapse_adm=0
encryption=0
botadmin="@johndoe:synapsedomain.tld" (USER) botadmin="@johndoe:synapsedomain.tld" (USER)
botusers="@johndoe:synapsedomain.tld" botusers="@johndoe:synapsedomain.tld"
; Checks ; Checks
@ -37,21 +18,13 @@
setup_private=0 setup_private=0
setup_public=0 setup_public=0
upgrade=1 upgrade=1
#upgrade=1 from_commit=CommitHash upgrade=1 from_commit=636be2f9f900e578d9aa26ee887dcec2ef8d4e71
backup_restore=1 backup_restore=1
multi_instance=1 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=1 port_already_use=1
change_url=0 change_url=0
;;; Levels actions=0
# If the level 5 (Package linter) is forced to 1. Please add justifications here. config_panel=0
Level 5=auto
;;; Options
#Email=
Notification=none
;;; Upgrade options ;;; Upgrade options
; commit=CommitHash ; commit=636be2f9f900e578d9aa26ee887dcec2ef8d4e71
#name=Name and date of the commit. name=0.1.6
#manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://github.com/tulir/mautrix-whatsapp/archive/v0.1.6.zip SOURCE_URL=https://github.com/tulir/mautrix-whatsapp/archive/refs/tags/v0.1.7.zip
SOURCE_SUM=c7f08d032e6e911f23c1e5ac13a5cbe64231b77f5dc6e6cea52c7f8d65532107 SOURCE_SUM=bcb95d2a1ae48cd88c5170960fadcc4dc5efb26ef7e7051f840fde2c3872540e
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true

View file

@ -1,13 +1,18 @@
# From v0.1.5 https://github.com/tulir/mautrix-whatsapp/blob/master/example-config.yaml # From v0.1.7 https://github.com/tulir/mautrix-whatsapp/blob/master/example-config.yaml
# Homeserver details. # Homeserver details.
homeserver: homeserver:
# The address that this appservice can use to connect to the homeserver. # The address that this appservice can use to connect to the homeserver.
#address: https://example.com #address: https://example.com
address: __DOMAIN__ address: https://__DOMAIN__
# The domain of the homeserver (for MXIDs, etc). # The domain of the homeserver (for MXIDs, etc).
#domain: example.com #domain: example.com
domain: __SERVER_NAME__ domain: __SERVER_NAME__
# The URL to push real-time bridge status to.
# If set, the bridge will make POST requests to this URL whenever a user's whatsapp connection state changes.
# The bridge will use the appservice as_token to authorize requests.
status_endpoint: null
# Application service host/registration related details. # Application service host/registration related details.
# Changing these values requires regeneration of the registration. # Changing these values requires regeneration of the registration.
appservice: appservice:
@ -91,6 +96,8 @@ bridge:
# (Note that, by default, non-admins might not have your homeserver's permission to create # (Note that, by default, non-admins might not have your homeserver's permission to create
# communities.) # communities.)
# {{.Localpart}} is the MXID localpart and {{.Server}} is the MXID server part of the user. # {{.Localpart}} is the MXID localpart and {{.Server}} is the MXID server part of the user.
# whatsapp_{{.Localpart}}={{.Server}} is a good value that should work for any user.
#community_template: null
community_template: whatsapp_{{.Localpart}}={{.Server}} community_template: whatsapp_{{.Localpart}}={{.Server}}
# WhatsApp connection timeout in seconds. # WhatsApp connection timeout in seconds.
@ -103,9 +110,6 @@ bridge:
# sent to WhatsApp. If fetch_message_on_timeout is enabled, a successful post-timeout fetch will # sent to WhatsApp. If fetch_message_on_timeout is enabled, a successful post-timeout fetch will
# trigger a read receipt too. # trigger a read receipt too.
delivery_receipts: false delivery_receipts: false
# Number of times to regenerate QR code when logging in.
# The regenerated QR code is sent as an edit and essentially multiplies the login timeout (20 seconds)
login_qr_regen_count: 2
# Maximum number of times to retry connecting on connection error. # Maximum number of times to retry connecting on connection error.
max_connection_attempts: 3 max_connection_attempts: 3
# Number of seconds to wait between connection attempts. # Number of seconds to wait between connection attempts.
@ -142,6 +146,15 @@ bridge:
recovery_chat_sync_limit: -1 recovery_chat_sync_limit: -1
# Whether or not to sync history when recovering from downtime. # Whether or not to sync history when recovering from downtime.
recovery_history_backfill: true recovery_history_backfill: true
# Whether or not portal info should be fetched from the server when syncing,
# instead of relying on finding any changes in the message history.
# If you get 599 errors often, you should try disabling this.
chat_meta_sync: true
# Whether or not puppet avatars should be fetched from the server even if an avatar is already set.
# If you get 599 errors often, you should try disabling this.
user_avatar_sync: true
# Whether or not Matrix users leaving groups should be bridged to WhatsApp
bridge_matrix_leave: true
# Maximum number of seconds since last message in chat to skip # Maximum number of seconds since last message in chat to skip
# syncing the chat in any case. This setting will take priority # syncing the chat in any case. This setting will take priority
# over both recovery_chat_sync_limit and initial_chat_sync_count. # over both recovery_chat_sync_limit and initial_chat_sync_count.
@ -195,7 +208,19 @@ bridge:
# This field will automatically be changed back to false after it, # This field will automatically be changed back to false after it,
# except if the config file is not writable. # except if the config file is not writable.
resend_bridge_info: false resend_bridge_info: false
# When using double puppeting, should muted chats be muted in Matrix?
mute_bridging: false
# When using double puppeting, should archived chats be moved to a specific tag in Matrix?
# Note that WhatsApp unarchives chats when a message is received, which will also be mirrored to Matrix.
# This can be set to a tag (e.g. m.lowpriority), or null to disable.
archive_tag: null
# Same as above, but for pinned chats. The favorite tag is called m.favourite
pinned_tag: null
# Whether or not mute status and tags should only be bridged when the portal room is created.
tag_only_on_create: true
# Whether or not WhatsApp status messages should be bridged into a Matrix room.
# Disabling this won't affect already created status broadcast rooms.
enable_status_broadcast: false
# Whether or not thumbnails from WhatsApp should be sent. # Whether or not thumbnails from WhatsApp should be sent.
# They're disabled by default due to very low resolution. # They're disabled by default due to very low resolution.
whatsapp_thumbnail: false whatsapp_thumbnail: false

55
issue_template.md Normal file
View file

@ -0,0 +1,55 @@
---
name: Bug report
about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently.
---
**How to post a meaningful bug report**
1. *Read this whole template first.*
2. *Determine if you are on the right place:*
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!*
- *Otherwise, the issue may be due to mautrix_whatsapp itself. Refer to its documentation or repository for help.*
- *When in doubt, post here and we will figure it out together.*
3. *Delete the italic comments as you write over them below, and remove this guide.*
---
### Describe the bug
*A clear and concise description of what the bug is.*
### Context
- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...*
- YunoHost version: x.x.x
- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...*
- Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes*
- If yes, please explain:
- Using, or trying to install package version/branch:
- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`*
### Steps to reproduce
- *If you performed a command from the CLI, the command itself is enough. For example:*
```sh
sudo yunohost app install mautrix_whatsapp
```
- *If you used the webadmin, please perform the equivalent command from the CLI first.*
- *If the error occurs in your browser, explain what you did:*
1. *Go to '...'*
2. *Click on '...'*
3. *Scroll down to '...'*
4. *See error*
### Expected behavior
*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.*
### Logs
*When an operation fails, YunoHost provides a simple way to share the logs.*
- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.*
- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.*
*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)*
*If applicable and useful, add screenshots to help explain your problem.*

View file

@ -6,7 +6,7 @@
"en": "A WhatsApp puppeting bridge for Matrix/Synapse.", "en": "A WhatsApp puppeting bridge for Matrix/Synapse.",
"fr": "Passerelle WhatsApp pour Matrix/Synapse." "fr": "Passerelle WhatsApp pour Matrix/Synapse."
}, },
"version": "0.1.6~ynh1", "version": "0.1.7~ynh1",
"url": "https://github.com/tulir/mautrix-whatsapp", "url": "https://github.com/tulir/mautrix-whatsapp",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"maintainer": { "maintainer": {
@ -15,7 +15,7 @@
"url": "https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh" "url": "https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh"
}, },
"requirements": { "requirements": {
"yunohost": ">= 4.0" "yunohost": ">= 4.1.0"
}, },
"multi_instance": true, "multi_instance": true,
"services": [ "services": [
@ -52,7 +52,7 @@
"default": "whatsappbot" "default": "whatsappbot"
}, },
{ {
"name": "bot_is_synapse_admin", "name": "bot_synapse_adm",
"type": "boolean", "type": "boolean",
"ask": { "ask": {
"en": "Give the WhatsApp bot administrator rights to the synapse instance?", "en": "Give the WhatsApp bot administrator rights to the synapse instance?",
@ -62,7 +62,7 @@
"en": "If true, the bot can group WhatsApp chats in a Matrix community. Not required if you set up synapse so that non-admins are authorized to create communities.", "en": "If true, the bot can group WhatsApp chats in a Matrix community. Not 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. Pas nécessaire si vous avez réglé synapse pour qu'il autorise les non-admin à créer des communautés." "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 "default": 1
}, },
{ {
"name": "encryption", "name": "encryption",
@ -71,7 +71,7 @@
"en": "Enable end-to-bridge encryption ?", "en": "Enable end-to-bridge encryption ?",
"fr": "Activer le chiffrement entre synapse et le bridge ?" "fr": "Activer le chiffrement entre synapse et le bridge ?"
}, },
"default": false "default": 0
}, },
{ {
"name": "botadmin", "name": "botadmin",

View file

@ -15,4 +15,4 @@
--- ---
*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results* *If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results*
[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/APP_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/APP_ynh%20PR-NUM-%20(USERNAME)/) [![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/mautrix_whatsapp_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/mautrix_whatsapp_ynh%20PR-NUM-%20(USERNAME)/)

View file

@ -6,7 +6,7 @@
# dependencies used by the app # dependencies used by the app
pkg_dependencies="g++ postgresql ffmpeg" pkg_dependencies="g++ postgresql ffmpeg"
GO_VERSION="1.14" GO_VERSION="1.15"
GO_PATH="/usr/lib/go-$GO_VERSION/bin" GO_PATH="/usr/lib/go-$GO_VERSION/bin"
#================================================= #=================================================

View file

@ -24,7 +24,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -39,14 +39,14 @@ mautrix_whatsapp_db_name=$(ynh_app_setting_get --app=$app --key=mautrix_whatsapp
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Backing up the main app directory..." --weight=1 ynh_print_info --message="Backing up the main app directory..."
ynh_backup --src_path="$final_path" ynh_backup --src_path="$final_path"
#================================================= #=================================================
# BACKUP THE POSTGRESQL DATABASE # BACKUP THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Backing up the PostgreSQL database..." --weight=1 ynh_print_info --message="Backing up the PostgreSQL database..."
ynh_psql_dump_db --database="$mautrix_whatsapp_db_name" > ${YNH_CWD}/dump.sql ynh_psql_dump_db --database="$mautrix_whatsapp_db_name" > ${YNH_CWD}/dump.sql
@ -55,14 +55,14 @@ ynh_psql_dump_db --database="$mautrix_whatsapp_db_name" > ${YNH_CWD}/dump.sql
#================================================= #=================================================
# BACKUP LOGROTATE # BACKUP LOGROTATE
#================================================= #=================================================
ynh_script_progression --message="Backing up logrotate configuration..." --weight=1 ynh_print_info --message="Backing up logrotate configuration..."
ynh_backup --src_path="/var/log/$app" ynh_backup --src_path="/var/log/$app"
#================================================= #=================================================
# BACKUP SYSTEMD # BACKUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Backing up systemd configuration..." --weight=1 ynh_print_info --message="Backing up systemd configuration..."
#ynh_backup --src_path="/etc/default/$app" #ynh_backup --src_path="/etc/default/$app"
ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup --src_path="/etc/systemd/system/$app.service"
@ -71,4 +71,4 @@ ynh_backup --src_path="/etc/systemd/system/$app.service"
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -26,13 +26,20 @@ ynh_abort_if_errors
synapsenumber=$YNH_APP_ARG_SYNAPSENUMBER synapsenumber=$YNH_APP_ARG_SYNAPSENUMBER
whatsappbot=$YNH_APP_ARG_WHATSAPPBOT whatsappbot=$YNH_APP_ARG_WHATSAPPBOT
bot_is_synapse_admin=$YNH_APP_ARG_BOT_IS_SYNAPSE_ADMIN bot_synapse_adm=$YNH_APP_ARG_BOT_SYNAPSE_ADM
encryption=$YNH_APP_ARG_BOT_IS_SYNAPSE_ADMIN mautrix_version=$(ynh_app_upstream_version)
botadmin=$YNH_APP_ARG_BOTADMIN
botusers=$YNH_APP_ARG_BOTUSERS
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
final_path=/opt/yunohost/$app final_path=/opt/yunohost/$app
encryption=$YNH_APP_ARG_ENCRYPTION
botadmin=$YNH_APP_ARG_BOTADMIN
botusers=$YNH_APP_ARG_BOTUSERS
if [ "$botusers" = "local" ]
then
botusers=$server_name
elif [ "$botusers" = "admin" ]
then
botusers=$botadmin
fi
# ToDo check (in manifest?) if the selected synapse instance is not already connected to a mautrix_whatsapp bridge # ToDo check (in manifest?) if the selected synapse instance is not already connected to a mautrix_whatsapp bridge
if [ $synapsenumber -eq "1" ] if [ $synapsenumber -eq "1" ]
@ -43,12 +50,6 @@ synapse_instance="synapse__$synapsenumber"
fi fi
server_name=$(ynh_app_setting_get --app $synapse_instance --key server_name) server_name=$(ynh_app_setting_get --app $synapse_instance --key server_name)
domain=$(ynh_app_setting_get --app $synapse_instance --key domain) domain=$(ynh_app_setting_get --app $synapse_instance --key domain)
synapse_config_path="/etc/matrix-$synapse_instance"
app_service_registration_path="/etc/matrix-$synapse_instance/app-service"
synapse_name="matrix-$synapse_instance"
synapse_user="matrix-$synapse_instance"
synapse_db_name="matrix_$synapse_instance"
synapse_db_user="matrix_$synapse_instance"
#================================================= #=================================================
# SET CONSTANTS # SET CONSTANTS
@ -58,7 +59,17 @@ whatsappbot_synapse_db_user="@$whatsappbot:$server_name"
mautrix_whatsapp_user=$app mautrix_whatsapp_user=$app
mautrix_whatsapp_db_name=$app mautrix_whatsapp_db_name=$app
mautrix_whatsapp_db_user=$app mautrix_whatsapp_db_user=$app
upstream_version=$(ynh_app_upstream_version) ynh_print_OFF
mautrix_whatsapp_db_pwd=$(ynh_string_random --length=30)
ynh_print_ON
mautrix_config_path="$final_path/config.yaml"
synapse_config_path="/etc/matrix-$synapse_instance"
app_service_registration_path="/etc/matrix-$synapse_instance/app-service"
synapse_name="matrix-$synapse_instance"
synapse_user="matrix-$synapse_instance"
synapse_db_name="matrix_$synapse_instance"
synapse_db_user="matrix_$synapse_instance"
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
@ -72,7 +83,7 @@ test ! -e "$final_path" || ynh_die --message="This path already contains a folde
#================================================= #=================================================
# FIND AND OPEN A PORT # FIND AND OPEN A PORT
#================================================= #=================================================
ynh_script_progression --message="Configuring firewall..." --weight=1 ynh_script_progression --message="Configuring PORT..." --weight=1
# Find a free port for communication between your local synapse instance (home server) and its app service mautrix_whatsapp. # 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) port=$(ynh_find_port --port=8449)
@ -88,44 +99,43 @@ ynh_app_setting_set --app=$app --key=port --value=$port
ynh_app_setting_set --app=$app --key=whatsappbot --value=$whatsappbot ynh_app_setting_set --app=$app --key=whatsappbot --value=$whatsappbot
ynh_app_setting_set --app=$app --key=synapse_instance --value=$synapse_instance ynh_app_setting_set --app=$app --key=synapse_instance --value=$synapse_instance
ynh_app_setting_set --app=$app --key=app_service_registration_path --value=$app_service_registration_path ynh_app_setting_set --app=$app --key=app_service_registration_path --value=$app_service_registration_path
ynh_app_setting_set --app=$app --key=bot_is_synapse_admin --value=$bot_is_synapse_admin ynh_app_setting_set --app=$app --key=bot_synapse_adm --value=$bot_synapse_adm
ynh_app_setting_set --app=$app --key=encryption --value=$encryption ynh_app_setting_set --app=$app --key=encryption --value=$encryption
ynh_app_setting_set --app=$app --key=mautrix_whatsapp_db_name --value=$mautrix_whatsapp_db_name
ynh_app_setting_set --app=$app --key=botadmin --value=$botadmin ynh_app_setting_set --app=$app --key=botadmin --value=$botadmin
ynh_app_setting_set --app=$app --key=botusers --value=$botusers ynh_app_setting_set --app=$app --key=botusers --value=$botusers
ynh_app_setting_set --app=$app --key=mautrix_version --value=$upstream_version ynh_app_setting_set --app=$app --key=mautrix_version --value=$mautrix_version
ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
ynh_app_setting_set --app=$app --key=mautrix_whatsapp_db_name --value=$mautrix_whatsapp_db_name
ynh_print_OFF
ynh_app_setting_set --app=$app --key=mautrix_whatsapp_db_pwd --value=$mautrix_whatsapp_db_pwd
ynh_print_ON
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." --weight=97 ynh_script_progression --message="Installing dependencies..." --weight=97
### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package.
### Those deb packages will be installed as dependencies of this package.
### If you're not using this helper:
### - Remove the section "REMOVE DEPENDENCIES" in the remove script
### - Remove the variable "pkg_dependencies" in _common.sh
### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
ynh_install_extra_app_dependencies --repo="http://http.debian.net/debian buster-backports main" --package="golang-go" if [ $encryption = true ]
then
ynh_install_extra_app_dependencies --repo="http://http.debian.net/debian buster-backports main" --package="libolm-dev" ynh_install_extra_app_dependencies --repo="http://http.debian.net/debian buster-backports main" --package="libolm-dev"
#ynh_install_extra_app_dependencies --repo="http://http.debian.net/debian $(lsb_release -sc)" --package="golang-1.11" fi
ynh_install_extra_app_dependencies --repo="http://http.debian.net/debian buster-backports main" --package="golang-go"
#export GOPATH="$final_path"
#export GOCACHE="$GOPATH"/.cache/go-build
export PATH=$PATH:$GO_PATH
env_path=$PATH
#================================================= #=================================================
# CREATE A POSTGRESQL DATABASE # CREATE A POSTGRESQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=3 ynh_script_progression --message="Creating a PostgreSQL database..." --weight=3
ynh_print_OFF
mautrix_whatsapp_db_pwd=$(ynh_string_random --length=30)
ynh_app_setting_set --app=$app --key=mautrix_whatsapp_db_pwd --value=$mautrix_whatsapp_db_pwd
ynh_print_ON
# Create postgresql database # Create postgresql database
ynh_psql_test_if_first_run ynh_psql_test_if_first_run
ynh_print_OFF ynh_print_OFF
@ -139,14 +149,6 @@ ynh_psql_execute_as_root \
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=3 ynh_script_progression --message="Setting up source files..." --weight=3
### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
### downloaded from an upstream source, like a git repository.
### `ynh_setup_source` use the file conf/app.src
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# WARNING : theses command are used in INSTALL, UPGRADE (2 times)
# For any update do it in all files
#if [ -n "$(uname -m | grep 64)" ] #if [ -n "$(uname -m | grep 64)" ]
#then #then
# ynh_setup_source --dest_dir=$final_path/ --source_id="amd64_$(lsb_release --codename --short)" # ynh_setup_source --dest_dir=$final_path/ --source_id="amd64_$(lsb_release --codename --short)"
@ -160,24 +162,18 @@ ynh_setup_source --dest_dir="$final_path"
#================================================= #=================================================
ynh_script_progression --message="Build with golang..." --weight=194 ynh_script_progression --message="Build with golang..." --weight=194
# Build mautrix-whatsapp pushd "$final_path" || ynh_die
base_directory=$PWD ynh_script_progression --message="Building the sources (it will take some time)..." --weight=6
export GOPATH="$final_path"_src if [ $encryption = true ]
export GOCACHE="$GOPATH"/.cache/go-build then
cd $final_path # Build with libolm3 end-to-bridge encryption
ynh_exec_warn_less ./build.sh
else
# Build without end-to-bridge encryption
ynh_exec_warn_less ./build.sh -tags nocrypto
fi
popd || ynh_die
if [ $encryption = true ]
then
# build with libolm3 end-to-bridge encryption
./build.sh
else
# build without end-to-bridge encryption
./build.sh -tags nocrypto
fi
# build with libolm2 encryption
# ./build.sh -tags nosas
cd $base_directory
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
@ -205,54 +201,29 @@ ynh_script_progression --message="Configuring Mautrix-WhatsApp..." --weight=2
# Configure Mautrix-WhatsApp # Configure Mautrix-WhatsApp
# WARNING : theses command are used in INSTALL, UPGRADE, CONFIG, CHANGE-URL (4 times) #verify_server_ssl_certificates="true"
# For any update do it in all files #matrix_server_supports_asmux="false"
#log_filename="/var/log/$app/$app.log"
mautrix_config_path="$final_path/config.yaml" #ynh_print_OFF
#ynh_replace_string --match_string=__MAUTRIX_WHATSAPP_DB_PWD__ --replace_string=$mautrix_whatsapp_db_pwd --target_file="$mautrix_config_path"
#ynh_print_ON
enable_relaybot="true"
relaybot_management_room="highwaytohell"
relaybot_invite="$botadmin"
log_format="log.log"
# Options: debug, info, warn, error, fatal
log_level="error"
#Copy example-config.yaml to config.yaml ynh_add_config --template="../conf/config.yaml" --destination="$mautrix_config_path"
cp ../conf/config.yaml "$mautrix_config_path"
ynh_replace_string --match_string=__DOMAIN__ --replace_string="https://$domain" --target_file="$mautrix_config_path" #=================================================
ynh_replace_string --match_string=__SERVER_NAME__ --replace_string=$server_name --target_file="$mautrix_config_path" # REGISTER SYNAPSE APP-SERVICE
ynh_replace_string --match_string=__PORT__ --replace_string=$port --target_file="$mautrix_config_path" #=================================================
ynh_replace_string --match_string=__MAUTRIX_WHATSAPP_USER__ --replace_string=$mautrix_whatsapp_user --target_file="$mautrix_config_path"
ynh_print_OFF
ynh_replace_string --match_string=__MAUTRIX_WHATSAPP_DB_PWD__ --replace_string=$mautrix_whatsapp_db_pwd --target_file="$mautrix_config_path"
ynh_print_ON
ynh_replace_string --match_string=__MAUTRIX_WHATSAPP_DB_NAME__ --replace_string=$mautrix_whatsapp_db_name --target_file="$mautrix_config_path"
ynh_replace_string --match_string=__WHATSAPPBOT__ --replace_string=$whatsappbot --target_file="$mautrix_config_path"
if [ "$botusers" = "local" ]
then
ynh_replace_string --match_string=__BOTUSERS__ --replace_string=$server_name --target_file="$mautrix_config_path"
elif [ "$botusers" = "admin" ]
then
ynh_replace_string --match_string=__BOTUSERS__ --replace_string=$botadmin --target_file="$mautrix_config_path"
else
ynh_replace_string --match_string=__BOTUSERS__ --replace_string=$botusers --target_file="$mautrix_config_path"
fi
ynh_replace_string --match_string=__BOTADMIN__ --replace_string=$botadmin --target_file="$mautrix_config_path"
ynh_replace_string --match_string=__ENABLE_RELAYBOT__ --replace_string="true" --target_file="$mautrix_config_path"
ynh_replace_string --match_string=__RELAYBOT_MANAGEMENT_ROOM__ --replace_string="highwaytohell" --target_file="$mautrix_config_path"
ynh_replace_string --match_string=__RELAYBOT_INVITE__ --replace_string=$botadmin --target_file="$mautrix_config_path"
ynh_replace_string --match_string=__APP__ --replace_string=$app --target_file="$mautrix_config_path"
ynh_replace_string --match_string=__LOG_FORMAT__ --replace_string="log.log" --target_file="$mautrix_config_path"
# Options: debug, info, warn, error, fatal
ynh_replace_string --match_string=__LOG_LEVEL__ --replace_string="error" --target_file="$mautrix_config_path"
#cd $final_path
#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.
#mkdir -p $app_service_registration_path
$final_path/mautrix-whatsapp -g -c $mautrix_config_path -r $app_service_registration_path/$app.yaml $final_path/mautrix-whatsapp -g -c $mautrix_config_path -r $app_service_registration_path/$app.yaml
#Add the path to the registration file (registration.yaml by default) to your synapse homeserver.yaml under app_service_config_files.
#cd $base_directory
#cp ../conf/$app.yaml $app_service_registration_path
#$as_token=; #Add the path to the registration file (registration.yaml by default) to your synapse homeserver.yaml under app_service_config_files.
#$hs_token=;
#ynh_replace_string --match_string=__AS_TOKEN__ --replace_string="$as_token" --target_file=$app_service_registration_path/$app.yaml
#ynh_replace_string --match_string=__HS_TOKEN__ --replace_string="$hs_token" --target_file=$app_service_registration_path/$app.yaml
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \ /opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \
|| ynh_die "Synapse can't restart with the appservice configuration" || ynh_die "Synapse can't restart with the appservice configuration"
# Handled by synapse: synapse_ynh adds all registration files added in $app_service_registration_path to the app_service_config_files list # Handled by synapse: synapse_ynh adds all registration files added in $app_service_registration_path to the app_service_config_files list
@ -261,10 +232,6 @@ $final_path/mautrix-whatsapp -g -c $mautrix_config_path -r $app_service_registra
# STORE THE CONFIG FILE CHECKSUM # STORE THE CONFIG FILE CHECKSUM
#================================================= #=================================================
### `ynh_store_file_checksum` is used to store the checksum of a file.
### That way, during the upgrade script, by using `ynh_backup_if_checksum_is_different`,
### you can make a backup of this file before modifying it again if the admin had modified it.
# Calculate and store the config file checksum into the app settings # Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$app_service_registration_path/$app.yaml" ynh_store_file_checksum --file="$app_service_registration_path/$app.yaml"
ynh_store_file_checksum --file="$mautrix_config_path" ynh_store_file_checksum --file="$mautrix_config_path"
@ -275,10 +242,6 @@ ynh_store_file_checksum --file="$mautrix_config_path"
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
### For security reason, any app should set the permissions to root: before anything else.
### Then, if write authorization is needed, any access should be given only to directories
### that really need such authorization.
# Set permissions to app files # Set permissions to app files
chown -R root: $final_path chown -R root: $final_path
@ -312,7 +275,7 @@ ynh_systemd_action --service_name=$app --action="start"
# Wait until the synapse user is created # Wait until the synapse user is created
sleep 30 sleep 30
# (Note that, by default, non-admins might not have your homeserver's permission to create communities.) # (Note that, by default, non-admins might not have your homeserver's permission to create communities.)
if [ "$bot_is_synapse_admin" = true ] if [ "$bot_synapse_adm" = true ]
then then
ynh_psql_execute_as_root --database=$synapse_db_name --sql="UPDATE users SET admin = 1 WHERE name = ""$whatsappbot"";" ynh_psql_execute_as_root --database=$synapse_db_name --sql="UPDATE users SET admin = 1 WHERE name = ""$whatsappbot"";"
#yunohost app action run $synapse_instance set_admin_user -a username=$whatsappbot #yunohost app action run $synapse_instance set_admin_user -a username=$whatsappbot

View file

@ -66,8 +66,8 @@ ynh_script_progression --message="Removing the PostgreSQL database..." --weight=
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user=$mautrix_whatsapp_db_name --db_name=$mautrix_whatsapp_db_user ynh_psql_remove_db --db_user=$mautrix_whatsapp_db_name --db_name=$mautrix_whatsapp_db_user
ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP OWNED BY ""$whatsappbot"";" ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP OWNED BY ""$mautrix_whatsapp_user"";"
ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP USER ""$whatsappbot"";" ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP USER ""$mautrix_whatsapp_user"";"
#yunohost app action run $synapse_instance drop_user -a username=$whatsappbot #yunohost app action run $synapse_instance drop_user -a username=$whatsappbot
#================================================= #=================================================

View file

@ -27,8 +27,6 @@ ynh_abort_if_errors
ynh_script_progression --message="Loading settings..." --weight=5 ynh_script_progression --message="Loading settings..." --weight=5
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
final_path=/opt/yunohost/$app
mautrix_config_path="$final_path/config.yaml"
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
server_name=$(ynh_app_setting_get --app=$app --key=server_name) server_name=$(ynh_app_setting_get --app=$app --key=server_name)
@ -36,12 +34,12 @@ port=$(ynh_app_setting_get --app=$app --key=port)
whatsappbot=$(ynh_app_setting_get --app=$app --key=whatsappbot) whatsappbot=$(ynh_app_setting_get --app=$app --key=whatsappbot)
synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance) synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
app_service_registration_path=$(ynh_app_setting_get --app=$app --key=app_service_registration_path) app_service_registration_path=$(ynh_app_setting_get --app=$app --key=app_service_registration_path)
bot_is_synapse_admin=$(ynh_app_setting_get --app=$app --key=bot_is_synapse_admin) encryption=$(ynh_app_setting_get --app=$app --key=encryption)
botadmin=$(ynh_app_setting_get --app=$app --key=botadmin) botadmin=$(ynh_app_setting_get --app=$app --key=botadmin)
botusers=$(ynh_app_setting_get --app=$app --key=botusers) botusers=$(ynh_app_setting_get --app=$app --key=botusers)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
mautrix_version=$(ynh_app_setting_get --app=$app --key=mautrix_version) mautrix_version=$(ynh_app_setting_get --app=$app --key=mautrix_version)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
ynh_print_OFF ynh_print_OFF
mautrix_whatsapp_db_pwd=$(ynh_app_setting_get --app=$app --key=mautrix_whatsapp_db_pwd) mautrix_whatsapp_db_pwd=$(ynh_app_setting_get --app=$app --key=mautrix_whatsapp_db_pwd)
ynh_print_ON ynh_print_ON
@ -55,7 +53,7 @@ whatsappbot_synapse_db_user="@$whatsappbot:$server_name"
mautrix_whatsapp_user=$app mautrix_whatsapp_user=$app
mautrix_whatsapp_db_name=$app mautrix_whatsapp_db_name=$app
mautrix_whatsapp_db_user=$app mautrix_whatsapp_db_user=$app
upstream_version=$(ynh_app_upstream_version) mautrix_config_path="$final_path/config.yaml"
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
@ -100,7 +98,10 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=100
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
ynh_install_extra_app_dependencies --repo="http://http.debian.net/debian buster-backports main" --package="golang-go" ynh_install_extra_app_dependencies --repo="http://http.debian.net/debian buster-backports main" --package="golang-go"
if [ $encryption = true ]
then
ynh_install_extra_app_dependencies --repo="http://http.debian.net/debian buster-backports main" --package="libolm-dev" ynh_install_extra_app_dependencies --repo="http://http.debian.net/debian buster-backports main" --package="libolm-dev"
fi
#================================================= #=================================================
# RESTORE THE POSTGRESQL DATABASE # RESTORE THE POSTGRESQL DATABASE
@ -119,10 +120,6 @@ ynh_psql_execute_file_as_root --file="${YNH_CWD}/dump.sql" --database="$mautrix_
# REGISTER SYNAPSE APP-SERVICE # REGISTER SYNAPSE APP-SERVICE
#================================================= #=================================================
$final_path/mautrix-whatsapp -g -c $mautrix_config_path -r $app_service_registration_path/$app.yaml $final_path/mautrix-whatsapp -g -c $mautrix_config_path -r $app_service_registration_path/$app.yaml
#$as_token=;
#$hs_token=;
#ynh_replace_string --match_string=__AS_TOKEN__ --replace_string="$as_token" --target_file=$app_service_registration_path/$app.yaml
#ynh_replace_string --match_string=__HS_TOKEN__ --replace_string="$hs_token" --target_file=$app_service_registration_path/$app.yaml
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \ /opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \
|| ynh_die "Synapse can't restart with the appservice configuration" || ynh_die "Synapse can't restart with the appservice configuration"
# Handled by synapse: synapse_ynh adds all registration files added in $app_service_registration_path to the app_service_config_files list # Handled by synapse: synapse_ynh adds all registration files added in $app_service_registration_path to the app_service_config_files list
@ -155,14 +152,14 @@ yunohost service add $app --description "$app daemon for bridging Whatsapp and M
ynh_script_progression --message="Starting a systemd service..." --weight=30 ynh_script_progression --message="Starting a systemd service..." --weight=30
ynh_systemd_action --service_name=$app --action="start" ynh_systemd_action --service_name=$app --action="start"
sleep 30 #sleep 30
# (Note that, by default, non-admins might not have your homeserver's permission to create communities.) # (Note that, by default, non-admins might not have your homeserver's permission to create communities.)
if [ "$bot_is_synapse_admin" = true ] # if [ "$bot_is_synapse_admin" = true ]
then # then
ynh_psql_execute_as_root --database=$synapse_db_name --sql="UPDATE users SET admin = 1 WHERE name = ""$whatsappbot"";" # ynh_psql_execute_as_root --database=$synapse_db_name --sql="UPDATE users SET admin = 1 WHERE name = ""$whatsappbot"";"
# yunohost app action run $synapse_instance set_admin_user -a username=$whatsappbot # yunohost app action run $synapse_instance set_admin_user -a username=$whatsappbot
fi # fi
ynh_systemd_action --service_name=$app --action="restart" #ynh_systemd_action --service_name=$app --action="restart"
#================================================= #=================================================

View file

@ -22,12 +22,10 @@ port=$(ynh_app_setting_get --app=$app --key=port)
whatsappbot=$(ynh_app_setting_get --app=$app --key=whatsappbot) whatsappbot=$(ynh_app_setting_get --app=$app --key=whatsappbot)
synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance) synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
app_service_registration_path=$(ynh_app_setting_get --app=$app --key=app_service_registration_path) app_service_registration_path=$(ynh_app_setting_get --app=$app --key=app_service_registration_path)
bot_is_synapse_admin=$(ynh_app_setting_get --app=$app --key=bot_is_synapse_admin)
encryption=$(ynh_app_setting_get --app=$app --key=encryption) encryption=$(ynh_app_setting_get --app=$app --key=encryption)
botadmin=$(ynh_app_setting_get --app=$app --key=botadmin) botadmin=$(ynh_app_setting_get --app=$app --key=botadmin)
botusers=$(ynh_app_setting_get --app=$app --key=botusers) botusers=$(ynh_app_setting_get --app=$app --key=botusers)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
mautrix_config_path="$final_path/config.yaml"
mautrix_version=$(ynh_app_setting_get --app=$app --key=mautrix_version) mautrix_version=$(ynh_app_setting_get --app=$app --key=mautrix_version)
ynh_print_OFF ynh_print_OFF
@ -43,6 +41,7 @@ whatsappbot_synapse_db_user="@$whatsappbot:$server_name"
mautrix_whatsapp_user=$app mautrix_whatsapp_user=$app
mautrix_whatsapp_db_name=$app mautrix_whatsapp_db_name=$app
mautrix_whatsapp_db_user=$app mautrix_whatsapp_db_user=$app
mautrix_config_path="$final_path/config.yaml"
upstream_version=$(ynh_app_upstream_version) upstream_version=$(ynh_app_upstream_version)
#================================================= #=================================================
@ -63,16 +62,20 @@ upgrade_type=$(ynh_check_app_version_changed)
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# If db_name doesn't exist, create it # If db_name doesn't exist, create it
if [ -z "$mautrix_whatsapp_db_name" ]; then #if [ -z "$mautrix_whatsapp_db_name" ]; then
mautrix_whatsapp_db_name=$(ynh_sanitize_dbid --db_name=$app) # mautrix_whatsapp_db_name=$(ynh_sanitize_dbid --db_name=$app)
ynh_app_setting_set --app=$app --key=db_name --value=$mautrix_whatsapp_db_name # ynh_app_setting_set --app=$app --key=db_name --value=$mautrix_whatsapp_db_name
fi #fi
# If final_path doesn't exist, create it # If final_path doesn't exist, create it
if [ -z "$final_path" ]; then #if [ -z "$final_path" ]; then
final_path=/opt/yunohost/$app # final_path=/opt/yunohost/$app
ynh_app_setting_set --app=$app --key=final_path --value=$final_path # ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi #fi
#Migration from 0.1.5
#domain=$(ynh_app_setting_get --app $synapse_instance --key domain)
#ynh_app_setting_set --app=$app --key=domain --value=$domain
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
@ -116,28 +119,44 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=100
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
ynh_install_extra_app_dependencies --repo="http://http.debian.net/debian buster-backports main" --package="golang-go" if [ $encryption = true ]
then
ynh_install_extra_app_dependencies --repo="http://http.debian.net/debian buster-backports main" --package="libolm-dev" ynh_install_extra_app_dependencies --repo="http://http.debian.net/debian buster-backports main" --package="libolm-dev"
fi
# TODO: check Go version and upgrade if needed
#if ! command -v /usr/local/go/bin/go &> /dev/null
#then
ynh_install_extra_app_dependencies --repo="http://http.debian.net/debian buster-backports main" --package="golang-go"
#if
# Migration from 1.6.0
ynh_secure_remove --file="$final_path"/asmux.go
src_path="$final_path"_src
#export GOPATH=$src_path
#export GOCACHE="$GOPATH"/.cache/go-build
# Remove a directory securely
ynh_secure_remove --file="$src_path"
#export PATH=$PATH:$GO_PATH
#env_path=$PATH
#================================================= #=================================================
# BUILD GO # BUILD GO
#================================================= #=================================================
# Build mautrix-whatsapp # Build mautrix-whatsapp
base_directory=$PWD
export GOPATH="$final_path"_src pushd "$final_path" || ynh_die
export GOCACHE="$GOPATH"/.cache/go-build ynh_script_progression --message="Building the sources (it will take some time)..." --weight=6
cd $final_path if [ $encryption = true ]
if [ $encryption = true ] then
then # Build with libolm3 end-to-bridge encryption
# build with libolm3 end-to-bridge encryption ynh_exec_warn_less ./build.sh
./build.sh else
else # Build without end-to-bridge encryption
# build without end-to-bridge encryption ynh_exec_warn_less ./build.sh -tags nocrypto
./build.sh -tags nocrypto fi
fi popd || ynh_die
# build with libolm2 encryption
# ./build.sh -tags nosas
cd $base_directory
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
@ -169,50 +188,34 @@ ynh_script_progression --message="Configuring Mautrix-WhatsApp..." --weight=2
# Configure Mautrix-WhatsApp # Configure Mautrix-WhatsApp
# WARNING : theses command are used in INSTALL, UPGRADE, CONFIG, CHANGE-URL (4 times) #ynh_print_OFF
# For any update do it in all files #ynh_replace_string --match_string=__MAUTRIX_WHATSAPP_DB_PWD__ --replace_string=$mautrix_whatsapp_db_pwd --target_file="$mautrix_config_path"
#ynh_print_ON
mautrix_config_path="$final_path/config.yaml" enable_relaybot="true"
relaybot_management_room="highwaytohell"
relaybot_invite="$botadmin"
log_format="log.log"
# Options: debug, info, warn, error, fatal
log_level="error"
#Copy example-config.yaml to config.yaml ynh_add_config --template="../conf/config.yaml" --destination="$mautrix_config_path"
cp ../conf/config.yaml "$mautrix_config_path"
ynh_replace_string --match_string=__DOMAIN__ --replace_string="https://$domain" --target_file="$mautrix_config_path"
ynh_replace_string --match_string=__SERVER_NAME__ --replace_string=$server_name --target_file="$mautrix_config_path"
ynh_replace_string --match_string=__PORT__ --replace_string=$port --target_file="$mautrix_config_path"
ynh_replace_string --match_string=__MAUTRIX_WHATSAPP_USER__ --replace_string=$mautrix_whatsapp_user --target_file="$mautrix_config_path"
ynh_print_OFF
ynh_replace_string --match_string=__MAUTRIX_WHATSAPP_DB_PWD__ --replace_string=$mautrix_whatsapp_db_pwd --target_file="$mautrix_config_path"
ynh_print_ON
ynh_replace_string --match_string=__MAUTRIX_WHATSAPP_DB_NAME__ --replace_string=$mautrix_whatsapp_db_name --target_file="$mautrix_config_path"
ynh_replace_string --match_string=__WHATSAPPBOT__ --replace_string=$whatsappbot --target_file="$mautrix_config_path"
if [ "$botusers" = "local" ]
then
ynh_replace_string --match_string=__BOTUSERS__ --replace_string=$server_name --target_file="$mautrix_config_path"
elif [ "$botusers" = "admin" ]
then
ynh_replace_string --match_string=__BOTUSERS__ --replace_string=$botadmin --target_file="$mautrix_config_path"
else
ynh_replace_string --match_string=__BOTUSERS__ --replace_string=$botusers --target_file="$mautrix_config_path"
fi
ynh_replace_string --match_string=__BOTADMIN__ --replace_string=$botadmin --target_file="$mautrix_config_path"
ynh_replace_string --match_string=__ENABLE_RELAYBOT__ --replace_string="true" --target_file="$mautrix_config_path"
ynh_replace_string --match_string=__RELAYBOT_MANAGEMENT_ROOM__ --replace_string="highwaytohell" --target_file="$mautrix_config_path"
ynh_replace_string --match_string=__RELAYBOT_INVITE__ --replace_string=$botadmin --target_file="$mautrix_config_path"
ynh_replace_string --match_string=__APP__ --replace_string=$app --target_file="$mautrix_config_path"
ynh_replace_string --match_string=__LOG_FORMAT__ --replace_string="log.log" --target_file="$mautrix_config_path"
# Options: debug, info, warn, error, fatal
ynh_replace_string --match_string=__LOG_LEVEL__ --replace_string="error" --target_file="$mautrix_config_path"
#================================================= #=================================================
# REGISTER SYNAPSE APP-SERVICE # REGISTER SYNAPSE APP-SERVICE
#================================================= #=================================================
$final_path/mautrix-whatsapp -g -c $mautrix_config_path -r $app_service_registration_path/$app.yaml $final_path/mautrix-whatsapp -g -c $mautrix_config_path -r $app_service_registration_path/$app.yaml
#Add the path to the registration file (registration.yaml by default) to your synapse homeserver.yaml under app_service_config_files.
/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \ /opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \
|| ynh_die "Synapse can't restart with the appservice configuration" || ynh_die "Synapse can't restart with the appservice configuration"
# Handled by synapse: synapse_ynh adds all registration files added in $app_service_registration_path to the app_service_config_files list # Handled by synapse: synapse_ynh adds all registration files added in $app_service_registration_path to the app_service_config_files list
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
# Recalculate and store the checksum of the file for the next upgrade. # Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$mautrix_config_path" ynh_store_file_checksum --file="$mautrix_config_path"
ynh_store_file_checksum --file="$app_service_registration_path/$app.yaml" ynh_store_file_checksum --file="$app_service_registration_path/$app.yaml"