mirror of
https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh.git
synced 2024-09-03 19:46:01 +02:00
upgrade to 0.2.3 multi-device (#38)
* upgrade to 0.2.3 conf etc.. * install pre-built (#39) * bot user as domain * execution rights * architecture=$YNH_ARCH * Update restore (#42) * Fix linter * Silence postgresql * Stay close to example_ynh * chown -R $app:$app "$final_path" * logrotate as user $app * fixed permissions * logs to file deactivated in config, handled by systemd * back to github release * instruction new relaybot Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com>
This commit is contained in:
parent
443ac4fb96
commit
8d950632d0
21 changed files with 601 additions and 683 deletions
4
issue_template.md → .github/ISSUE_TEMPLATE.md
vendored
Normal file → Executable file
4
issue_template.md → .github/ISSUE_TEMPLATE.md
vendored
Normal file → Executable file
|
@ -8,7 +8,7 @@ about: When creating a bug report, please use the following template to provide
|
|||
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.*
|
||||
- *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.*
|
||||
- *When in doubt, post here and we will figure it out together.*
|
||||
3. *Delete the italic comments as you write over them below, and remove this guide.*
|
||||
---
|
||||
|
@ -31,7 +31,7 @@ about: When creating a bug report, please use the following template to provide
|
|||
|
||||
- *If you performed a command from the CLI, the command itself is enough. For example:*
|
||||
```sh
|
||||
sudo yunohost app install mautrix_whatsapp
|
||||
sudo yunohost app install the_app
|
||||
```
|
||||
- *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:*
|
16
.github/PULL_REQUEST_TEMPLATE.md
vendored
Executable file
16
.github/PULL_REQUEST_TEMPLATE.md
vendored
Executable file
|
@ -0,0 +1,16 @@
|
|||
## Problem
|
||||
|
||||
- *Description of why you made this PR*
|
||||
|
||||
## Solution
|
||||
|
||||
- *And how do you fix that problem*
|
||||
|
||||
## PR Status
|
||||
|
||||
- [ ] Code finished and ready to be reviewed/tested
|
||||
- [ ] The fix/enhancement were manually tested (if applicable)
|
||||
|
||||
## Automatic tests
|
||||
|
||||
Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization)
|
136
.github/workflows/updater.sh
vendored
Executable file
136
.github/workflows/updater.sh
vendored
Executable file
|
@ -0,0 +1,136 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# PACKAGE UPDATING HELPER
|
||||
#=================================================
|
||||
|
||||
# This script is meant to be run by GitHub Actions
|
||||
# The YunoHost-Apps organisation offers a template Action to run this script periodically
|
||||
# Since each app is different, maintainers can adapt its contents so as to perform
|
||||
# automatic actions when a new upstream release is detected.
|
||||
|
||||
# Remove this exit command when you are ready to run this Action
|
||||
exit 1
|
||||
|
||||
#=================================================
|
||||
# FETCHING LATEST RELEASE AND ITS ASSETS
|
||||
#=================================================
|
||||
|
||||
# Fetching information
|
||||
current_version=$(cat manifest.json | jq -j '.version|split("~")[0]')
|
||||
repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]')
|
||||
# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions)
|
||||
version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1)
|
||||
assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'"))
|
||||
|
||||
# Later down the script, we assume the version has only digits and dots
|
||||
# Sometimes the release name starts with a "v", so let's filter it out.
|
||||
# You may need more tweaks here if the upstream repository has different naming conventions.
|
||||
if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then
|
||||
version=${version:1}
|
||||
fi
|
||||
|
||||
# Setting up the environment variables
|
||||
echo "Current version: $current_version"
|
||||
echo "Latest release from upstream: $version"
|
||||
echo "VERSION=$version" >> $GITHUB_ENV
|
||||
# For the time being, let's assume the script will fail
|
||||
echo "PROCEED=false" >> $GITHUB_ENV
|
||||
|
||||
# Proceed only if the retrieved version is greater than the current one
|
||||
if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then
|
||||
echo "::warning ::No new version available"
|
||||
exit 0
|
||||
# Proceed only if a PR for this new version does not already exist
|
||||
elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then
|
||||
echo "::warning ::A branch already exists for this update"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.)
|
||||
echo "${#assets[@]} available asset(s)"
|
||||
|
||||
#=================================================
|
||||
# UPDATE SOURCE FILES
|
||||
#=================================================
|
||||
|
||||
# Here we use the $assets variable to get the resources published in the upstream release.
|
||||
# Here is an example for Grav, it has to be adapted in accordance with how the upstream releases look like.
|
||||
|
||||
# Let's loop over the array of assets URLs
|
||||
for asset_url in ${assets[@]}; do
|
||||
|
||||
echo "Handling asset at $asset_url"
|
||||
|
||||
# Assign the asset to a source file in conf/ directory
|
||||
# Here we base the source file name upon a unique keyword in the assets url (admin vs. update)
|
||||
# Leave $src empty to ignore the asset
|
||||
case $asset_url in
|
||||
*"admin"*)
|
||||
src="app"
|
||||
;;
|
||||
*"update"*)
|
||||
src="app-upgrade"
|
||||
;;
|
||||
*)
|
||||
src=""
|
||||
;;
|
||||
esac
|
||||
|
||||
# If $src is not empty, let's process the asset
|
||||
if [ ! -z "$src" ]; then
|
||||
|
||||
# Create the temporary directory
|
||||
tempdir="$(mktemp -d)"
|
||||
|
||||
# Download sources and calculate checksum
|
||||
filename=${asset_url##*/}
|
||||
curl --silent -4 -L $asset_url -o "$tempdir/$filename"
|
||||
checksum=$(sha256sum "$tempdir/$filename" | head -c 64)
|
||||
|
||||
# Delete temporary directory
|
||||
rm -rf $tempdir
|
||||
|
||||
# Get extension
|
||||
if [[ $filename == *.tar.gz ]]; then
|
||||
extension=tar.gz
|
||||
else
|
||||
extension=${filename##*.}
|
||||
fi
|
||||
|
||||
# Rewrite source file
|
||||
cat <<EOT > conf/$src.src
|
||||
SOURCE_URL=$asset_url
|
||||
SOURCE_SUM=$checksum
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=$extension
|
||||
SOURCE_IN_SUBDIR=true
|
||||
SOURCE_FILENAME=
|
||||
EOT
|
||||
echo "... conf/$src.src updated"
|
||||
|
||||
else
|
||||
echo "... asset ignored"
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPDATE STEPS
|
||||
#=================================================
|
||||
|
||||
# Any action on the app's source code can be done.
|
||||
# The GitHub Action workflow takes care of committing all changes after this script ends.
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
||||
# Replace new version in manifest
|
||||
echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json
|
||||
|
||||
# No need to update the README, yunohost-bot takes care of it
|
||||
|
||||
# The Action will proceed only if the PROCEED environment variable is set to true
|
||||
echo "PROCEED=true" >> $GITHUB_ENV
|
||||
exit 0
|
27
README.md
27
README.md
|
@ -14,7 +14,7 @@ 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!**
|
||||
|
||||
**Shipped version:** 0.1.10
|
||||
**Shipped version:** 0.2.3
|
||||
|
||||
|
||||
## Screenshots
|
||||
|
@ -37,13 +37,26 @@ A puppeting bridge between Matrix and WhatsApp packaged as a YunoHost service. M
|
|||
* 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
|
||||
* First Relaybot option should be enabled in the bridge configuration (default=disabled, see below) and room ID of the relaybot administration room added.
|
||||
* 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://docs.mau.fi/bridges/go/whatsapp/relaybot.html)
|
||||
**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
|
||||
|
||||
|
@ -114,7 +127,7 @@ To try the testing branch, please proceed like that:
|
|||
```
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh/tree/testing --debug
|
||||
or
|
||||
sudo yunohost app upgrade synapse -u https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh/tree/testing --debug
|
||||
sudo yunohost app upgrade mautrix_whatsapp -u https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh/tree/testing --debug
|
||||
```
|
||||
|
||||
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:
|
||||
|
|
|
@ -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!**
|
||||
|
||||
**Version incluse:** 0.1.10
|
||||
**Version incluse:** 0.2.3
|
||||
|
||||
## Captures d'écran
|
||||
|
||||
|
|
|
@ -3,12 +3,11 @@
|
|||
sudo yunohost tools update apps
|
||||
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
|
||||
port="8449" (PORT)
|
||||
synapsenumber="1"
|
||||
whatsappbot="whatsappbot"
|
||||
bot_synapse_adm=0
|
||||
encryption=0
|
||||
botadmin="@johndoe:synapsedomain.tld" (USER)
|
||||
botadmin="@johndoe:synapsedomain.tld"
|
||||
botusers="@johndoe:synapsedomain.tld"
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
|
@ -19,15 +18,11 @@
|
|||
setup_public=0
|
||||
upgrade=1
|
||||
upgrade=1 from_commit=ede0231ac59aaa1d65a3009bcbdfe333bf5e87fd
|
||||
#upgrade=1 from_commit=a95215f2ea5d1f34b1c804f776e78c4785477023
|
||||
upgrade=1 from_commit=443ac4fb96297455281d9495844dde3b9a197214
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
port_already_use=1
|
||||
change_url=0
|
||||
actions=0
|
||||
config_panel=0
|
||||
;;; Upgrade options
|
||||
; commit=ede0231ac59aaa1d65a3009bcbdfe333bf5e87fd
|
||||
name=0.1.8
|
||||
# ; commit=a95215f2ea5d1f34b1c804f776e78c4785477023
|
||||
# name=0.1.7
|
||||
; commit=443ac4fb96297455281d9495844dde3b9a197214
|
||||
name=0.1.10
|
||||
|
|
6
conf/amd64.src
Normal file
6
conf/amd64.src
Normal file
|
@ -0,0 +1,6 @@
|
|||
SOURCE_URL=https://github.com/mautrix/whatsapp/releases/download/v0.2.3/mautrix-whatsapp-amd64
|
||||
SOURCE_SUM=7bd2627e8b8245179453454195b0e0a8f5da18e7083a0eada101f5c640245b4d
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_IN_SUBDIR=false
|
||||
SOURCE_FILENAME=mautrix-whatsapp
|
||||
SOURCE_EXTRACT=false
|
|
@ -1,12 +0,0 @@
|
|||
SOURCE_URL=https://mau.dev/tulir/mautrix-whatsapp/-/jobs/1879/artifacts/download
|
||||
#SOURCE_URL=https://mau.dev/tulir/mautrix-whatsapp/-/jobs/artifacts/static-build/download?job=1879
|
||||
SOURCE_SUM=2f9b9950b5432e12394eb01919a3c8226f9d25dd5a93e40906947692eb1f66a7
|
||||
# (Optional) Program to check the integrity (sha256sum, md5sum...)
|
||||
# default: sha256
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
# (Optional) Archive format
|
||||
# default: tar.gz
|
||||
SOURCE_FORMAT=zip
|
||||
# (Optional) Put false if sources are directly in the archive root
|
||||
# default: true
|
||||
SOURCE_IN_SUBDIR=false
|
|
@ -1,6 +0,0 @@
|
|||
SOURCE_URL=https://github.com/mautrix/whatsapp/archive/v0.1.10.tar.gz
|
||||
SOURCE_SUM=388bf9a0ec6771fba4018763fa112a8076effef0792eacc79d16c2b9eb2e13eb
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=true
|
||||
#SOURCE_FILENAME=
|
6
conf/arm64.src
Normal file
6
conf/arm64.src
Normal file
|
@ -0,0 +1,6 @@
|
|||
SOURCE_URL=https://github.com/mautrix/whatsapp/releases/download/v0.2.3/mautrix-whatsapp-arm64
|
||||
SOURCE_SUM=4a9dc02c40b7220490bd372968cd3243989f2de50ab825f24bae8ca9bbaf8024
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_IN_SUBDIR=false
|
||||
SOURCE_FILENAME=mautrix-whatsapp
|
||||
SOURCE_EXTRACT=false
|
6
conf/armhf.src
Normal file
6
conf/armhf.src
Normal file
|
@ -0,0 +1,6 @@
|
|||
SOURCE_URL=https://github.com/mautrix/whatsapp/releases/download/v0.2.3/mautrix-whatsapp-arm
|
||||
SOURCE_SUM=79769cf5103cb158e27dc94ebda9f993559a57d9798ec71d72254d5249b3f092
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_IN_SUBDIR=false
|
||||
SOURCE_FILENAME=mautrix-whatsapp
|
||||
SOURCE_EXTRACT=false
|
246
conf/config.yaml
246
conf/config.yaml
|
@ -1,4 +1,4 @@
|
|||
# From v0.1.7 https://github.com/tulir/mautrix-whatsapp/blob/master/example-config.yaml
|
||||
# From v0.2.1 https://github.com/mautrix/whatsapp/blob/master/example-config.yaml
|
||||
# Homeserver details.
|
||||
homeserver:
|
||||
# The address that this appservice can use to connect to the homeserver.
|
||||
|
@ -8,11 +8,15 @@ homeserver:
|
|||
#domain: example.com
|
||||
domain: __SERVER_NAME__
|
||||
|
||||
# Is the homeserver actually mautrix-asmux?
|
||||
asmux: false
|
||||
# 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
|
||||
|
||||
# Endpoint for reporting per-message status.
|
||||
message_send_checkpoint_endpoint: null
|
||||
|
||||
# Application service host/registration related details.
|
||||
# Changing these values requires regeneration of the registration.
|
||||
appservice:
|
||||
|
@ -33,8 +37,8 @@ appservice:
|
|||
# The database URI.
|
||||
# SQLite: File name is enough. https://github.com/mattn/go-sqlite3#connection-string
|
||||
# Postgres: Connection string. For example, postgres://user:password@host/database?sslmode=disable
|
||||
#uri: mautrix-whatsapp.db
|
||||
uri: postgres://__MAUTRIX_WHATSAPP_USER__:__MAUTRIX_WHATSAPP_DB_PWD__@localhost:5432/__MAUTRIX_WHATSAPP_DB_NAME__
|
||||
# To connect via Unix socket, use something like postgres:///dbname?host=/var/run/postgresql #uri: mautrix-whatsapp.db
|
||||
uri: postgres://__APP__:__DB_PWD__@localhost:5432/__DB_NAME__
|
||||
# Maximum number of connections. Mostly relevant for Postgres.
|
||||
max_open_conns: 20
|
||||
max_idle_conns: 2
|
||||
|
@ -43,38 +47,47 @@ appservice:
|
|||
provisioning:
|
||||
# Prefix for the provisioning API paths.
|
||||
prefix: /_matrix/provision/v1
|
||||
# Shared secret for authentication. If set to "disable", the provisioning API will be disabled.
|
||||
shared_secret: disable
|
||||
# Shared secret for authentication. If set to "generate", a random secret will be generated,
|
||||
# or if set to "disable", the provisioning API will be disabled.
|
||||
shared_secret: generate
|
||||
|
||||
# The unique ID of this appservice.
|
||||
#id: whatsapp
|
||||
id: __WHATSAPPBOT__
|
||||
id: __BOTNAME__
|
||||
# Appservice bot details.
|
||||
bot:
|
||||
# Username of the appservice bot.
|
||||
#username: whatsappbot
|
||||
username: __WHATSAPPBOT__
|
||||
username: __BOTNAME__
|
||||
# Display name and avatar for bot. Set to "remove" to remove display name/avatar, leave empty
|
||||
# to leave display name/avatar as-is.
|
||||
displayname: WhatsApp bridge bot
|
||||
avatar: mxc://maunium.net/NeXNQarUbrlYBiPCpprYsRqr
|
||||
|
||||
# Whether or not to receive ephemeral events via appservice transactions.
|
||||
# Requires MSC2409 support (i.e. Synapse 1.22+).
|
||||
# You should disable bridge -> sync_with_custom_puppets when this is enabled.
|
||||
ephemeral_events: false
|
||||
|
||||
# Authentication tokens for AS <-> HS communication. Autogenerated; do not modify.
|
||||
as_token: "This value is generated when generating the registration"
|
||||
hs_token: "This value is generated when generating the registration"
|
||||
|
||||
# Prometheus config.
|
||||
metrics:
|
||||
# Whether or not to enable prometheus metrics
|
||||
# Enable prometheus metrics?
|
||||
enabled: false
|
||||
# IP and port where the metrics listener should be. The path is always /metrics
|
||||
listen: 127.0.0.1:8001
|
||||
|
||||
# Config for things that are directly sent to WhatsApp.
|
||||
whatsapp:
|
||||
# Device name that's shown in the "WhatsApp Web" section in the mobile app.
|
||||
os_name: Mautrix-WhatsApp bridge
|
||||
# Browser name that determines the logo shown in the mobile app. If the name is unrecognized, a generic icon is shown.
|
||||
# Use the name of an actual browser (Chrome, Firefox, Safari, IE, Edge, Opera) if you want a specific icon.
|
||||
browser_name: mx-wa
|
||||
# Browser name that determines the logo shown in the mobile app.
|
||||
# Must be "unknown" for a generic icon or a valid browser name if you want a specific icon.
|
||||
# List of valid browser names: https://github.com/tulir/whatsmeow/blob/2a72655ef600a7fd7a2e98d53ec6da029759c4b8/binary/proto/def.proto#L1582-L1594
|
||||
browser_name: unknown
|
||||
|
||||
# Bridge config
|
||||
bridge:
|
||||
|
@ -82,130 +95,77 @@ bridge:
|
|||
# {{.}} is replaced with the phone number of the WhatsApp user.
|
||||
username_template: whatsapp_{{.}}
|
||||
# Displayname template for WhatsApp users.
|
||||
# {{.Notify}} - nickname set by the WhatsApp user
|
||||
# {{.VName}} - validated WhatsApp business name
|
||||
# {{.JID}} - phone number (international format)
|
||||
# {{.PushName}} - nickname set by the WhatsApp user
|
||||
# {{.BusinessName}} - validated WhatsApp business name
|
||||
# {{.Phone}} - phone number (international format)
|
||||
# The following variables are also available, but will cause problems on multi-user instances:
|
||||
# {{.Name}} - display name from contact list
|
||||
# {{.Short}} - short display name from contact list
|
||||
displayname_template: "{{if .Notify}}{{.Notify}}{{else if .VName}}{{.VName}}{{else}}{{.JID}}{{end}} (WA)"
|
||||
# Localpart template for per-user room grouping community IDs.
|
||||
# On startup, the bridge will try to create these communities, add all of the specific user's
|
||||
# portals to the community, and invite the Matrix user to it.
|
||||
# (Note that, by default, non-admins might not have your homeserver's permission to create
|
||||
# communities.)
|
||||
# {{.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}}
|
||||
|
||||
# WhatsApp connection timeout in seconds.
|
||||
connection_timeout: 20
|
||||
# If WhatsApp doesn't respond within connection_timeout, should the bridge try to fetch the message
|
||||
# to see if it was actually bridged? Use this if you have problems with sends timing out but actually
|
||||
# succeeding.
|
||||
fetch_message_on_timeout: false
|
||||
# Whether or not the bridge should send a read receipt from the bridge bot when a message has been
|
||||
# sent to WhatsApp. If fetch_message_on_timeout is enabled, a successful post-timeout fetch will
|
||||
# trigger a read receipt too.
|
||||
# {{.FullName}} - full name from contact list
|
||||
# {{.FirstName}} - first name from contact list
|
||||
displayname_template: "{{if .PushName}}{{.PushName}}{{else if .BusinessName}}{{.BusinessName}}{{else}}{{.JID}}{{end}} (WA)"
|
||||
# Should the bridge send a read receipt from the bridge bot when a message has been sent to WhatsApp?
|
||||
delivery_receipts: false
|
||||
# Maximum number of times to retry connecting on connection error.
|
||||
max_connection_attempts: 3
|
||||
# Number of seconds to wait between connection attempts.
|
||||
# Negative numbers are exponential backoff: -connection_retry_delay + 1 + 2^attempts
|
||||
connection_retry_delay: -1
|
||||
# Whether or not the bridge should send a notice to the user's management room when it retries connecting.
|
||||
# If false, it will only report when it stops retrying.
|
||||
report_connection_retry: true
|
||||
# Whether or not the bridge should reconnect even if WhatsApp says another web client connected.
|
||||
aggressive_reconnect: false
|
||||
# Maximum number of seconds to wait for chats to be sent at startup.
|
||||
# If this is too low and you have lots of chats, it could cause backfilling to fail.
|
||||
chat_list_wait: 30
|
||||
# Maximum number of seconds to wait to sync portals before force unlocking message processing.
|
||||
# If this is too low and you have lots of chats, it could cause backfilling to fail.
|
||||
portal_sync_wait: 600
|
||||
user_message_buffer: 1024
|
||||
# Should incoming calls send a message to the Matrix room?
|
||||
call_start_notices: true
|
||||
# Should another user's cryptographic identity changing send a message to Matrix?
|
||||
identity_change_notices: false
|
||||
# Should a "reactions not yet supported" warning be sent to the Matrix room when a user reacts to a message?
|
||||
reaction_notices: true
|
||||
portal_message_buffer: 128
|
||||
|
||||
# Whether or not to send call start/end notices to Matrix.
|
||||
call_notices:
|
||||
start: true
|
||||
end: true
|
||||
|
||||
# Number of chats to sync for new users.
|
||||
initial_chat_sync_count: 10
|
||||
# Number of old messages to fill when creating new portal rooms.
|
||||
initial_history_fill_count: 20
|
||||
# Whether or not notifications should be turned off while filling initial history.
|
||||
# Only applicable when using double puppeting.
|
||||
initial_history_disable_notifications: false
|
||||
# Maximum number of chats to sync when recovering from downtime.
|
||||
# Set to -1 to sync all new chats during downtime.
|
||||
recovery_chat_sync_limit: -1
|
||||
# Whether or not to sync history when recovering from downtime.
|
||||
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.
|
||||
# Settings for handling history sync payloads. These settings only apply right after login,
|
||||
# because the phone only sends the history sync data once, and there's no way to re-request it
|
||||
# (other than logging out and back in again).
|
||||
history_sync:
|
||||
# Should the bridge create portals for chats in the history sync payload?
|
||||
create_portals: true
|
||||
# Maximum age of chats in seconds to create portals for. Set to 0 to create portals for all chats in sync payload.
|
||||
max_age: 604800
|
||||
# Enable backfilling history sync payloads from WhatsApp using batch sending?
|
||||
# This requires a server with MSC2716 support, which is currently an experimental feature in synapse.
|
||||
# It can be enabled by setting experimental_features -> msc2716_enabled to true in homeserver.yaml.
|
||||
# Note that prior to Synapse 1.49, there were some bugs with the implementation, especially if using event persistence workers.
|
||||
# There are also still some issues in Synapse's federation implementation.
|
||||
backfill: false
|
||||
# Use double puppets for backfilling?
|
||||
# In order to use this, the double puppets must be in the appservice's user ID namespace
|
||||
# (because the bridge can't use the double puppet access token with batch sending).
|
||||
# This only affects double puppets on the local server, double puppets on other servers will never be used.
|
||||
double_puppet_backfill: false
|
||||
# Should the bridge request a full sync from the phone when logging in?
|
||||
# This bumps the size of history syncs from 3 months to 1 year.
|
||||
request_full_sync: false
|
||||
# Should puppet avatars be fetched from the server even if an avatar is already set?
|
||||
user_avatar_sync: true
|
||||
# Whether or not Matrix users leaving groups should be bridged to WhatsApp
|
||||
# Should Matrix users leaving groups be bridged to WhatsApp?
|
||||
bridge_matrix_leave: true
|
||||
# Maximum number of seconds since last message in chat to skip
|
||||
# syncing the chat in any case. This setting will take priority
|
||||
# over both recovery_chat_sync_limit and initial_chat_sync_count.
|
||||
# Default is 3 days = 259200 seconds
|
||||
# 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
|
||||
# syncing the chat in any case. This setting will take priority
|
||||
# over both recovery_chat_sync_limit and initial_chat_sync_count.
|
||||
# Default is 3 days = 259200 seconds
|
||||
sync_max_chat_age: 259200
|
||||
|
||||
# Whether or not to sync with custom puppets to receive EDUs that
|
||||
# are not normally sent to appservices.
|
||||
# Should the bridge sync with double puppeting to receive EDUs that aren't normally sent to appservices.
|
||||
sync_with_custom_puppets: true
|
||||
# Whether or not to update the m.direct account data event when double puppeting is enabled.
|
||||
# Should the bridge update the m.direct account data event when double puppeting is enabled.
|
||||
# Note that updating the m.direct event is not atomic (except with mautrix-asmux)
|
||||
# and is therefore prone to race conditions.
|
||||
sync_direct_chat_list: false
|
||||
# When double puppeting is enabled, users can use `!wa toggle` to change whether or not
|
||||
# When double puppeting is enabled, users can use `!wa toggle` to change whether
|
||||
# presence and read receipts are bridged. These settings set the default values.
|
||||
# Existing users won't be affected when these are changed.
|
||||
default_bridge_receipts: true
|
||||
default_bridge_presence: true
|
||||
# Shared secret for https://github.com/devture/matrix-synapse-shared-secret-auth
|
||||
# Servers to always allow double puppeting from
|
||||
double_puppet_server_map:
|
||||
example.com: https://example.com
|
||||
# Allow using double puppeting from any server with a valid client .well-known file.
|
||||
double_puppet_allow_discovery: false
|
||||
# Shared secrets for https://github.com/devture/matrix-synapse-shared-secret-auth
|
||||
#
|
||||
# If set, custom puppets will be enabled automatically for local users
|
||||
# If set, double puppeting will be enabled automatically for local users
|
||||
# instead of users having to find an access token and run `login-matrix`
|
||||
# manually.
|
||||
login_shared_secret: null
|
||||
|
||||
# Whether or not to invite own WhatsApp user's Matrix puppet into private
|
||||
# chat portals when backfilling if needed.
|
||||
# This always uses the default puppet instead of custom puppets due to
|
||||
# rate limits and timestamp massaging.
|
||||
invite_own_puppet_for_backfilling: true
|
||||
# Whether or not to explicitly set the avatar and room name for private
|
||||
# chat portal rooms. This can be useful if the previous field works fine,
|
||||
# but causes room avatar/name bugs.
|
||||
login_shared_secret_map:
|
||||
example.com: foobar
|
||||
# Should the bridge explicitly set the avatar and room name for private chat portal rooms?
|
||||
private_chat_portal_meta: false
|
||||
# Whether or not Matrix m.notice-type messages should be bridged.
|
||||
# Should Matrix m.notice-type messages be bridged?
|
||||
bridge_notices: true
|
||||
# Set this to true to tell the bridge to re-send m.bridge events to all rooms on the next run.
|
||||
# This field will automatically be changed back to false after it,
|
||||
# except if the config file is not writable.
|
||||
# This field will automatically be changed back to false after it, except if the config file is not writable.
|
||||
resend_bridge_info: false
|
||||
# When using double puppeting, should muted chats be muted in Matrix?
|
||||
mute_bridging: false
|
||||
|
@ -215,18 +175,23 @@ bridge:
|
|||
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.
|
||||
# Should mute status and tags 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.
|
||||
# Should WhatsApp status messages 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.
|
||||
enable_status_broadcast: true
|
||||
# Should the status broadcast room be muted and moved into low priority by default?
|
||||
# This is only applied when creating the room, the user can unmute/untag it later.
|
||||
mute_status_broadcast: true
|
||||
# Should the bridge use thumbnails from WhatsApp?
|
||||
# They're disabled by default due to very low resolution.
|
||||
whatsapp_thumbnail: false
|
||||
|
||||
# Allow invite permission for user. User can invite any bots to room with whatsapp
|
||||
# users (private chat and groups)
|
||||
allow_user_invite: false
|
||||
# Whether or not created rooms should have federation enabled.
|
||||
# If false, created portal rooms will never be federated.
|
||||
federate_rooms: true
|
||||
|
||||
# The prefix for commands. Only required in non-management rooms.
|
||||
command_prefix: "!wa"
|
||||
|
@ -241,14 +206,14 @@ bridge:
|
|||
# Sent when joining a management room and the user is not logged in.
|
||||
welcome_unconnected: "Use `help` for help or `login` to log in."
|
||||
# Optional extra text sent when joining a management room.
|
||||
# additional_help: "This would be some additional text in case you need it."
|
||||
additional_help: ""
|
||||
|
||||
# End-to-bridge encryption support options.
|
||||
#
|
||||
# See https://docs.mau.fi/bridges/general/end-to-bridge-encryption.html for more info.
|
||||
encryption:
|
||||
# Allow encryption, work in group chat rooms with e2ee enabled
|
||||
allow: false
|
||||
allow: __ENCRYPTION__
|
||||
# Default to encryption, force-enable encryption in all portals the bridge creates
|
||||
# This will cause the bridge bot to be in private chats for the encryption to work properly.
|
||||
# It is recommended to also set private_chat_portal_meta to true when using this.
|
||||
|
@ -268,7 +233,7 @@ bridge:
|
|||
|
||||
# Permissions for using the bridge.
|
||||
# Permitted values:
|
||||
# relaybot - Talk through the relaybot (if enabled), no access otherwise
|
||||
# relay - Talk through the relaybot (if enabled), no access otherwise
|
||||
# user - Access to use the bridge to chat with a WhatsApp account.
|
||||
# admin - User level and some additional administration tools
|
||||
# Permitted keys:
|
||||
|
@ -276,25 +241,20 @@ bridge:
|
|||
# domain - All users on that homeserver
|
||||
# mxid - Specific user
|
||||
permissions:
|
||||
"*": relaybot
|
||||
"*": relay
|
||||
#"example.com": user
|
||||
"__BOTUSERS__": user
|
||||
#"@admin:example.com": admin
|
||||
"__BOTADMIN__": admin
|
||||
|
||||
relaybot:
|
||||
# Whether or not relaybot support is enabled.
|
||||
# Settings for relay mode
|
||||
relay:
|
||||
# Whether relay mode should be allowed. If allowed, `!wa set-relay` can be used to turn any
|
||||
# authenticated user into a relaybot for that chat.
|
||||
#enabled: false
|
||||
enabled: __ENABLE_RELAYBOT__
|
||||
# The management room for the bot. This is where all status notifications are posted and
|
||||
# in this room, you can use `!wa <command>` instead of `!wa relaybot <command>`. Omitting
|
||||
# the command prefix completely like in user management rooms is not possible.
|
||||
#management: "!foo:example.com"
|
||||
management: "!__RELAYBOT_MANAGEMENT_ROOM__:__SERVER_NAME__"
|
||||
# List of users to invite to all created rooms that include the relaybot.
|
||||
#invites: []
|
||||
invites:
|
||||
- "__RELAYBOT_INVITE__"
|
||||
# Should only admins be allowed to set themselves as relay users?
|
||||
admin_only: true
|
||||
# The formats to use when sending messages to WhatsApp via the relaybot.
|
||||
message_formats:
|
||||
m.text: "<b>{{ .Sender.Displayname }}</b>: {{ .Message }}"
|
||||
|
@ -312,15 +272,15 @@ logging:
|
|||
#directory: ./logs
|
||||
directory: /var/log/__APP__
|
||||
# Available variables: .Date for the file date and .Index for different log files on the same day.
|
||||
# Set this to null to disable logging to file.
|
||||
#file_name_format: "{{.Date}}-{{.Index}}.log"
|
||||
file_name_format: "__LOG_FORMAT__"
|
||||
file_name_format: null
|
||||
# Date format for file names in the Go time format: https://golang.org/pkg/time/#pkg-constants
|
||||
#file_date_format: 2006-01-02
|
||||
#file_date_format: "2006-01-02"
|
||||
# Log file permissions.
|
||||
file_mode: 0600
|
||||
file_mode: 0o600
|
||||
# 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
|
||||
timestamp_format: "Jan _2, 2006 15:04:05"
|
||||
# Minimum severity for log messages printed to stdout/stderr. This doesn't affect the log file. # Options: debug, info, warn, error, fatal
|
||||
#print_level: debug
|
||||
print_level: __LOG_LEVEL__
|
||||
|
|
|
@ -5,40 +5,11 @@ After=matrix-synapse.service
|
|||
[Service]
|
||||
Type=simple
|
||||
User=__APP__
|
||||
Group=__APP__
|
||||
WorkingDirectory=/opt/yunohost/__APP__
|
||||
ExecStart=/opt/yunohost/__APP__/mautrix-whatsapp -c=/opt/yunohost/__APP__/config.yaml >> /var/log/__APP__/log.log 2>&1
|
||||
ExecStart=/opt/yunohost/__APP__/mautrix-whatsapp -c=/opt/yunohost/__APP__/config.yaml >> /var/log/__APP__/__APP__.log 2>&1
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
|
||||
#[Service]
|
||||
#Type=exec
|
||||
#User=__APP__
|
||||
#WorkingDirectory=/opt/yunohost/__APP__
|
||||
#ExecStart=/opt/yunohost/__APP__/mautrix-whatsapp -c=/opt/yunohost/__APP__/config.yaml >> /var/log/__APP__/log.log 2>&1
|
||||
#Restart=on-failure
|
||||
#RestartSec=30s
|
||||
|
||||
# Optional hardening to improve security
|
||||
#ReadWritePaths=/opt/yunohost/__APP__ /var/log/__APP__/
|
||||
#NoNewPrivileges=yes
|
||||
#MemoryDenyWriteExecute=true
|
||||
#PrivateDevices=yes
|
||||
#PrivateTmp=yes
|
||||
#ProtectHome=yes
|
||||
#ProtectSystem=strict
|
||||
#ProtectControlGroups=true
|
||||
#RestrictSUIDSGID=true
|
||||
#RestrictRealtime=true
|
||||
#LockPersonality=true
|
||||
#ProtectKernelLogs=true
|
||||
#ProtectKernelTunables=true
|
||||
#ProtectHostname=true
|
||||
#ProtectKernelModules=true
|
||||
#PrivateUsers=true
|
||||
#ProtectClock=true
|
||||
#SystemCallArchitectures=native
|
||||
#SystemCallErrorNumber=EPERM
|
||||
#SystemCallFilter=@system-service
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "Matrix-Whatsapp bridge",
|
||||
"name": "Matrix WhatsApp bridge",
|
||||
"id": "mautrix_whatsapp",
|
||||
"packaging_format": 1,
|
||||
"description": {
|
||||
"en": "A WhatsApp puppeting bridge for Matrix/Synapse.",
|
||||
"fr": "Passerelle WhatsApp pour Matrix/Synapse."
|
||||
"en": "Matrix / Synapse puppeting bridge for WhatsApp",
|
||||
"fr": "Passerelle Matrix / Synapse pour WhatsApp"
|
||||
},
|
||||
"version": "0.1.10~ynh1",
|
||||
"version": "0.2.3~ynh1",
|
||||
"url": "https://github.com/mautrix/whatsapp",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"maintainer": {
|
||||
|
@ -15,7 +15,7 @@
|
|||
"url": "https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 4.1.0"
|
||||
"yunohost": ">= 4.3.0"
|
||||
},
|
||||
"multi_instance": true,
|
||||
"services": [
|
||||
|
@ -27,27 +27,27 @@
|
|||
"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"
|
||||
"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."
|
||||
"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",
|
||||
"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"
|
||||
"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. 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."
|
||||
"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"
|
||||
},
|
||||
|
@ -55,23 +55,27 @@
|
|||
"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 ?"
|
||||
"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 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."
|
||||
"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.",
|
||||
"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": 1
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "encryption",
|
||||
"type": "boolean",
|
||||
"ask": {
|
||||
"en": "Enable end-to-bridge encryption ?",
|
||||
"fr": "Activer le chiffrement entre synapse et le bridge ?"
|
||||
"en": "Enable end-to-bridge encryption?",
|
||||
"fr": "Activer le chiffrement entre Synapse et le bridge ?"
|
||||
},
|
||||
"default": 0
|
||||
"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",
|
||||
|
@ -82,8 +86,8 @@
|
|||
},
|
||||
"example": "@johndoe:localsynapse.servername or @johndoe:matrix.org",
|
||||
"help": {
|
||||
"en": "The WhatsApp bot administrator does not need to be a local synapse account.",
|
||||
"fr": "Le compte administrateur du robot WhatsApp peut ne pas être un compte local synapse."
|
||||
"en": "The WhatsApp bot administrator does not need to be a local Synapse account.",
|
||||
"fr": "Le compte administrateur du robot WhatsApp peut ne pas être un compte local Synapse."
|
||||
},
|
||||
"default": "Your main Matrix account"
|
||||
},
|
||||
|
@ -91,14 +95,14 @@
|
|||
"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 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 la passerelle WhatsApp."
|
||||
},
|
||||
"example": "admin or local or @johndoe:server.name or server.name or *",
|
||||
"default": "admin",
|
||||
"example": "admin or domain or @johndoe:server.name or server.name or *",
|
||||
"default": "domain",
|
||||
"help": {
|
||||
"en": "Either the administrator only (admin), all local synapse users (local), a remote or local user (@johndoe:server.name), a remote server (matrix.org), or all remote/local servers (*) can be authorized. Give the matrix server_name, not the full domain/url.",
|
||||
"fr": "On peut autoriser le compte administrateur seul (admin), tous les comptes synapse locaux (local), un compte local ou distant (@johndoe:server.name), un serveur distant (matrix.org), ou tous les serveurs remote/local (*). Donner le nom du serveur matrix, pas le domaine/url complet."
|
||||
"en": "Either the administrator only (admin), all local Synapse users (domain), 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": "L'administrateur seulement (admin), tous les comptes Synapse locaux (domain), 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."
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
## Problem
|
||||
- *Description of why you made this PR*
|
||||
|
||||
## Solution
|
||||
- *And how do you fix that problem*
|
||||
|
||||
## PR Status
|
||||
- [ ] Code finished.
|
||||
- [ ] Tested with Package_check.
|
||||
- [ ] Fix or enhancement tested.
|
||||
- [ ] Upgrade from last version tested.
|
||||
- [ ] Can be reviewed and tested.
|
||||
|
||||
## Package_check results
|
||||
---
|
||||
*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results*
|
||||
|
||||
[/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/mautrix_whatsapp_ynh%20PR-NUM-%20(USERNAME)/)
|
|
@ -6,27 +6,11 @@
|
|||
|
||||
# dependencies used by the app
|
||||
pkg_dependencies="g++ postgresql ffmpeg"
|
||||
GO_VERSION="1.15"
|
||||
GO_PATH="/usr/lib/go-$GO_VERSION/bin"
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
# Detect the system architecture to download the right tarball
|
||||
# NOTE: `uname -m` is more accurate and universal than `arch`
|
||||
# See https://en.wikipedia.org/wiki/Uname
|
||||
if [ -n "$(uname -m | grep 64)" ]; then
|
||||
architecture="amd64"
|
||||
elif [ -n "$(uname -m | grep 86)" ]; then
|
||||
architecture="386"
|
||||
elif [ -n "$(uname -m | grep arm)" ]; then
|
||||
architecture="armv6l"
|
||||
else
|
||||
ynh_die "Unable to detect your achitecture, please open a bug describing \
|
||||
your hardware and the result of the command \"uname -m\"." 1
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -29,44 +29,40 @@ ynh_print_info --message="Loading installation settings..."
|
|||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
#domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
mautrix_whatsapp_db_name=$(ynh_app_setting_get --app=$app --key=mautrix_whatsapp_db_name)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
#=================================================
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up the main app directory..."
|
||||
|
||||
ynh_backup --src_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up the PostgreSQL database..."
|
||||
|
||||
ynh_psql_dump_db --database="$mautrix_whatsapp_db_name" > ${YNH_CWD}/dump.sql
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
# BACKUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up logrotate configuration..."
|
||||
|
||||
ynh_backup --src_path="/var/log/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up systemd configuration..."
|
||||
|
||||
#ynh_backup --src_path="/etc/default/$app"
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up the PostgreSQL database..."
|
||||
|
||||
ynh_psql_dump_db --database="$db_name" > db.sql
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
271
scripts/install
271
scripts/install
|
@ -24,158 +24,83 @@ ynh_abort_if_errors
|
|||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
|
||||
botname=$YNH_APP_ARG_BOTNAME
|
||||
bot_synapse_adm=$YNH_APP_ARG_BOT_SYNAPSE_ADM
|
||||
encryption=$YNH_APP_ARG_ENCRYPTION
|
||||
botadmin=$YNH_APP_ARG_BOTADMIN
|
||||
botusers=$YNH_APP_ARG_BOTUSERS
|
||||
if [ "$botusers" = "admin" ]
|
||||
then
|
||||
botusers=$botadmin
|
||||
fi
|
||||
synapsenumber=$YNH_APP_ARG_SYNAPSENUMBER
|
||||
# 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"
|
||||
synapse_instance="synapse"
|
||||
else
|
||||
synapse_instance="synapse__$synapsenumber"
|
||||
synapse_instance="synapse__$synapsenumber"
|
||||
fi
|
||||
server_name=$(ynh_app_setting_get --app $synapse_instance --key server_name)
|
||||
domain=$(ynh_app_setting_get --app $synapse_instance --key domain)
|
||||
|
||||
whatsappbot=$YNH_APP_ARG_WHATSAPPBOT
|
||||
bot_synapse_adm=$YNH_APP_ARG_BOT_SYNAPSE_ADM
|
||||
mautrix_version=$(ynh_app_upstream_version)
|
||||
architecture=$YNH_ARCH
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
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
|
||||
|
||||
#=================================================
|
||||
# SET CONSTANTS
|
||||
#=================================================
|
||||
|
||||
whatsappbot_synapse_db_user="@$whatsappbot:$server_name"
|
||||
mautrix_whatsapp_user=$app
|
||||
mautrix_whatsapp_db_name=$app
|
||||
mautrix_whatsapp_db_user=$app
|
||||
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
|
||||
#=================================================
|
||||
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"
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
|
||||
#=================================================
|
||||
# SET CONSTANTS
|
||||
#=================================================
|
||||
|
||||
enable_relaybot="true"
|
||||
# Options: debug, info, warn, error, fatal
|
||||
log_level="error"
|
||||
#log_format="$app.log"
|
||||
|
||||
synapse_db_name="matrix_$synapse_instance"
|
||||
bot_synapse_db_user="@$botname:$server_name"
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing installation settings..." --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=botname --value=$botname
|
||||
ynh_app_setting_set --app=$app --key=synapse_instance --value=$synapse_instance
|
||||
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=botusers --value=$botusers
|
||||
ynh_app_setting_set --app=$app --key=botadmin --value=$botadmin
|
||||
ynh_app_setting_set --app=$app --key=mautrix_version --value=$mautrix_version
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# FIND AND OPEN A PORT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring PORT..." --weight=1
|
||||
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)
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing installation settings..." --weight=7
|
||||
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
ynh_app_setting_set --app=$app --key=server_name --value=$server_name
|
||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||
ynh_app_setting_set --app=$app --key=whatsappbot --value=$whatsappbot
|
||||
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=bot_synapse_adm --value=$bot_synapse_adm
|
||||
ynh_app_setting_set --app=$app --key=encryption --value=$encryption
|
||||
ynh_app_setting_set --app=$app --key=botadmin --value=$botadmin
|
||||
ynh_app_setting_set --app=$app --key=botusers --value=$botusers
|
||||
ynh_app_setting_set --app=$app --key=mautrix_version --value=$mautrix_version
|
||||
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
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=97
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
if [ $encryption = true ]
|
||||
then
|
||||
ynh_install_extra_app_dependencies --repo="http://http.debian.net/debian buster-backports main" --package="libolm-dev" --key="https://keyserver.ubuntu.com/pks/lookup?search=0x0E98404D386FA1D9&op=get"
|
||||
fi
|
||||
|
||||
ynh_install_extra_app_dependencies --repo="http://http.debian.net/debian buster-backports main" --package="golang-go" --key="https://keyserver.ubuntu.com/pks/lookup?search=0x0E98404D386FA1D9&op=get"
|
||||
|
||||
src_path="$final_path"/src
|
||||
mkdir -p $src_path
|
||||
export GOPATH="$src_path"
|
||||
export GOCACHE="$GOPATH"/.cache/go-build
|
||||
|
||||
export PATH=$PATH:$GO_PATH
|
||||
env_path=$PATH
|
||||
|
||||
#=================================================
|
||||
# CREATE A POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=3
|
||||
|
||||
# Create postgresql database
|
||||
ynh_psql_test_if_first_run
|
||||
ynh_print_OFF
|
||||
ynh_psql_create_user $mautrix_whatsapp_db_user $mautrix_whatsapp_db_pwd
|
||||
ynh_print_ON
|
||||
ynh_psql_execute_as_root \
|
||||
--sql="CREATE DATABASE ""$mautrix_whatsapp_db_name"" ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER ""$mautrix_whatsapp_db_user"";"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --weight=3
|
||||
|
||||
#if [ -n "$(uname -m | grep 64)" ]
|
||||
#then
|
||||
# ynh_setup_source --dest_dir=$final_path/ --source_id="amd64_$(lsb_release --codename --short)"
|
||||
#else
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# BUILD GO
|
||||
#=================================================
|
||||
ynh_script_progression --message="Build with golang..." --weight=194
|
||||
|
||||
pushd "$final_path" || ynh_die
|
||||
ynh_script_progression --message="Building the sources (it will take some time)..." --weight=6
|
||||
if [ $encryption = true ]
|
||||
then
|
||||
# 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
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=10
|
||||
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
|
@ -183,104 +108,100 @@ popd || ynh_die
|
|||
ynh_script_progression --message="Configuring system user..." --weight=1
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username=$mautrix_whatsapp_user
|
||||
ynh_system_user_create --username=$app
|
||||
|
||||
#=================================================
|
||||
# CREATE A POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=3
|
||||
|
||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
db_pwd=$(ynh_string_random --length=30)
|
||||
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
|
||||
ynh_psql_test_if_first_run
|
||||
ynh_psql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --weight=5
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path" --source_id=$architecture
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chown $app:$app "$final_path"
|
||||
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring Mautrix Bridge..." --weight=2
|
||||
|
||||
ynh_add_config --template="../conf/config.yaml" --destination="$final_path/config.yaml"
|
||||
chmod -R 750 "$final_path"
|
||||
chown -R $app:$app "$final_path"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring a systemd service..." --weight=20
|
||||
ynh_script_progression --message="Configuring a systemd service..." --weight=5
|
||||
|
||||
# Create systemd config for mautrix-whatsapp
|
||||
#cp ../conf/default_mautrix-whatsapp /etc/default/$app
|
||||
ynh_add_systemd_config --service=$app
|
||||
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# SET MAUTRIX-WHATSAPP CONFIG
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring Mautrix-WhatsApp..." --weight=2
|
||||
|
||||
# Configure Mautrix-WhatsApp
|
||||
|
||||
#verify_server_ssl_certificates="true"
|
||||
#matrix_server_supports_asmux="false"
|
||||
#log_filename="/var/log/$app/$app.log"
|
||||
|
||||
#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"
|
||||
|
||||
ynh_add_config --template="../conf/config.yaml" --destination="$mautrix_config_path"
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# 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 $final_path/config.yaml -r /etc/matrix-$synapse_instance/app-service/$app.yaml
|
||||
chown -R $app:$app "$final_path"
|
||||
|
||||
#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 \
|
||||
|| ynh_die "Synapse can't restart with the appservice configuration"
|
||||
# Handled by synapse: synapse_ynh adds all registration files added in $app_service_registration_path to the app_service_config_files list
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
#=================================================
|
||||
|
||||
# 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="$mautrix_config_path"
|
||||
ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml"
|
||||
ynh_store_file_checksum --file="$final_path/config.yaml"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
|
||||
# Set permissions to app files
|
||||
chown -R root: $final_path
|
||||
|
||||
# WARNING : theses command are used in INSTALL, UPGRADE, RESTORE
|
||||
# For any update do it in all files
|
||||
chown $mautrix_whatsapp_user:root -R $final_path
|
||||
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring log rotation..." --weight=3
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate --logfile "/var/log/$app/log.log"
|
||||
chown $mautrix_whatsapp_user:root -R /var/log/$app
|
||||
ynh_use_logrotate --logfile "/var/log/$app/$app.log" --specific_user $app/$app
|
||||
chmod -R 600 "/var/log/$app"
|
||||
chmod 700 "/var/log/$app"
|
||||
chown -R $app:$app /var/log/$app
|
||||
|
||||
#=================================================
|
||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
#yunohost service add $app --log "/var/log/$app/log.log"
|
||||
# if using yunohost version 3.2 or more in the 'manifest.json', a description can be added
|
||||
yunohost service add $app --description "$app daemon for bridging Whatsapp and Matrix messages" --log "/var/log/$app/log.log"
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
yunohost service add $app --description "$app daemon for bridging Whatsapp and Matrix messages" --log "/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=15
|
||||
|
||||
# Start a systemd service
|
||||
ynh_systemd_action --service_name=$app --action="start"
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
# Wait until the synapse user is created
|
||||
sleep 30
|
||||
# (Note that, by default, non-admins might not have your homeserver's permission to create communities.)
|
||||
if [ "$bot_synapse_adm" = true ]
|
||||
then
|
||||
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
|
||||
ynh_psql_execute_as_root --database=$synapse_db_name --sql="UPDATE users SET admin = 1 WHERE name = ""$botname"";"
|
||||
#yunohost app action run $synapse_instance set_admin_user -a username=$botname
|
||||
fi
|
||||
ynh_systemd_action --service_name=$app --action="restart"
|
||||
|
||||
|
|
|
@ -19,24 +19,18 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
server_name=$(ynh_app_setting_get --app=$app --key=server_name)
|
||||
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)
|
||||
whatsappbot=$(ynh_app_setting_get --app=$app --key=whatsappbot)
|
||||
botname=$(ynh_app_setting_get --app=$app --key=botname)
|
||||
botadmin=$(ynh_app_setting_get --app=$app --key=botadmin)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
#db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
#db_user=$db_name
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# SET CONSTANTS
|
||||
#=================================================
|
||||
|
||||
src_path=$final_path"_src"
|
||||
synapse_db_name="matrix_$synapse_instance"
|
||||
whatsappbot_synapse_db_user="@$whatsappbot:$server_name"
|
||||
mautrix_whatsapp_user=$app
|
||||
mautrix_whatsapp_db_name=$app
|
||||
mautrix_whatsapp_db_user=$app
|
||||
bot_synapse_db_user="@""$botname"":""$server_name"
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
|
@ -65,10 +59,14 @@ ynh_remove_systemd_config
|
|||
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=$mautrix_whatsapp_db_name --db_name=$mautrix_whatsapp_db_user
|
||||
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 ""$mautrix_whatsapp_user"";"
|
||||
#yunohost app action run $synapse_instance drop_user -a username=$whatsappbot
|
||||
ynh_psql_remove_db --db_user=$db_name --db_name=$db_name
|
||||
ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP OWNED BY ""$app"";"
|
||||
ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP OWNED BY ""$bot_synapse_db_user"";"
|
||||
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 ""$app"";"
|
||||
ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP USER ""$bot_synapse_db_user"";"
|
||||
ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP USER ""$botname"";"
|
||||
#yunohost app action run $synapse_instance drop_user -a username=$botname
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
|
@ -84,7 +82,6 @@ ynh_remove_app_dependencies
|
|||
ynh_script_progression --message="Removing app main directory..." --weight=1
|
||||
|
||||
# Remove the app directory securely
|
||||
#ynh_secure_remove --file="/etc/$app/"
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
||||
#=================================================
|
||||
|
@ -101,9 +98,7 @@ ynh_remove_logrotate
|
|||
ynh_script_progression --message="Removing synapse app service..." --weight=6
|
||||
|
||||
# Remove a directory securely
|
||||
ynh_secure_remove --file="$src_path"
|
||||
|
||||
ynh_secure_remove --file="$app_service_registration_path/$app.yaml"
|
||||
ynh_secure_remove --file="/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"
|
||||
|
@ -119,7 +114,7 @@ ynh_secure_remove --file="/var/log/$app"
|
|||
ynh_script_progression --message="Removing the dedicated system user..." --weight=5
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete --username=$mautrix_whatsapp_user
|
||||
ynh_system_user_delete --username=$app
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
104
scripts/restore
104
scripts/restore
|
@ -28,50 +28,39 @@ ynh_script_progression --message="Loading settings..." --weight=5
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
server_name=$(ynh_app_setting_get --app=$app --key=server_name)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
whatsappbot=$(ynh_app_setting_get --app=$app --key=whatsappbot)
|
||||
botname=$(ynh_app_setting_get --app=$app --key=botname)
|
||||
synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
|
||||
app_service_registration_path=$(ynh_app_setting_get --app=$app --key=app_service_registration_path)
|
||||
bot_synapse_adm=$(ynh_app_setting_get --app=$app --key=bot_synapse_adm)
|
||||
encryption=$(ynh_app_setting_get --app=$app --key=encryption)
|
||||
botadmin=$(ynh_app_setting_get --app=$app --key=botadmin)
|
||||
botusers=$(ynh_app_setting_get --app=$app --key=botusers)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
mautrix_version=$(ynh_app_setting_get --app=$app --key=mautrix_version)
|
||||
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)
|
||||
|
||||
ynh_print_OFF
|
||||
mautrix_whatsapp_db_pwd=$(ynh_app_setting_get --app=$app --key=mautrix_whatsapp_db_pwd)
|
||||
ynh_print_ON
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||
|
||||
mautrix_version=$(ynh_app_upstream_version)
|
||||
|
||||
#=================================================
|
||||
# SET CONSTANTS
|
||||
#=================================================
|
||||
|
||||
synapse_db_name="matrix_$synapse_instance"
|
||||
whatsappbot_synapse_db_user="@$whatsappbot:$server_name"
|
||||
mautrix_whatsapp_user=$app
|
||||
mautrix_whatsapp_db_name=$app
|
||||
mautrix_whatsapp_db_user=$app
|
||||
mautrix_config_path="$final_path/config.yaml"
|
||||
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 "
|
||||
test ! -d $final_path || ynh_die --message="There is already a directory: $final_path "
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
|
@ -80,28 +69,29 @@ ynh_script_progression --message="Recreating the dedicated system user..." --wei
|
|||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# RESTORE USER RIGHTS
|
||||
#=================================================
|
||||
|
||||
# Restore permissions on app files
|
||||
chown -R root: $final_path
|
||||
chown $mautrix_whatsapp_user:root -R $final_path
|
||||
chmod 750 "$final_path"
|
||||
chown $app:$app "$final_path"
|
||||
chmod -R 750 "$final_path"
|
||||
chown -R $app:$app "$final_path"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=100
|
||||
|
||||
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"
|
||||
fi
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE POSTGRESQL DATABASE
|
||||
|
@ -109,20 +99,18 @@ fi
|
|||
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=8
|
||||
|
||||
ynh_psql_test_if_first_run
|
||||
ynh_print_OFF
|
||||
ynh_psql_create_user $mautrix_whatsapp_db_user $mautrix_whatsapp_db_pwd
|
||||
ynh_print_ON
|
||||
ynh_psql_execute_as_root \
|
||||
--sql="CREATE DATABASE ""$mautrix_whatsapp_db_name"" ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER ""$mautrix_whatsapp_db_user"";"
|
||||
ynh_psql_execute_file_as_root --file="${YNH_CWD}/dump.sql" --database="$mautrix_whatsapp_db_name"
|
||||
ynh_psql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd
|
||||
ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# 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 $final_path/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"
|
||||
# Handled by synapse: synapse_ynh adds all registration files added in $app_service_registration_path to the app_service_config_files list
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
|
@ -130,37 +118,39 @@ $final_path/mautrix-whatsapp -g -c $mautrix_config_path -r $app_service_registra
|
|||
ynh_script_progression --message="Restoring the systemd configuration..." --weight=3
|
||||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||
systemctl enable $app.service
|
||||
systemctl enable $app.service --quiet
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_use_logrotate --logfile "/var/log/$app/log.log"
|
||||
chown $mautrix_whatsapp_user:root -R /var/log/$app
|
||||
ynh_use_logrotate --logfile "/var/log/$app/$app.log" --specific_user $app/$app
|
||||
chmod -R 600 "/var/log/$app"
|
||||
chmod 700 "/var/log/$app"
|
||||
chown -R $app:$app /var/log/$app
|
||||
|
||||
#=================================================
|
||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
# if using yunohost version 3.2 or more in the 'manifest.json', a description can be added
|
||||
yunohost service add $app --description "$app daemon for bridging Whatsapp and Matrix messages" --log "/var/log/$app/log.log"
|
||||
yunohost service add $app --description "$app daemon for bridging Whatsapp and Matrix messages" --log "/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=30
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start"
|
||||
#sleep 30
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||
# Wait until the synapse user is created
|
||||
sleep 30
|
||||
# (Note that, by default, non-admins might not have your homeserver's permission to create communities.)
|
||||
# if [ "$bot_is_synapse_admin" = true ]
|
||||
# then
|
||||
# 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
|
||||
# fi
|
||||
#ynh_systemd_action --service_name=$app --action="restart"
|
||||
|
||||
if [ "$bot_synapse_adm" = true ]
|
||||
then
|
||||
ynh_psql_execute_as_root --database=$synapse_db_name --sql="UPDATE users SET admin = 1 WHERE name = ""$botname"";"
|
||||
#yunohost app action run $synapse_instance set_admin_user -a username=$botname
|
||||
fi
|
||||
ynh_systemd_action --service_name=$app --action="restart"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
243
scripts/upgrade
243
scripts/upgrade
|
@ -19,41 +19,36 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
server_name=$(ynh_app_setting_get --app=$app --key=server_name)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
whatsappbot=$(ynh_app_setting_get --app=$app --key=whatsappbot)
|
||||
botname=$(ynh_app_setting_get --app=$app --key=botname)
|
||||
synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
|
||||
app_service_registration_path=$(ynh_app_setting_get --app=$app --key=app_service_registration_path)
|
||||
encryption=$(ynh_app_setting_get --app=$app --key=encryption)
|
||||
botadmin=$(ynh_app_setting_get --app=$app --key=botadmin)
|
||||
botusers=$(ynh_app_setting_get --app=$app --key=botusers)
|
||||
botadmin=$(ynh_app_setting_get --app=$app --key=botadmin)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
mautrix_version=$(ynh_app_setting_get --app=$app --key=mautrix_version)
|
||||
previous_mautrix_version=$(ynh_app_setting_get --app=$app --key=mautrix_version)
|
||||
|
||||
ynh_print_OFF
|
||||
mautrix_whatsapp_db_pwd=$(ynh_app_setting_get --app=$app --key=mautrix_whatsapp_db_pwd)
|
||||
ynh_print_ON
|
||||
#db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||
|
||||
mautrix_version=$(ynh_app_upstream_version)
|
||||
architecture=$YNH_ARCH
|
||||
|
||||
#=================================================
|
||||
# SET CONSTANTS
|
||||
#=================================================
|
||||
|
||||
enable_relaybot="true"
|
||||
# Options: debug, info, warn, error, fatal
|
||||
log_level="error"
|
||||
#log_format="$app.log"
|
||||
|
||||
synapse_db_name="matrix_$synapse_instance"
|
||||
whatsappbot_synapse_db_user="@$whatsappbot:$server_name"
|
||||
mautrix_whatsapp_user=$app
|
||||
mautrix_whatsapp_db_name=$app
|
||||
mautrix_whatsapp_db_user=$app
|
||||
mautrix_config_path="$final_path/config.yaml"
|
||||
upstream_version=$(ynh_app_upstream_version)
|
||||
bot_synapse_db_user="@$botname:$server_name"
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
|
||||
### This helper will compare the version of the currently installed app and the version of the upstream package.
|
||||
### $upgrade_type can have 2 different values
|
||||
### - UPGRADE_APP if the upstream app version has changed
|
||||
### - UPGRADE_PACKAGE if only the YunoHost package has changed
|
||||
### ynh_check_app_version_changed will stop the upgrade if the app is up to date.
|
||||
### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do.
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
|
@ -61,6 +56,37 @@ upgrade_type=$(ynh_check_app_version_changed)
|
|||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||
|
||||
# Migration from <=1.10.0 to >0.2.1
|
||||
ynh_secure_remove --file="$final_path"/community.go
|
||||
ynh_secure_remove --file="$final_path"/database/upgrades/2019-05-23-protoupgrade.go
|
||||
ynh_secure_remove --file="$final_path"/database/upgrades/2019-05-16-message-delete-cascade.go
|
||||
src_path="$final_path"_src
|
||||
ynh_secure_remove --file="$src_path"
|
||||
src_path="$final_path"/src
|
||||
ynh_secure_remove --file="$src_path"
|
||||
|
||||
# Upgrade from >0.2.0
|
||||
botname=$(ynh_app_setting_get --app=$app --key=botname)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||
|
||||
# Upgrade from <=0.2.0
|
||||
if [ -z "$botname" ]
|
||||
then
|
||||
botname=$(ynh_app_setting_get --app=$app --key=whatsappbot)
|
||||
ynh_app_setting_set --app=$app --key=botname --value=$botname
|
||||
fi
|
||||
if [ -z "$db_name" ]
|
||||
then
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=$app)
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
fi
|
||||
if [ -z "$db_pwd" ]
|
||||
then
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mautrix_whatsapp_db_pwd)
|
||||
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
|
||||
fi
|
||||
|
||||
# If db_name doesn't exist, create it
|
||||
#if [ -z "$mautrix_whatsapp_db_name" ]; then
|
||||
# mautrix_whatsapp_db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
|
@ -73,10 +99,6 @@ ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
|||
# ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
#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
|
||||
#=================================================
|
||||
|
@ -100,6 +122,21 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
|||
|
||||
ynh_systemd_action --service_name=$app --action="stop"
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..." --weight=100
|
||||
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=8
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
@ -109,130 +146,28 @@ 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"
|
||||
ynh_setup_source --dest_dir="$final_path" --source_id=$architecture
|
||||
chmod 750 $final_path
|
||||
chown $app:$app $final_path
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..." --weight=100
|
||||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
if [ $encryption = true ]
|
||||
then
|
||||
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
|
||||
# Remove a directory securely
|
||||
ynh_secure_remove --file="$src_path"
|
||||
#export PATH=$PATH:$GO_PATH
|
||||
#env_path=$PATH
|
||||
|
||||
src_path="$final_path"/src
|
||||
mkdir -p $src_path
|
||||
export GOPATH="$src_path"
|
||||
export GOCACHE="$GOPATH"/.cache/go-build
|
||||
|
||||
#=================================================
|
||||
# BUILD GO
|
||||
#=================================================
|
||||
|
||||
# Build mautrix-whatsapp
|
||||
|
||||
pushd "$final_path" || ynh_die
|
||||
ynh_script_progression --message="Building the sources (it will take some time)..." --weight=6
|
||||
if [ $encryption = true ]
|
||||
then
|
||||
# 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
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=8
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$mautrix_whatsapp_user
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# ...
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
#=================================================
|
||||
|
||||
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
||||
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
|
||||
ynh_backup_if_checksum_is_different --file="$mautrix_config_path"
|
||||
ynh_backup_if_checksum_is_different --file="$app_service_registration_path/$app.yaml"
|
||||
ynh_backup_if_checksum_is_different --file="$final_path/config.yaml"
|
||||
ynh_backup_if_checksum_is_different --file="/etc/matrix-$synapse_instance/app-service/$app.yaml"
|
||||
|
||||
#=================================================
|
||||
# SET MAUTRIX-WHATSAPP CONFIG
|
||||
# UPDATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring Mautrix-WhatsApp..." --weight=2
|
||||
ynh_script_progression --message="Configuring Mautrix Bridge..." --weight=2
|
||||
|
||||
# Configure Mautrix-WhatsApp
|
||||
|
||||
#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"
|
||||
|
||||
ynh_add_config --template="../conf/config.yaml" --destination="$mautrix_config_path"
|
||||
|
||||
|
||||
#=================================================
|
||||
# REGISTER SYNAPSE APP-SERVICE
|
||||
#=================================================
|
||||
$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 \
|
||||
|| ynh_die "Synapse can't restart with the appservice configuration"
|
||||
# Handled by synapse: synapse_ynh adds all registration files added in $app_service_registration_path to the app_service_config_files list
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
#=================================================
|
||||
|
||||
# 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="$app_service_registration_path/$app.yaml"
|
||||
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
#ynh_use_logrotate --logfile "/var/log/$app/log.log"
|
||||
#chown $mautrix_whatsapp_user:root -R /var/log/$app
|
||||
# Use logrotate to manage app-specific logfile(s)
|
||||
ynh_use_logrotate --non-append
|
||||
ynh_add_config --template="../conf/config.yaml" --destination="$final_path/config.yaml"
|
||||
chmod -R 750 "$final_path"
|
||||
chown -R $app:$app "$final_path"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
|
@ -242,29 +177,49 @@ ynh_script_progression --message="Upgrading systemd configuration..." --weight=4
|
|||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# REGISTER SYNAPSE APP-SERVICE
|
||||
#=================================================
|
||||
$final_path/mautrix-whatsapp -g -c $final_path/config.yaml -r /etc/matrix-$synapse_instance/app-service/$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 \
|
||||
|| ynh_die "Synapse can't restart with the appservice configuration"
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
#=================================================
|
||||
|
||||
# Recalculate and store the checksum of the file for the next upgrade.
|
||||
ynh_store_file_checksum --file="$final_path/config.yaml"
|
||||
ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
|
||||
|
||||
# Set permissions on app files
|
||||
chown -R root: $final_path
|
||||
chown $mautrix_whatsapp_user:root -R $final_path
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate --logfile "/var/log/$app/$app.log" --specific_user $app/$app
|
||||
chmod -R 600 "/var/log/$app"
|
||||
chmod 700 "/var/log/$app"
|
||||
chown -R $app:$app /var/log/$app
|
||||
|
||||
#=================================================
|
||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
#=================================================
|
||||
#yunohost service add $app --log "/var/log/$app/log.log"
|
||||
# if using yunohost version 3.2 or more in the 'manifest.json', a description can be added
|
||||
yunohost service add $app --description "$app daemon for bridging Whatsapp and Matrix messages" --log "/var/log/$app/log.log"
|
||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
||||
|
||||
yunohost service add $app --description "$app daemon for bridging Whatsapp and Matrix messages" --log "/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
|
||||
chown -R $app:$app "$final_path"
|
||||
ynh_systemd_action --service_name=$app --action="start"
|
||||
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue