diff --git a/README.md b/README.md
index e2b5c1c..d6f7268 100644
--- a/README.md
+++ b/README.md
@@ -3,14 +3,14 @@ N.B.: This README was automatically generated by https://github.com/YunoHost/app
It shall NOT be edited by hand.
-->
-# Matrix WhatsApp bridge for YunoHost
+# Matrix-WhatsApp bridge for YunoHost
[](https://dash.yunohost.org/appci/app/mautrix_whatsapp)  
-[](https://install-app.yunohost.org/?app=mautrix_whatsapp)
+[](https://install-app.yunohost.org/?app=mautrix_whatsapp)
*[Lire ce readme en français.](./README_fr.md)*
-> *This package allows you to install Matrix WhatsApp bridge quickly and simply on a YunoHost server.
+> *This package allows you to install Matrix-WhatsApp bridge quickly and simply on a YunoHost server.
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
## Overview
@@ -24,18 +24,18 @@ Therefore, [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh)
** Attention: always backup and restore the Yunohost matrix_synapse et mautrix_whatsapp apps together!**
-**Shipped version:** 0.6.0~ynh3
+**Shipped version:** 0.7.0~ynh2
## Disclaimers / important information
-### List of known public services
+## List of known public services
* Ask on one of the following rooms: #mautrix_yunohost:matrix.fdn.fr or #whatsapp:maunium.net
-### Bridging usage
+## Bridging usage
** Note that several WhatsApp and Matrix users can be bridged, each WhatsApp account has its own bot administration room. If they are in a same WhatsApp group, only one matrix room will be created. **
-#### Bridge a WhatsApp user and a Matrix user
+### Bridge a WhatsApp user and a Matrix user
* First your matrix user or server has to be authorized in the bridge configuration (see below)
* Then, invite the bot (default @whatsappbot:yoursynapse.domain)
* The room with the Mautrix-WhatsApp bot is called "administration room".
@@ -44,7 +44,7 @@ Therefore, [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh)
* 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
+### 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)
@@ -53,7 +53,7 @@ Your can also create a portal for an existing Matrix room. **Note that this can
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
+### Relaybot: Bridge a group for several Matrix and several WhatsApp users to chat together
**When upgrading from
* Official admin documentation:
* Upstream app code repository:
* YunoHost documentation for this app:
diff --git a/README_fr.md b/README_fr.md
index d1084e6..4001ff5 100644
--- a/README_fr.md
+++ b/README_fr.md
@@ -3,14 +3,14 @@ N.B.: This README was automatically generated by https://github.com/YunoHost/app
It shall NOT be edited by hand.
-->
-# Matrix WhatsApp bridge pour YunoHost
+# Matrix-WhatsApp bridge pour YunoHost
[](https://dash.yunohost.org/appci/app/mautrix_whatsapp)  
-[](https://install-app.yunohost.org/?app=mautrix_whatsapp)
+[](https://install-app.yunohost.org/?app=mautrix_whatsapp)
*[Read this readme in english.](./README.md)*
-> *Ce package vous permet d'installer Matrix WhatsApp bridge rapidement et simplement sur un serveur YunoHost.
+> *Ce package vous permet d'installer Matrix-WhatsApp bridge rapidement et simplement sur un serveur YunoHost.
Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
## Vue d'ensemble
@@ -24,18 +24,18 @@ C'est pourquoi [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_y
** Attention : sauvegardez et restaurez toujours les deux applications Yunohost matrix_synapse et mautrix_whatsapp en même temps!**
-**Version incluse :** 0.6.0~ynh3
+**Version incluse :** 0.7.0~ynh2
## Avertissements / informations importantes
-### Liste de passerelles publiques
+## Liste de passerelles publiques
* Demandez sur un des salons suivants: #mautrix_yunohost:matrix.fdn.fr or #whatsapp:maunium.net
-### Usages de la passerelle
+## Usages de la passerelle
** Notez que plusieurs comptes WhatsApp et Matrix peuvent être relayés, chaque compte WhatsApp connecté a son propre Salon d'Administration. Si plusieurs utilisateur.ice.s du Robot sont dans un même groupe WhatsApp, seul un Salon Matrix sera créé par la passerelle. **
-#### Relayer TOUTES les conversations entre UN compte WhatsApp et UN compte Matrix
+### Relayer TOUTES les conversations entre UN compte WhatsApp et UN compte Matrix
* Prérequis : votre compte Matrix ou le serveur sur lequel il est hébergé doit être autorisé dans la configuration de la passerelle (voir ci-dessous)
* Invitez le Robot (par défaut @whatsappbot:synapse.votredomaine) à une nouvelle conversation.
* Ce nouveau salon d'administration du Robot Mautrix-WhatsApp est appelé "Administration Room".
@@ -101,6 +101,7 @@ Si vous devez téléverser vos fichiers log quelque-part, soyez avertis qu'ils c
## Documentations et ressources
+* Site officiel de l'app :
* Documentation officielle de l'admin :
* Dépôt de code officiel de l'app :
* Documentation YunoHost pour cette app :
diff --git a/check_process b/check_process
index 60e492a..8e8ca52 100644
--- a/check_process
+++ b/check_process
@@ -1,7 +1,7 @@
;; Default test serie
; pre-install
sudo yunohost tools update apps
- sudo yunohost app install https://github.com/YunoHost-Apps/synapse_ynh/ -a "domain=$domain&server_name=$server_name&is_public=$is_public&jitsi_server=$jitsi_server" --force
+ sudo yunohost app install https://github.com/YunoHost-Apps/synapse_ynh/ -a "domain=$domain&server_name=$server_name&is_free_registration=$is_free_registration&jitsi_server=$jitsi_server" --force
; Manifest
synapsenumber="1"
whatsappbot="whatsappbot"
@@ -17,10 +17,15 @@
setup_private=0
setup_public=0
upgrade=1
+ # 0.3.0
upgrade=1 from_commit=42df5b910927283241e185dcb8a62089adeb9c85
+ # 0.2.4
upgrade=1 from_commit=23cd51919e2b09865256a21214865d798bd843f6
backup_restore=1
multi_instance=1
+;;; Options
+Email=
+Notification=none
;;; Upgrade options
; commit=42df5b910927283241e185dcb8a62089adeb9c85
name=0.3.0
diff --git a/conf/amd64.src b/conf/amd64.src
index 9078b1d..8b57e20 100644
--- a/conf/amd64.src
+++ b/conf/amd64.src
@@ -1,5 +1,5 @@
-SOURCE_URL=https://github.com/mautrix/whatsapp/releases/download/v0.6.0/mautrix-whatsapp-amd64
-SOURCE_SUM=16fb400dfff3ee41c67c90c4c81106dd1b18d83ce120e038e72d2b0f2e0c3654
+SOURCE_URL=https://github.com/mautrix/whatsapp/releases/download/v0.7.0/mautrix-whatsapp-amd64
+SOURCE_SUM=13b43350e3beabcccd5cce51d3562c0eed703b4075674143d13921fa3f9e6400
SOURCE_SUM_PRG=sha256sum
SOURCE_IN_SUBDIR=false
SOURCE_FILENAME=mautrix-whatsapp
diff --git a/conf/arm64.src b/conf/arm64.src
index b3a546c..4119861 100644
--- a/conf/arm64.src
+++ b/conf/arm64.src
@@ -1,5 +1,5 @@
-SOURCE_URL=https://github.com/mautrix/whatsapp/releases/download/v0.6.0/mautrix-whatsapp-arm64
-SOURCE_SUM=3b17adb90a1368e9598c5302c1490f717e86c7d820dbeba20d6404f242edb772
+SOURCE_URL=https://github.com/mautrix/whatsapp/releases/download/v0.7.0/mautrix-whatsapp-arm64
+SOURCE_SUM=90157e29087320de779a285c308e9aca1a0f052a9e84c4d071e2fbdb3a2c6e31
SOURCE_SUM_PRG=sha256sum
SOURCE_IN_SUBDIR=false
SOURCE_FILENAME=mautrix-whatsapp
diff --git a/conf/armhf.src b/conf/armhf.src
index 269d980..d54422d 100644
--- a/conf/armhf.src
+++ b/conf/armhf.src
@@ -1,5 +1,5 @@
-SOURCE_URL=https://github.com/mautrix/whatsapp/releases/download/v0.6.0/mautrix-whatsapp-arm
-SOURCE_SUM=04c6d4d6327048c4d504e0ca349965d1cdcc17ef742eaf6b31148afb3361e02b
+SOURCE_URL=https://github.com/mautrix/whatsapp/releases/download/v0.7.0/mautrix-whatsapp-arm
+SOURCE_SUM=54c0c20d5c6a2997d99cdeb469eebf786ce0593f95582e98da318e178ab364ef
SOURCE_SUM_PRG=sha256sum
SOURCE_IN_SUBDIR=false
SOURCE_FILENAME=mautrix-whatsapp
diff --git a/conf/config.yaml b/conf/config.yaml
index 2e05b11..64d257e 100644
--- a/conf/config.yaml
+++ b/conf/config.yaml
@@ -1,14 +1,13 @@
-# Homeserver details.
+# Homeserver details
homeserver:
# The address that this appservice can use to connect to the homeserver.
- #address: https://example.com
address: https://__DOMAIN__
# The domain of the homeserver (for MXIDs, etc).
- #domain: example.com
domain: __SERVER_NAME__
- # Is the homeserver actually mautrix-asmux?
- asmux: false
+ # What software is the homeserver running?
+ # Standard Matrix homeservers like Synapse, Dendrite and Conduit should just use "standard" here.
+ software: standard
# 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.
@@ -22,12 +21,10 @@ homeserver:
# Changing these values requires regeneration of the registration.
appservice:
# The address that the homeserver can use to connect to this appservice.
- #address: http://localhost:29318
address: http://localhost:__PORT__
# The hostname and port where this appservice should listen.
hostname: 0.0.0.0
- #port: 29318
port: __PORT__
# Database config.
@@ -64,7 +61,7 @@ appservice:
# 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
+ ephemeral_events: true
# Authentication tokens for AS <-> HS communication. Autogenerated; do not modify.
as_token: "This value is generated when generating the registration"
@@ -199,7 +196,7 @@ bridge:
# Should Matrix users leaving groups be bridged to WhatsApp?
bridge_matrix_leave: true
# Should the bridge sync with double puppeting to receive EDUs that aren't normally sent to appservices.
- sync_with_custom_puppets: true
+ sync_with_custom_puppets: false
# 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.
@@ -280,6 +277,9 @@ bridge:
# Should the bridge never send alerts to the bridge management room?
# These are mostly things like the user being logged out.
disable_bridge_alerts: false
+ # Should the bridge stop if the WhatsApp server says another user connected with the same session?
+ # This is only safe on single-user bridges.
+ crash_on_stream_replaced: false
# Should the bridge detect URLs in outgoing messages, ask the homeserver to generate a preview,
# and send it to WhatsApp? URL previews can always be sent using the `com.beeper.linkpreviews`
# key in the event content even if this is disabled.
@@ -323,6 +323,8 @@ bridge:
# 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.
default: false
+ # Whether to use MSC2409/MSC3202 instead of /sync long polling for receiving encryption-related data.
+ appservice: false
# Require encryption, drop any unencrypted messages.
require: false
# Enable key sharing? If enabled, key requests for rooms where users are in will be fulfilled.
@@ -392,7 +394,7 @@ bridge:
# 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__
+ enabled: true
# 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.
@@ -423,4 +425,4 @@ logging:
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: __LOG_LEVEL__
+ print_level: INFO
diff --git a/conf/systemd.service b/conf/systemd.service
index 90371cb..c16a18b 100644
--- a/conf/systemd.service
+++ b/conf/systemd.service
@@ -1,18 +1,18 @@
[Unit]
-Description=Matrix-Whatsapp Bridge
+Description=Matrix Whatsapp Bridge
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__/__APP__.log 2>&1
+WorkingDirectory=__FINALPATH__/
+ExecStart=__FINALPATH__/mautrix-whatsapp -c=__FINALPATH__/config.yaml >> /var/log/__APP__/__APP__.log 2>&1
Restart=always
RestartSec=3
# Optional hardening to improve security
-ReadWritePaths=/opt/yunohost/__APP__
+ReadWritePaths=__FINALPATH__/
NoNewPrivileges=yes
MemoryDenyWriteExecute=true
PrivateDevices=yes
diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md
index 8e82a1b..c64e70e 100644
--- a/doc/DISCLAIMER.md
+++ b/doc/DISCLAIMER.md
@@ -1,11 +1,11 @@
-### List of known public services
+## List of known public services
* Ask on one of the following rooms: #mautrix_yunohost:matrix.fdn.fr or #whatsapp:maunium.net
-### Bridging usage
+## Bridging usage
** Note that several WhatsApp and Matrix users can be bridged, each WhatsApp account has its own bot administration room. If they are in a same WhatsApp group, only one matrix room will be created. **
-#### Bridge a WhatsApp user and a Matrix user
+### Bridge a WhatsApp user and a Matrix user
* First your matrix user or server has to be authorized in the bridge configuration (see below)
* Then, invite the bot (default @whatsappbot:yoursynapse.domain)
* The room with the Mautrix-WhatsApp bot is called "administration room".
@@ -14,7 +14,7 @@
* 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
+### 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)
@@ -23,7 +23,7 @@ Your can also create a portal for an existing Matrix room. **Note that this can
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
+### Relaybot: Bridge a group for several Matrix and several WhatsApp users to chat together
**When upgrading from /dev/null
then
- ynh_script_progression --message="Removing $app service..." --weight=3
+ ynh_script_progression --message="Removing $app service integration..." --weight=3
yunohost service remove $app
fi
@@ -54,13 +47,21 @@ ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config
ynh_remove_systemd_config
+#=================================================
+# REMOVE LOGROTATE CONFIGURATION
+#=================================================
+ynh_script_progression --message="Removing logrotate configuration..." --weight=1
+
+# Remove the app-specific logrotate config
+ynh_remove_logrotate
+
#=================================================
# REMOVE THE POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=4
# Remove a database if it exists, along with the associated user
-ynh_psql_remove_db --db_user=$db_name --db_name=$db_name
+ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP OWNED BY ""$app"";"
ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP OWNED BY ""$bot_synapse_db_user"";"
ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP OWNED BY ""$botname"";"
@@ -69,6 +70,14 @@ ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP USER ""$bot_syn
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 APP MAIN DIR
+#=================================================
+ynh_script_progression --message="Removing app main directory..." --weight=1
+
+# Remove the app directory securely
+ynh_secure_remove --file="$final_path"
+
#=================================================
# REMOVE DEPENDENCIES
#=================================================
@@ -77,32 +86,16 @@ ynh_script_progression --message="Removing dependencies..." --weight=8
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
-#=================================================
-# REMOVE APP MAIN DIR
-#=================================================
-ynh_script_progression --message="Removing app main directory..." --weight=1
-
-# Remove the app directory securely
-ynh_secure_remove --file="$final_path"
-
-#=================================================
-# REMOVE LOGROTATE CONFIGURATION
-#=================================================
-ynh_script_progression --message="Removing logrotate configuration..." --weight=1
-
-# Remove the app-specific logrotate config
-ynh_remove_logrotate
-
#=================================================
# SPECIFIC REMOVE
#=================================================
-ynh_script_progression --message="Removing synapse app service..." --weight=6
+# REMOVE VARIOUS FILES
+#=================================================
+ynh_script_progression --message="Removing various files..." --weight=6
# Remove a directory securely
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"
+/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die --message="Synapse can't restart with the appservice configuration"
# Remove the log files
ynh_secure_remove --file="/var/log/$app"
diff --git a/scripts/restore b/scripts/restore
index 4815fa6..2267b43 100755
--- a/scripts/restore
+++ b/scripts/restore
@@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
-#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
+# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers
#=================================================
ynh_clean_setup () {
- #### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
@@ -24,11 +23,13 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
-ynh_script_progression --message="Loading settings..." --weight=5
+ynh_script_progression --message="Loading installation settings..." --weight=5
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
+db_name=$(ynh_app_setting_get --app=$app --key=db_name)
+db_user=$db_name
domain=$(ynh_app_setting_get --app=$app --key=domain)
server_name=$(ynh_app_setting_get --app=$app --key=server_name)
appserviceid=$(ynh_app_setting_get --app=$app --key=appserviceid)
@@ -40,16 +41,6 @@ botusers=$(ynh_app_setting_get --app=$app --key=botusers)
botadmin=$(ynh_app_setting_get --app=$app --key=botadmin)
previous_mautrix_version=$(ynh_app_setting_get --app=$app --key=mautrix_version)
port=$(ynh_app_setting_get --app=$app --key=port)
-
-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"
bot_synapse_db_user="@$botname:$server_name"
@@ -58,7 +49,8 @@ bot_synapse_db_user="@$botname:$server_name"
#=================================================
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
@@ -67,9 +59,8 @@ test ! -d $final_path || ynh_die --message="There is already a directory: $final
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
-# Create a dedicated user (if not existing) and set home dir to /opt/yunohost/$app so systemd hardening works
-# See more: https://docs.mau.fi/bridges/go/setup.html?bridge=whatsapp#systemd-service
-ynh_system_user_create --username=$app --home_dir=/opt/yunohost/$app
+# Create the dedicated user (if not existing)
+ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE THE APP MAIN DIR
@@ -78,21 +69,18 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
ynh_restore_file --origin_path="$final_path"
-#=================================================
-# RESTORE USER RIGHTS
-#=================================================
-
-# Restore permissions on app files
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
+# Define and install dependencies
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#=================================================
@@ -101,18 +89,17 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=8
ynh_psql_test_if_first_run
-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"
+db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
+ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
+ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
-#=================================================
-# SPECIFIC RESTORATION
#=================================================
# REGISTER SYNAPSE APP-SERVICE
#=================================================
+ynh_script_progression --message="Registering Synapse app-service" --weight=1
$final_path/mautrix-whatsapp -g -c $final_path/config.yaml -r /etc/matrix-$synapse_instance/app-service/$app.yaml
-/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \
- || ynh_die "Synapse can't restart with the appservice configuration"
+/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die "Synapse can't restart with the appservice configuration"
#=================================================
# RESTORE SYSTEMD
@@ -125,24 +112,23 @@ systemctl enable $app.service --quiet
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
+ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
-ynh_use_logrotate --logfile "/var/log/$app/$app.log" --nonappend --specific_user $app/$app
-chmod -R 600 "/var/log/$app"
-chmod 700 "/var/log/$app"
-chown -R $app:$app /var/log/$app
+ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
-yunohost service add $app --description "$app daemon for bridging Whatsapp and Matrix messages" --log "/var/log/$app/$app.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
+# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
# Wait until the synapse user is created
sleep 30
diff --git a/scripts/upgrade b/scripts/upgrade
index 127fa65..5273e41 100755
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -16,42 +16,52 @@ ynh_script_progression --message="Loading installation settings..." --weight=5
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)
appserviceid=$(ynh_app_setting_get --app=$app --key=appserviceid)
botname=$(ynh_app_setting_get --app=$app --key=botname)
-synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
encryption=$(ynh_app_setting_get --app=$app --key=encryption)
-botusers=$(ynh_app_setting_get --app=$app --key=botusers)
botadmin=$(ynh_app_setting_get --app=$app --key=botadmin)
+botusers=$(ynh_app_setting_get --app=$app --key=botusers)
+domain=$(ynh_app_setting_get --app=$app --key=domain)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
-previous_mautrix_version=$(ynh_app_setting_get --app=$app --key=mautrix_version)
-
-#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"
-
+db_name=$(ynh_app_setting_get --app=$app --key=db_name)
+db_user=$db_name
+db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
+port=$(ynh_app_setting_get --app=$app --key=port)
+synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
+server_name=$(ynh_app_setting_get --app=$app --key=server_name)
synapse_db_name="matrix_$synapse_instance"
bot_synapse_db_user="@$botname:$server_name"
#=================================================
# CHECK VERSION
#=================================================
+ynh_script_progression --message="Checking version..." --weight=1
upgrade_type=$(ynh_check_app_version_changed)
+#=================================================
+# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
+#=================================================
+ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=10
+
+# Backup the current version of the app
+ynh_backup_before_upgrade
+ynh_clean_setup () {
+ # Restore it if the upgrade fails
+ ynh_restore_upgradebackup
+}
+# Exit if an error occurs during the execution of the script
+ynh_abort_if_errors
+
+#=================================================
+# STANDARD UPGRADE STEPS
+#=================================================
+# STOP SYSTEMD SERVICE
+#=================================================
+ynh_script_progression --message="Stopping a systemd service..." --weight=1
+
+ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
+
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
@@ -108,36 +118,6 @@ fi
# ynh_app_setting_set --app=$app --key=final_path --value=$final_path
#fi
-#=================================================
-# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
-#=================================================
-ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=10
-
-# Backup the current version of the app
-ynh_backup_before_upgrade
-ynh_clean_setup () {
- # restore it if the upgrade fails
- ynh_restore_upgradebackup
-}
-# Exit if an error occurs during the execution of the script
-ynh_abort_if_errors
-
-#=================================================
-# STANDARD UPGRADE STEPS
-#=================================================
-# STOP SYSTEMD SERVICE
-#=================================================
-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
#=================================================
@@ -146,9 +126,9 @@ ynh_script_progression --message="Making sure dedicated system user exists..." -
# Create a dedicated user (if not existing) and set home dir to /opt/yunohost/$app so systemd hardening works
# See more: https://docs.mau.fi/bridges/go/setup.html?bridge=whatsapp#systemd-service
if ynh_system_user_exists -u "$app"; then
- usermod --home /opt/yunohost/$app $app
+ usermod --home "$final_path" $app
else
- ynh_system_user_create --username=$app --home_dir=/opt/yunohost/$app
+ ynh_system_user_create --username=$app --home_dir="$final_path"
fi
#=================================================
@@ -160,29 +140,45 @@ then
ynh_script_progression --message="Upgrading source files..." --weight=2
# Download, check integrity, uncompress and patch the source from app.src
- ynh_setup_source --dest_dir="$final_path" --source_id=$architecture
- chmod 750 $final_path
- chown $app:$app $final_path
+ ynh_setup_source --dest_dir="$final_path" --source_id=$YNH_ARCH
fi
-#=================================================
-# 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="$final_path/config.yaml"
-ynh_backup_if_checksum_is_different --file="/etc/matrix-$synapse_instance/app-service/$app.yaml"
-
-#=================================================
-# UPDATE CONFIGURATION
-#=================================================
-ynh_script_progression --message="Configuring Mautrix Bridge..." --weight=2
-
-ynh_add_config --template="../conf/config.yaml" --destination="$final_path/config.yaml"
+chmod 750 "$final_path"
chmod -R 750 "$final_path"
chown -R $app:$app "$final_path"
+#=================================================
+# UPGRADE DEPENDENCIES
+#=================================================
+ynh_script_progression --message="Upgrading dependencies..." --weight=100
+
+ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
+
+#=================================================
+# SPECIFIC UPGRADE
+#=================================================
+# UPDATE A CONFIG FILE
+#=================================================
+ynh_script_progression --message="Updating a configuration file..." --weight=2
+
+ynh_add_config --template="../conf/config.yaml" --destination="$final_path/config.yaml"
+
+chmod 400 "$final_path/config.yaml"
+chown $app:$app "$final_path/config.yaml"
+
+#=================================================
+# REGISTER SYNAPSE APP-SERVICE
+#=================================================
+ynh_script_progression --message="Registering Synapse app-service" --weight=1
+
+$final_path/mautrix-whatsapp -g -c $final_path/config.yaml -r /etc/matrix-$synapse_instance/app-service/$app.yaml
+/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die "Synapse can't restart with the appservice configuration"
+
+# Set permissions on app files
+chown -R $app:$app "$final_path"
+ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml"
+ynh_store_file_checksum --file="$final_path/config.yaml"
+
#=================================================
# SETUP SYSTEMD
#=================================================
@@ -191,23 +187,6 @@ 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
#=================================================
@@ -226,14 +205,14 @@ chown -R $app:$app /var/log/$app
#=================================================
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"
+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"
+# Start a systemd service
ynh_systemd_action --service_name=$app --action="start"
#=================================================
diff --git a/sources/extra_files/app/.gitignore b/sources/extra_files/app/.gitignore
deleted file mode 100644
index 783a4ae..0000000
--- a/sources/extra_files/app/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-*~
-*.sw[op]
diff --git a/sources/patches/.gitignore b/sources/patches/.gitignore
deleted file mode 100644
index 783a4ae..0000000
--- a/sources/patches/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-*~
-*.sw[op]