mirror of
https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh.git
synced 2024-09-03 19:46:01 +02:00
Merge branch 'testing' into ci-auto-update-v0.7.0
This commit is contained in:
commit
21512d5bc4
16 changed files with 208 additions and 267 deletions
26
README.md
26
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
|
||||
|
@ -28,14 +28,14 @@ Therefore, [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh)
|
|||
|
||||
## 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 <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:
|
||||
|
@ -65,14 +65,16 @@ To be able to bridge not only your logged in Matrix account but also Matrix frie
|
|||
* 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
|
||||
## Configuration of the bridge
|
||||
|
||||
The bridge is [roughly configured at installation](https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh/blob/master/conf/config.yaml), e.g. allowed admin and user of the bot. Finer configuration can be done by modifying the
|
||||
following configuration file with SSH:
|
||||
```/opt/yunohost/mautrix_whatsapp/config.yaml```
|
||||
and then restarting the mautrix_whatsapp service.
|
||||
|
||||
### Multi-users support
|
||||
## YunoHost specific features
|
||||
|
||||
#### Multi-user support
|
||||
|
||||
* Bot users are not related to Yunohost users. Any Matrix account or Synapse server autorized in the configuration of the bridge can invite/use the bot.
|
||||
* The WhatsApp bot is a local Matrix-Synapse user, but accessible through federation (synapse public or private).
|
||||
|
@ -80,7 +82,7 @@ and then restarting the mautrix_whatsapp service.
|
|||
* If several bot users are in a same WhatsApp group, only one Matrix room will be created by the bridge.
|
||||
* See https://github.com/YunoHost-Apps/synapse_ynh#multi-users-support
|
||||
|
||||
### Multi-instance support
|
||||
#### Multi-instance support
|
||||
|
||||
* Multi-instance installation should work. Several bridge instances could be installed for one Matrix-Synapse instance so that one Matrix user can bridge several WhatsApp accounts.
|
||||
* Several bridge instances could be installed for each Matrix-Synapse instance to benefit from it. But one bridge can be used by users from several Matrix-Synapse instances.
|
||||
|
@ -89,7 +91,7 @@ and then restarting the mautrix_whatsapp service.
|
|||
|
||||
ARM, ARM64, AMD64
|
||||
|
||||
### Limitations
|
||||
## Limitations
|
||||
|
||||
* Audio/Video calls are not bridged yet.
|
||||
* If WhatsApp loses connection, e.g. the phone is set in flight mode or push notifications are deactivated, the bot has sometimes to be restarted manually by sending a reconnnect message in the matrix administration room.
|
||||
|
|
12
README_fr.md
12
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
|
||||
|
@ -28,14 +28,14 @@ C'est pourquoi [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_y
|
|||
|
||||
## 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".
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
# 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?
|
||||
|
@ -22,12 +20,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.
|
||||
|
@ -392,7 +388,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 +419,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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <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:
|
||||
|
@ -35,14 +35,16 @@ To be able to bridge not only your logged in Matrix account but also Matrix frie
|
|||
* 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
|
||||
## Configuration of the bridge
|
||||
|
||||
The bridge is [roughly configured at installation](https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh/blob/master/conf/config.yaml), e.g. allowed admin and user of the bot. Finer configuration can be done by modifying the
|
||||
following configuration file with SSH:
|
||||
```/opt/yunohost/mautrix_whatsapp/config.yaml```
|
||||
and then restarting the mautrix_whatsapp service.
|
||||
|
||||
### Multi-users support
|
||||
## YunoHost specific features
|
||||
|
||||
#### Multi-user support
|
||||
|
||||
* Bot users are not related to Yunohost users. Any Matrix account or Synapse server autorized in the configuration of the bridge can invite/use the bot.
|
||||
* The WhatsApp bot is a local Matrix-Synapse user, but accessible through federation (synapse public or private).
|
||||
|
@ -50,7 +52,7 @@ and then restarting the mautrix_whatsapp service.
|
|||
* If several bot users are in a same WhatsApp group, only one Matrix room will be created by the bridge.
|
||||
* See https://github.com/YunoHost-Apps/synapse_ynh#multi-users-support
|
||||
|
||||
### Multi-instance support
|
||||
#### Multi-instance support
|
||||
|
||||
* Multi-instance installation should work. Several bridge instances could be installed for one Matrix-Synapse instance so that one Matrix user can bridge several WhatsApp accounts.
|
||||
* Several bridge instances could be installed for each Matrix-Synapse instance to benefit from it. But one bridge can be used by users from several Matrix-Synapse instances.
|
||||
|
@ -59,7 +61,7 @@ and then restarting the mautrix_whatsapp service.
|
|||
|
||||
ARM, ARM64, AMD64
|
||||
|
||||
### Limitations
|
||||
## Limitations
|
||||
|
||||
* Audio/Video calls are not bridged yet.
|
||||
* If WhatsApp loses connection, e.g. the phone is set in flight mode or push notifications are deactivated, the bot has sometimes to be restarted manually by sending a reconnnect message in the matrix administration room.
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
### 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".
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "Matrix WhatsApp bridge",
|
||||
"name": "Matrix-WhatsApp bridge",
|
||||
"id": "mautrix_whatsapp",
|
||||
"packaging_format": 1,
|
||||
"description": {
|
||||
|
@ -11,7 +11,6 @@
|
|||
"upstream": {
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"website": "https://maunium.net/go/mautrix-whatsapp/",
|
||||
"demo": "",
|
||||
"admindoc": "https://docs.mau.fi/bridges/go/whatsapp/index.html",
|
||||
"code": "https://github.com/mautrix/whatsapp"
|
||||
},
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
# dependencies used by the app
|
||||
# dependencies used by the app (must be on a single line)
|
||||
pkg_dependencies="g++ postgresql ffmpeg"
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -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,7 +23,7 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
@ -48,7 +47,7 @@ ynh_backup --src_path="$final_path"
|
|||
# BACKUP LOGROTATE
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/var/log/$app"
|
||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
|
|
|
@ -14,7 +14,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,16 +23,20 @@ ynh_abort_if_errors
|
|||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
|
||||
synapsenumber=$YNH_APP_ARG_SYNAPSENUMBER
|
||||
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
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
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
|
||||
|
@ -43,10 +46,7 @@ else
|
|||
fi
|
||||
server_name=$(ynh_app_setting_get --app $synapse_instance --key server_name)
|
||||
domain=$(ynh_app_setting_get --app $synapse_instance --key domain)
|
||||
|
||||
mautrix_version=$(ynh_app_upstream_version)
|
||||
architecture=$YNH_ARCH
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
synapse_db_name="matrix_$synapse_instance"
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
|
@ -55,34 +55,20 @@ ynh_script_progression --message="Validating installation parameters..." --weigh
|
|||
|
||||
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_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=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
|
||||
ynh_app_setting_set --app=$app --key=botusers --value=$botusers
|
||||
ynh_app_setting_set --app=$app --key=synapse_instance --value=$synapse_instance
|
||||
ynh_app_setting_set --app=$app --key=server_name --value=$server_name
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
|
@ -98,7 +84,7 @@ ynh_app_setting_set --app=$app --key=port --value=$port
|
|||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=10
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=97
|
||||
|
||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
|
@ -107,9 +93,8 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
|||
#=================================================
|
||||
ynh_script_progression --message="Configuring system user..." --weight=1
|
||||
|
||||
# Create a system user 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 a system user
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# CREATE A POSTGRESQL DATABASE
|
||||
|
@ -117,31 +102,48 @@ ynh_system_user_create --username=$app --home_dir=/opt/yunohost/$app
|
|||
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=3
|
||||
|
||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
db_user=$db_name
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
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
|
||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --weight=5
|
||||
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path" --source_id=$architecture
|
||||
ynh_setup_source --dest_dir="$final_path" --source_id=$YNH_ARCH
|
||||
|
||||
chmod 750 "$final_path"
|
||||
chown $app:$app "$final_path"
|
||||
chmod -R 750 "$final_path"
|
||||
chown -R $app:$app "$final_path"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring Mautrix Bridge..." --weight=2
|
||||
ynh_script_progression --message="Adding a configuration file..." --weight=2
|
||||
|
||||
ynh_add_config --template="../conf/config.yaml" --destination="$final_path/config.yaml"
|
||||
chmod -R 750 "$final_path"
|
||||
|
||||
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 --message="Synapse can't restart with the appservice configuration"
|
||||
|
||||
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
|
||||
|
@ -151,24 +153,6 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=5
|
|||
# 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
|
||||
chown -R $app:$app "$final_path"
|
||||
|
||||
/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
|
||||
#=================================================
|
||||
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml"
|
||||
ynh_store_file_checksum --file="$final_path/config.yaml"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
@ -187,7 +171,7 @@ 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
|
||||
|
|
|
@ -16,32 +16,25 @@ 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)
|
||||
synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
|
||||
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)
|
||||
synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
|
||||
server_name=$(ynh_app_setting_get --app=$app --key=server_name)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# SET CONSTANTS
|
||||
#=================================================
|
||||
|
||||
synapse_db_name="matrix_$synapse_instance"
|
||||
bot_synapse_db_user="@""$botname"":""$server_name"
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
# REMOVE SERVICE FROM ADMIN PANEL
|
||||
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
||||
#=================================================
|
||||
|
||||
# Remove a service from the admin panel, added by `yunohost service add`
|
||||
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||
if ynh_exec_warn_less yunohost service status $app >/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
|
||||
|
||||
|
@ -53,13 +46,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"";"
|
||||
|
@ -68,6 +69,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
|
||||
#=================================================
|
||||
|
@ -76,32 +85,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"
|
||||
|
|
|
@ -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)
|
||||
botname=$(ynh_app_setting_get --app=$app --key=botname)
|
||||
|
@ -39,16 +40,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"
|
||||
|
||||
|
@ -57,7 +48,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
|
||||
|
@ -66,9 +58,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
|
||||
|
@ -77,21 +68,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
|
||||
|
||||
#=================================================
|
||||
|
@ -100,18 +88,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
|
||||
|
@ -124,24 +111,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
|
||||
|
|
161
scripts/upgrade
161
scripts/upgrade
|
@ -16,41 +16,51 @@ 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)
|
||||
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
|
||||
#=================================================
|
||||
|
@ -99,36 +109,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
|
||||
#=================================================
|
||||
|
@ -137,9 +117,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
|
||||
|
||||
#=================================================
|
||||
|
@ -151,29 +131,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
|
||||
#=================================================
|
||||
|
@ -182,23 +178,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
|
||||
#=================================================
|
||||
|
@ -217,14 +196,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"
|
||||
|
||||
#=================================================
|
||||
|
|
2
sources/extra_files/app/.gitignore
vendored
2
sources/extra_files/app/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
*~
|
||||
*.sw[op]
|
2
sources/patches/.gitignore
vendored
2
sources/patches/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
*~
|
||||
*.sw[op]
|
Loading…
Add table
Reference in a new issue