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

Packaging v2 WIP

This commit is contained in:
Dante 2023-06-04 21:30:13 +01:00
parent d0fad3f3b3
commit f2f21b8ff0
14 changed files with 181 additions and 433 deletions

View file

@ -1,6 +0,0 @@
SOURCE_URL=https://github.com/mautrix/whatsapp/releases/download/v0.8.5/mautrix-whatsapp-amd64
SOURCE_SUM=2989419b6c8ce870189359a44a1642a22e6cc87d6344123622fa2d59d073a339
SOURCE_SUM_PRG=sha256sum
SOURCE_IN_SUBDIR=false
SOURCE_FILENAME=mautrix-whatsapp
SOURCE_EXTRACT=false

View file

@ -1,6 +0,0 @@
SOURCE_URL=https://github.com/mautrix/whatsapp/releases/download/v0.8.5/mautrix-whatsapp-arm64
SOURCE_SUM=e9c34620f5748bac34f4d15d9e9088ecf8676288edc9460bf6245688eafd6367
SOURCE_SUM_PRG=sha256sum
SOURCE_IN_SUBDIR=false
SOURCE_FILENAME=mautrix-whatsapp
SOURCE_EXTRACT=false

View file

@ -1,6 +0,0 @@
SOURCE_URL=https://github.com/mautrix/whatsapp/releases/download/v0.8.5/mautrix-whatsapp-arm
SOURCE_SUM=6f664454fccabe023c6d7eb8ad85ed80ba7c5691605e16977cfc67ffed1a252a
SOURCE_SUM_PRG=sha256sum
SOURCE_IN_SUBDIR=false
SOURCE_FILENAME=mautrix-whatsapp
SOURCE_EXTRACT=false

View file

@ -6,13 +6,13 @@ After=matrix-synapse.service
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
ExecStart=__FINALPATH__/mautrix-whatsapp -c=__FINALPATH__/config.yaml ExecStart=__INSTALL_DIR__/mautrix-whatsapp -c=__INSTALL_DIR__/config.yaml
Restart=always Restart=always
RestartSec=3 RestartSec=3
# Optional hardening to improve security # Optional hardening to improve security
ReadWritePaths=__FINALPATH__/ /var/log/__APP__ ReadWritePaths=__INSTALL_DIR__/ /var/log/__APP__
NoNewPrivileges=yes NoNewPrivileges=yes
MemoryDenyWriteExecute=true MemoryDenyWriteExecute=true
PrivateDevices=yes PrivateDevices=yes

View file

@ -42,7 +42,7 @@ services = ["__APP__"]
yes = "true" yes = "true"
no = "false" no = "false"
help = "If allowed, '!wa set-relay' can be used to turn any Bridge User into a RelayBot for that chat. This allows people to talk on WhatsApp without an own account." help = "If allowed, '!wa set-relay' can be used to turn any Bridge User into a RelayBot for that chat. This allows people to talk on WhatsApp without an own account."
bind = "relay>enabled:__FINALPATH__/config.yaml" bind = "relay>enabled:__INSTALL_DIR__/config.yaml"
[main.bridge.admin_only] [main.bridge.admin_only]
ask = "Should only Bridge Admins be allowed to set themselves as Relay Users?" ask = "Should only Bridge Admins be allowed to set themselves as Relay Users?"
@ -50,7 +50,7 @@ services = ["__APP__"]
yes = "true" yes = "true"
no = "false" no = "false"
help = "See User management -> Admins" help = "See User management -> Admins"
bind = ":__FINALPATH__/config.yaml" bind = ":__INSTALL_DIR__/config.yaml"
visible = "enable_relaybot" visible = "enable_relaybot"
[main.bot] [main.bot]
@ -60,19 +60,19 @@ services = ["__APP__"]
ask = "Username of the AppService Bot" ask = "Username of the AppService Bot"
type = "string" type = "string"
help = "Sets bot username. Please keep in mind that the bot admin room for previous bot username will stop working so you may need to create a new one using the new username" help = "Sets bot username. Please keep in mind that the bot admin room for previous bot username will stop working so you may need to create a new one using the new username"
bind = "bot>username:__FINALPATH__/config.yaml" bind = "bot>username:__INSTALL_DIR__/config.yaml"
[main.bot.displayname] [main.bot.displayname]
ask = "Display name for Bot" ask = "Display name for Bot"
type = "string" type = "string"
help = "Set to 'remove' to remove display name, leave empty to set default 'WhatsApp bridge bot'" help = "Set to 'remove' to remove display name, leave empty to set default 'WhatsApp bridge bot'"
bind = ":__FINALPATH__/config.yaml" bind = ":__INSTALL_DIR__/config.yaml"
[main.bot.avatar] [main.bot.avatar]
ask = "Avatar for Bot" ask = "Avatar for Bot"
type = "string" type = "string"
help = "Should be in format 'mxc://server_name/NeXNQarUbrlYBiPCpprYsRqr', see README for tutorial. Set to 'remove' to remove avatar, leave empty to use standard WhatsApp logo." help = "Should be in format 'mxc://server_name/NeXNQarUbrlYBiPCpprYsRqr', see README for tutorial. Set to 'remove' to remove avatar, leave empty to use standard WhatsApp logo."
bind = ":__FINALPATH__/config.yaml" bind = ":__INSTALL_DIR__/config.yaml"
[privacy] [privacy]
name = "Privacy" name = "Privacy"
@ -95,7 +95,7 @@ services = ["__APP__"]
yes = "true" yes = "true"
no = "false" no = "false"
help = "Enable so-called End-to-Bridge (e2b) Encryption. For the Bridge to work in group chat Rooms with End-to-End Encryption (e2ee) enabled." help = "Enable so-called End-to-Bridge (e2b) Encryption. For the Bridge to work in group chat Rooms with End-to-End Encryption (e2ee) enabled."
bind = "encryption>allow:__FINALPATH__/config.yaml" bind = "encryption>allow:__INSTALL_DIR__/config.yaml"
[privacy.portal_rooms.encryption_default] [privacy.portal_rooms.encryption_default]
ask = "Force-enable Encryption in all Portal Rooms the Bridge creates?" ask = "Force-enable Encryption in all Portal Rooms the Bridge creates?"
@ -103,7 +103,7 @@ services = ["__APP__"]
yes = "true" yes = "true"
no = "false" no = "false"
help = "This will cause the Bridge Bot to be in private chats for the Encryption to work properly." help = "This will cause the Bridge Bot to be in private chats for the Encryption to work properly."
bind = "encryption>default:__FINALPATH__/config.yaml" bind = "encryption>default:__INSTALL_DIR__/config.yaml"
visible = "encryption" visible = "encryption"
[privacy.portal_rooms.encryption_require] [privacy.portal_rooms.encryption_require]
@ -112,7 +112,7 @@ services = ["__APP__"]
yes = "true" yes = "true"
no = "false" no = "false"
help = "Require encryption, drop any unencrypted messages." help = "Require encryption, drop any unencrypted messages."
bind = "encryption>require:__FINALPATH__/config.yaml" bind = "encryption>require:__INSTALL_DIR__/config.yaml"
visible = "encryption" visible = "encryption"
[privacy.config] [privacy.config]
@ -124,7 +124,7 @@ services = ["__APP__"]
yes = "true" yes = "true"
no = "false" no = "false"
help = "Should the bridge send a read Receipt from the bridge bot when a message has been sent to WhatsApp?" help = "Should the bridge send a read Receipt from the bridge bot when a message has been sent to WhatsApp?"
bind = ":__FINALPATH__/config.yaml" bind = ":__INSTALL_DIR__/config.yaml"
[privacy.config.send_presence_on_typing] [privacy.config.send_presence_on_typing]
ask = "Send Presence on typing?" ask = "Send Presence on typing?"
@ -132,7 +132,7 @@ services = ["__APP__"]
yes = "true" yes = "true"
no = "false" no = "false"
help = "Send the Presence as 'available' to WhatsApp when Users start typing on a Portal." help = "Send the Presence as 'available' to WhatsApp when Users start typing on a Portal."
bind = ":__FINALPATH__/config.yaml" bind = ":__INSTALL_DIR__/config.yaml"
[privacy.config.url_previews] [privacy.config.url_previews]
ask = "Enable URL Preview?" ask = "Enable URL Preview?"
@ -140,7 +140,7 @@ services = ["__APP__"]
yes = "true" yes = "true"
no = "false" no = "false"
help = "Should the Bridge detect URLs in outgoing messages, ask the HomeServer to generate a Preview, and send it to WhatsApp?" help = "Should the Bridge detect URLs in outgoing messages, ask the HomeServer to generate a Preview, and send it to WhatsApp?"
bind = ":__FINALPATH__/config.yaml" bind = ":__INSTALL_DIR__/config.yaml"
[advanced] [advanced]
name = "Advanced Settings" name = "Advanced Settings"
@ -160,19 +160,19 @@ services = ["__APP__"]
ask = "Localpart template of MXIDs for WhatsApp users" ask = "Localpart template of MXIDs for WhatsApp users"
type = "string" type = "string"
help = "Defaults to 'whatsapp_{{.}}'. '{{.}}' is replaced with the phone number 'msidsn' of the WhatsApp user." help = "Defaults to 'whatsapp_{{.}}'. '{{.}}' is replaced with the phone number 'msidsn' of the WhatsApp user."
bind = ":__FINALPATH__/config.yaml" bind = ":__INSTALL_DIR__/config.yaml"
[advanced.whatsapp.os_name] [advanced.whatsapp.os_name]
ask = "Device name in the 'WhatsApp Web' section of the smartphone app" ask = "Device name in the 'WhatsApp Web' section of the smartphone app"
type = "string" type = "string"
bind = ":__FINALPATH__/config.yaml" bind = ":__INSTALL_DIR__/config.yaml"
[advanced.whatsapp.browser_name] [advanced.whatsapp.browser_name]
ask = "Browser name that determines the logo shown in the smartphone app" ask = "Browser name that determines the logo shown in the smartphone app"
type = "select" type = "select"
choices = ["unknown", "chrome", "firefox", "ie", "opera", "safari", "edge", "desktop", "ipad", "android_tablet", "ohana", "aloha", "catalina", "tcl_tv"] choices = ["unknown", "chrome", "firefox", "ie", "opera", "safari", "edge", "desktop", "ipad", "android_tablet", "ohana", "aloha", "catalina", "tcl_tv"]
help = "Must be 'unknown' for a generic icon or a valid browser name if you want a specific logo." help = "Must be 'unknown' for a generic icon or a valid browser name if you want a specific logo."
bind = ":__FINALPATH__/config.yaml" bind = ":__INSTALL_DIR__/config.yaml"
[advanced.appservice] [advanced.appservice]
name = "HomeServer Application Service" name = "HomeServer Application Service"
@ -183,7 +183,7 @@ services = ["__APP__"]
yes = "true" yes = "true"
no = "false" no = "false"
help = "Enable only if HomeServer supports https://github.com/matrix-org/matrix-spec-proposals/pull/2246?" help = "Enable only if HomeServer supports https://github.com/matrix-org/matrix-spec-proposals/pull/2246?"
bind = ":__FINALPATH__/config.yaml" bind = ":__INSTALL_DIR__/config.yaml"
[advanced.appservice.ephemeral_events] [advanced.appservice.ephemeral_events]
ask = "Receive Ephemeral Events via AppService transactions?" ask = "Receive Ephemeral Events via AppService transactions?"
@ -191,14 +191,14 @@ services = ["__APP__"]
yes = "true" yes = "true"
no = "false" no = "false"
help = "Enable only if HomeServer supports MSC2409 (i.e. Synapse 1.22+). If enabled, you should disable bridge -> 'sync_with_custom_puppets'." help = "Enable only if HomeServer supports MSC2409 (i.e. Synapse 1.22+). If enabled, you should disable bridge -> 'sync_with_custom_puppets'."
bind = ":__FINALPATH__/config.yaml" bind = ":__INSTALL_DIR__/config.yaml"
[advanced.appservice.print_level] [advanced.appservice.min_level]
ask = "Logging print level for Standard Output" ask = "Logging print level for Standard Output"
type = "select" type = "select"
choices = ["debug", "info", "warn", "error", "fatal"] choices = ["debug", "info", "warn", "error", "fatal"]
help = "Minimum severity for log messages printed to stdout/stderr. This doesn't affect the log file." help = "Minimum severity for log messages printed to stdout/stderr. This doesn't affect the log file."
bind = ":__FINALPATH__/config.yaml" bind = ":__INSTALL_DIR__/config.yaml"
[advanced.metrics] [advanced.metrics]
name = "Prometheus Metrics" name = "Prometheus Metrics"
@ -208,12 +208,12 @@ services = ["__APP__"]
type = "boolean" type = "boolean"
yes = "true" yes = "true"
no = "false" no = "false"
bind = "metrics>enabled:__FINALPATH__/config.yaml" bind = "metrics>enabled:__INSTALL_DIR__/config.yaml"
[advanced.metrics.listen_port] [advanced.metrics.listen_port]
ask = "IP and Port for the Metrics listener?" ask = "IP and Port for the Metrics listener?"
type = "string" type = "string"
help = "Defaults to: '127.0.0.1:8001'. The path is always /metrics" help = "Defaults to: '127.0.0.1:8001'. The path is always /metrics"
bind = "metrics>listen:__FINALPATH__/config.yaml" bind = "metrics>listen:__INSTALL_DIR__/config.yaml"
visible = "enable_metrics" visible = "enable_metrics"

View file

@ -1,114 +0,0 @@
{
"name": "Matrix-WhatsApp bridge",
"id": "mautrix_whatsapp",
"packaging_format": 1,
"description": {
"en": "Matrix / Synapse puppeting bridge for WhatsApp",
"fr": "Passerelle Matrix / Synapse pour WhatsApp"
},
"version": "0.8.5~ynh1",
"url": "https://github.com/mautrix/whatsapp",
"upstream": {
"license": "AGPL-3.0-or-later",
"website": "https://maunium.net/go/mautrix-whatsapp/",
"admindoc": "https://docs.mau.fi/bridges/go/whatsapp/index.html",
"code": "https://github.com/mautrix/whatsapp"
},
"license": "AGPL-3.0-or-later",
"maintainer": {
"name": "thardev",
"email": "",
"url": "https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh"
},
"requirements": {
"yunohost": ">= 4.3.0"
},
"multi_instance": true,
"services": [
"postgresql"
],
"arguments": {
"install": [
{
"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."
},
"example": "2 (for instance synapse__2)",
"help": {
"en": "If you installed Synapse only once time, then leave default value 1.",
"fr": "Si vous n'avez installé qu'une fois Synapse, gardez la valeur par défaut 1."
},
"default": "1"
},
{
"name": "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"
},
"example": "whatsappbot",
"help": {
"en": "A system user will be created. Invite @whatsappbot:localsynapse.servername from an authorized Matrix account to start bridging.\nGive 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.\nDonner le nom du serveur Matrix, pas le domaine/URL complet."
},
"default": "whatsappbot"
},
{
"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 ?"
},
"help": {
"en": "If true, the bot can group WhatsApp chats in a Matrix space.\nNot 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.\nPas nécessaire si vous avez réglé Synapse pour qu'il autorise les non-admin à créer des communautés."
},
"default": true
},
{
"name": "encryption",
"type": "boolean",
"ask": {
"en": "Enable end-to-bridge encryption?",
"fr": "Activer le chiffrement entre Synapse et le bridge ?"
},
"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",
"type": "string",
"ask": {
"en": "Choose the Matrix account administrator of the WhatsApp bot",
"fr": "Choisissez le compte Matrix administrateur du robot WhatsApp"
},
"example": "@johndoe:localsynapse.servername or @johndoe:matrix.org",
"help": {
"en": "The administrator does not need to be a local Synapse account. Valid formats are @johndoe:localsynapse.servername or @johndoe:matrix.org",
"fr": "L'administrateur peut ne pas être un compte local Synapse. Les formats valables sont @johndoe:localsynapse.servername or @johndoe:matrix.org"
}
},
{
"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 la passerelle WhatsApp."
},
"example": "@johndoe:server.name or server.name or *",
"help": {
"en": "A remote or local user (@johndoe:server.name),the local server (server.name), a remote server (matrix.org), or all remote/local servers (*) can be authorized.\nGive the Matrix server_name, not the full domain/URL.\nIt is also possible to specify multiple values by separating them with comma. Example: @johndoe:server.name,domain.tld,matrix.org",
"fr": "Un compte local ou distant (@johndoe:server.name), le serveur local (server.name), un serveur distant (matrix.org), ou tous les serveurs remote/local (*).\nDonner le nom du serveur Matrix, pas le domaine/URL complet\nIl est également possible de spécifier plusieurs valeurs en les séparant par une virgule. Exemple : @johndoe:server.name,domain.tld,matrix.org"
}
}
]
}
}

110
manifest.toml Normal file
View file

@ -0,0 +1,110 @@
packaging_format = 2
id = "mautrix_whatsapp"
name = "Matrix-WhatsApp bridge"
description.en = "Matrix / Synapse puppeting bridge for WhatsApp"
description.fr = "Passerelle Matrix / Synapse pour WhatsApp"
version = "0.8.5~ynh1"
maintainers = ["thardev"]
[upstream]
license = "AGPL-3.0-or-later"
website = "https://maunium.net/go/mautrix-whatsapp/"
code = "https://github.com/mautrix/whatsapp"
admindoc = "https://docs.mau.fi/bridges/go/whatsapp/index.html"
[integration]
yunohost = ">= 11.1"
architectures = ["amd64", "arm64", "armhf"]
multi_instance = true
ldap = false
sso = false
disk = "100M"
ram.build = "1M"
ram.runtime = "1M"
[install]
[install.synapse_instance]
ask.en = "Choose the local Synapse instance to communicate with mautrix_whatsapp."
ask.fr = "Choisissez l'instance Synapse qui doit communiquer avec mautrix_whatsapp."
type = "app"
pattern.regexp = "synapse(__)*[0-9]*"
pattern.error = "Invalid app selected. Please select a Synapse instance."
help.en = "Usually the Synapse instances contain a number after it is installed more than one time. E.g. synapse__1 will be the second instance."
help.fr = "En général, les instances de Synapse contiennent un numéro après avoir été installées plus d'une fois. Par exemple, synapse__1 sera la deuxième instance."
[install.botname]
ask.en = "Choose a local Synapse user name for the WhatsApp bot"
ask.fr = "Choisissez un nom d'utilisateur Synapse local pour le robot WhatsApp"
type = "string"
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."
help.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"
[install.bot_synapse_adm]
ask.en = "Give the WhatsApp bot administrator rights to the Synapse instance?"
ask.fr = "Donner au robot WhatsApp des droits administrateur à l'instance Synapse ?"
type = "boolean"
help.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."
help.fr = "Si true, le robot groupera les conversations WhatsApp dans une communauté Matrix.Pas nécessaire si vous avez réglé Synapse pour qu'il autorise les non-admin à créer des communautés."
default = true
[install.encryption]
ask.en = "Enable end-to-bridge encryption?"
ask.fr = "Activer le chiffrement entre Synapse et le bridge ?"
type = "boolean"
help.en = "Only activate if you know the prerequisites and constraints related to E2B."
help.fr = "N'activer que si vous connaissez les prérequis et constraintes liées à E2B."
default = true
[install.botadmin]
ask.en = "Choose the Matrix account administrator of the WhatsApp bot"
ask.fr = "Choisissez le compte Matrix administrateur du robot WhatsApp"
type = "string"
example = "@johndoe:localsynapse.servername or @johndoe:matrix.org"
help.en = "The administrator does not need to be a local Synapse account. Valid formats are @johndoe:localsynapse.servername or @johndoe:matrix.org"
help.fr = "L'administrateur peut ne pas être un compte local Synapse. Les formats valables sont @johndoe:localsynapse.servername or @johndoe:matrix.org"
[install.botusers]
ask.en = "Choose Matrix user(s) authorized to bridge with the WhatsApp bot."
ask.fr = "Choisissez le/les compte(s) Matrix autorisés à utiliser la passerelle WhatsApp."
type = "string"
example = "@johndoe:server.name or server.name or *"
help.en = """
A remote or local user (@johndoe:server.name),the local server (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.
It is also possible to specify multiple values by separating them with comma. Example: @johndoe:server.name,domain.tld,matrix.org"""
help.fr = """Un compte local ou distant (@johndoe:server.name), le serveur local (server.name), un serveur distant (matrix.org), ou tous les serveurs remote/local (*).
Donner le nom du serveur Matrix, pas le domaine/URL complet.
Il est également possible de spécifier plusieurs valeurs en les séparant par une virgule. Exemple : @johndoe:server.name,domain.tld,matrix.org"""
[resources]
[resources.apt]
packages = "g++, postgresql, ffmpeg"
[resources.database]
type = "postgresql"
[resources.system_user]
home = "/opt/yunohost/__APP__"
[resources.install_dir]
dir = "/opt/yunohost/__APP__"
[resources.ports]
main.default = 8449
[resources.sources]
[resources.sources.main]
in_subdir = false
extract = false
rename = "mautrix-whatsapp"
amd64.url = "https://github.com/mautrix/whatsapp/releases/download/v0.8.5/mautrix-whatsapp-amd64"
amd64.sha256 = "2989419b6c8ce870189359a44a1642a22e6cc87d6344123622fa2d59d073a339"
arm64.url = "https://github.com/mautrix/whatsapp/releases/download/v0.8.5/mautrix-whatsapp-arm64"
arm64.sha256 = "e9c34620f5748bac34f4d15d9e9088ecf8676288edc9460bf6245688eafd6367"
armhf.url = "https://github.com/mautrix/whatsapp/releases/download/v0.8.5/mautrix-whatsapp-arm"
armhf.sha256 = "6f664454fccabe023c6d7eb8ad85ed80ba7c5691605e16977cfc67ffed1a252a"

View file

@ -1,12 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# COMMON VARIABLES
#=================================================
# dependencies used by the app (must be on a single line)
pkg_dependencies="g++ postgresql ffmpeg"
#================================================= #=================================================
# CONFIG PANEL SETTERS # CONFIG PANEL SETTERS
#================================================= #=================================================
@ -22,24 +15,24 @@ apply_permissions() {
then then
#ynh_systemd_action --service_name="$app" --action=stop #ynh_systemd_action --service_name="$app" --action=stop
# Get all entries between "permissions:" and "relay:" keys, remove the role part, remove commented parts, format it with newlines and clean whitespaces and double quotes. # Get all entries between "permissions:" and "relay:" keys, remove the role part, remove commented parts, format it with newlines and clean whitespaces and double quotes.
allDefinedEntries=$(awk '/permissions:/{flag=1; next} /relay:/{flag=0} flag' "$final_path/config.yaml" | sed "/: $role/d" | sed -r 's/: (admin|user|relay)//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr ',' '\n' ) allDefinedEntries=$(awk '/permissions:/{flag=1; next} /relay:/{flag=0} flag' "$install_dir/config.yaml" | sed "/: $role/d" | sed -r 's/: (admin|user|relay)//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr ',' '\n' )
# Delete everything from the corresponding role to insert the new defined values. This way we also handle deletion of users. # Delete everything from the corresponding role to insert the new defined values. This way we also handle deletion of users.
sed -i "/permissions:/,/relay:/{/: $role/d;}" "$final_path/config.yaml" sed -i "/permissions:/,/relay:/{/: $role/d;}" "$install_dir/config.yaml"
# Ensure that entries with value surrounded with quotes are deleted too. E.g. "users". # Ensure that entries with value surrounded with quotes are deleted too. E.g. "users".
sed -i "/permissions:/,/relay:/{/: \"$role\"/d;}" "$final_path/config.yaml" sed -i "/permissions:/,/relay:/{/: \"$role\"/d;}" "$install_dir/config.yaml"
for user in "${usersArray[@]}" for user in "${usersArray[@]}"
do do
if grep -q -x "${user}" <<< "$allDefinedEntries" if grep -q -x "${user}" <<< "$allDefinedEntries"
then then
ynh_print_info "User $user already defined in another role." ynh_print_info "User $user already defined in another role."
else else
sed -i "/permissions:/a \ \\\"$user\": $role" "$final_path/config.yaml" # Whitespaces are needed so that the file can be correctly parsed sed -i "/permissions:/a \ \\\"$user\": $role" "$install_dir/config.yaml" # Whitespaces are needed so that the file can be correctly parsed
fi fi
done done
fi fi
set +o noglob set +o noglob
ynh_print_info "Users with role $role added in $final_path/config.yaml" ynh_print_info "Users with role $role added in $install_dir/config.yaml"
} }
@ -48,19 +41,19 @@ set__listuser() {
role="user" role="user"
ynh_app_setting_set --app=$app --key=listuser --value="$listuser" ynh_app_setting_set --app=$app --key=listuser --value="$listuser"
apply_permissions apply_permissions
ynh_store_file_checksum --file="$final_path/config.yaml" ynh_store_file_checksum --file="$install_dir/config.yaml"
} }
set__listrelay() { set__listrelay() {
role="relay" role="relay"
ynh_app_setting_set --app=$app --key=listrelay --value="$listrelay" ynh_app_setting_set --app=$app --key=listrelay --value="$listrelay"
apply_permissions apply_permissions
ynh_store_file_checksum --file="$final_path/config.yaml" ynh_store_file_checksum --file="$install_dir/config.yaml"
} }
set__listadmin() { set__listadmin() {
role="admin" role="admin"
ynh_app_setting_set --app=$app --key=listadmin --value="$listadmin" ynh_app_setting_set --app=$app --key=listadmin --value="$listadmin"
apply_permissions apply_permissions
ynh_store_file_checksum --file="$final_path/config.yaml" ynh_store_file_checksum --file="$install_dir/config.yaml"
} }

View file

@ -17,18 +17,6 @@ source /usr/share/yunohost/helpers
ynh_clean_setup () { ynh_clean_setup () {
true true
} }
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
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)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
@ -39,7 +27,7 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$final_path" ynh_backup --src_path="$install_dir"
#================================================= #=================================================
# SPECIFIC BACKUP # SPECIFIC BACKUP

View file

@ -3,8 +3,6 @@ source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
ynh_abort_if_errors ynh_abort_if_errors
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
# SPECIFIC GETTERS FOR TOML SHORT KEY # SPECIFIC GETTERS FOR TOML SHORT KEY
#================================================= #=================================================
@ -15,7 +13,7 @@ get__botname() {
} }
get__listuser() { get__listuser() {
existingUsers=$(grep -- "\".*: user" "$final_path/config.yaml" | sed -r 's/: user//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr '\n' ',') existingUsers=$(grep -- "\".*: user" "$install_dir/config.yaml" | sed -r 's/: user//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr '\n' ',')
cat <<EOF cat <<EOF
"$existingUsers" "$existingUsers"
@ -23,7 +21,7 @@ EOF
} }
get__listrelay() { get__listrelay() {
existingRelayUsers=$(grep -- "\".*: relay" "$final_path/config.yaml" | sed -r 's/: relay//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr '\n' ',') existingRelayUsers=$(grep -- "\".*: relay" "$install_dir/config.yaml" | sed -r 's/: relay//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr '\n' ',')
cat <<EOF cat <<EOF
"$existingRelayUsers" "$existingRelayUsers"
@ -31,7 +29,7 @@ EOF
} }
get__listadmin() { get__listadmin() {
existingAdmins=$(grep -- "\".*: admin" "$final_path/config.yaml" | sed -r 's/: admin//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr '\n' ',') existingAdmins=$(grep -- "\".*: admin" "$install_dir/config.yaml" | sed -r 's/: admin//' | tr -d '[:blank:]' | sed '/^#/d' | tr -d '\"' | tr '\n' ',')
cat <<EOF cat <<EOF
"$existingAdmins" "$existingAdmins"
@ -56,12 +54,12 @@ set__botname() {
ynh_app_setting_set --app=$app --key=botname --value="$botname" ynh_app_setting_set --app=$app --key=botname --value="$botname"
synapse_instance=$(ynh_app_setting_get --app $app --key synapse_instance) synapse_instance=$(ynh_app_setting_get --app $app --key synapse_instance)
sed -i "s/username:.*/username: $botname/" "$final_path/config.yaml" sed -i "s/username:.*/username: $botname/" "$install_dir/config.yaml"
"$final_path/mautrix-whatsapp" -g -c "$final_path/config.yaml" -r "/etc/matrix-$synapse_instance/app-service/$app.yaml" "$install_dir/mautrix-whatsapp" -g -c "$install_dir/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" "/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" chown -R "$app:$app" "$install_dir"
ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml" ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml"
ynh_store_file_checksum --file="$final_path/config.yaml" ynh_store_file_checksum --file="$install_dir/config.yaml"
} }
ynh_app_config_run $1 ynh_app_config_run $1

View file

@ -16,30 +16,8 @@ source /usr/share/yunohost/helpers
ynh_clean_setup () { ynh_clean_setup () {
true true
} }
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= # Retrieve some values from selected Synapse instance
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
appserviceid=$YNH_APP_INSTANCE_NAME
synapsenumber=$YNH_APP_ARG_SYNAPSENUMBER
botname=$YNH_APP_ARG_BOTNAME
bot_synapse_adm=$YNH_APP_ARG_BOT_SYNAPSE_ADM
encryption=$YNH_APP_ARG_ENCRYPTION
listadmin=$YNH_APP_ARG_BOTADMIN
listuser=$YNH_APP_ARG_BOTUSERS
app=$YNH_APP_INSTANCE_NAME
# ToDo check (in manifest?) if the selected synapse instance is not already connected to a mautrix_whatsapp bridge
if [ $synapsenumber -eq "1" ]
then
synapse_instance="synapse"
else
synapse_instance="synapse__$synapsenumber"
fi
server_name=$(ynh_app_setting_get --app $synapse_instance --key server_name) server_name=$(ynh_app_setting_get --app $synapse_instance --key server_name)
domain=$(ynh_app_setting_get --app $synapse_instance --key domain) domain=$(ynh_app_setting_get --app $synapse_instance --key domain)
synapse_db_name="matrix_$synapse_instance" synapse_db_name="matrix_$synapse_instance"
@ -57,6 +35,7 @@ fi
# SET STANDARD SETTINGS FROM DEFAULT CONFIG # SET STANDARD SETTINGS FROM DEFAULT CONFIG
#================================================= #=================================================
appserviceid=$app
async_media="false" async_media="false"
displayname="WhatsApp bridge bot" displayname="WhatsApp bridge bot"
avatar="mxc://maunium.net/NeXNQarUbrlYBiPCpprYsRqr" avatar="mxc://maunium.net/NeXNQarUbrlYBiPCpprYsRqr"
@ -76,7 +55,10 @@ admin_only="true"
print_level="info" print_level="info"
enable_relaybot="true" enable_relaybot="true"
listrelay="*" listrelay="*"
listadmin="$botadmin"
listuser="$botusers"
ynh_app_setting_set --app=$app --key=appserviceid --value=$appserviceid
ynh_app_setting_set --app=$app --key=async_media --value=$async_media ynh_app_setting_set --app=$app --key=async_media --value=$async_media
ynh_app_setting_set --app=$app --key=displayname --value=$displayname ynh_app_setting_set --app=$app --key=displayname --value=$displayname
ynh_app_setting_set --app=$app --key=avatar --value=$avatar ynh_app_setting_set --app=$app --key=avatar --value=$avatar
@ -97,79 +79,17 @@ ynh_app_setting_set --app=$app --key=admin_only --value=$admin_only
ynh_app_setting_set --app=$app --key=print_level --value=$print_level ynh_app_setting_set --app=$app --key=print_level --value=$print_level
ynh_app_setting_set --app=$app --key=listrelay --value=$listrelay ynh_app_setting_set --app=$app --key=listrelay --value=$listrelay
#=================================================
# 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"
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=7
ynh_app_setting_set --app=$app --key=appserviceid --value=$appserviceid
ynh_app_setting_set --app=$app --key=botname --value=$botname
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=listuser --value=$listuser
ynh_app_setting_set --app=$app --key=listadmin --value=$listadmin
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
#=================================================
# FIND AND OPEN A PORT
#=================================================
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)
ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=97
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# CREATE A POSTGRESQL DATABASE
#=================================================
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
ynh_psql_test_if_first_run
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 # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=5 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 # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" --source_id=$YNH_ARCH ynh_setup_source --dest_dir="$install_dir"
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R 750 "$final_path" chmod -R 750 "$install_dir"
chown -R $app:$app "$final_path" chown -R $app:$app "$install_dir"
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
@ -178,10 +98,10 @@ chown -R $app:$app "$final_path"
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=2 ynh_script_progression --message="Adding a configuration file..." --weight=2
ynh_add_config --template="../conf/config.yaml" --destination="$final_path/config.yaml" ynh_add_config --template="../conf/config.yaml" --destination="$install_dir/config.yaml"
chmod 400 "$final_path/config.yaml" chmod 400 "$install_dir/config.yaml"
chown $app:$app "$final_path/config.yaml" chown $app:$app "$install_dir/config.yaml"
# This calls allows to set multiple users during install question "botusers" specifying them separated by a comma # This calls allows to set multiple users during install question "botusers" specifying them separated by a comma
set__listuser set__listuser
@ -193,12 +113,12 @@ set__listadmin
#================================================= #=================================================
ynh_script_progression --message="Registering Synapse app-service" --weight=1 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 $install_dir/mautrix-whatsapp -g -c $install_dir/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" /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" chown -R $app:$app "$install_dir"
ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml" ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml"
ynh_store_file_checksum --file="$final_path/config.yaml" ynh_store_file_checksum --file="$install_dir/config.yaml"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD

View file

@ -16,13 +16,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=5
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
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)
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 db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
synapse_db_name="matrix_$synapse_instance" synapse_db_name="matrix_$synapse_instance"
bot_synapse_db_user="@""$botname"":""$server_name" bot_synapse_db_user="@""$botname"":""$server_name"
@ -60,9 +54,6 @@ ynh_remove_logrotate
#================================================= #=================================================
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=4 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_user" --db_name="$db_name"
if ynh_psql_user_exists --user="$app"; then if ynh_psql_user_exists --user="$app"; then
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 \"$app\";"
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 \"$app\";"
@ -79,22 +70,6 @@ if ynh_psql_user_exists --user="$botname"; then
fi fi
#yunohost app action run $synapse_instance drop_user -a username=$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
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=8
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#================================================= #=================================================
# SPECIFIC REMOVE # SPECIFIC REMOVE
#================================================= #=================================================
@ -109,16 +84,6 @@ ynh_secure_remove --file="/etc/matrix-$synapse_instance/app-service/$app.yaml"
# Remove the log files # Remove the log files
ynh_secure_remove --file="/var/log/$app" ynh_secure_remove --file="/var/log/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=5
# Delete a system user
ynh_system_user_delete --username=$app
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -17,79 +17,29 @@ source /usr/share/yunohost/helpers
ynh_clean_setup () { ynh_clean_setup () {
true true
} }
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
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)
botname=$(ynh_app_setting_get --app=$app --key=botname)
synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance)
bot_synapse_adm=$(ynh_app_setting_get --app=$app --key=bot_synapse_adm)
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)
previous_mautrix_version=$(ynh_app_setting_get --app=$app --key=mautrix_version)
port=$(ynh_app_setting_get --app=$app --key=port)
synapse_db_name="matrix_$synapse_instance" synapse_db_name="matrix_$synapse_instance"
bot_synapse_db_user="@$botname:$server_name" 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 "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$install_dir"
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R 750 "$final_path" chmod -R 750 "$install_dir"
chown -R $app:$app "$final_path" chown -R $app:$app "$install_dir"
#================================================= #=================================================
# SPECIFIC RESTORATION # 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
#================================================= #=================================================
# RESTORE THE POSTGRESQL DATABASE # RESTORE THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=8 ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=8
ynh_psql_test_if_first_run ynh_psql_test_if_first_run
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_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 ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
@ -98,17 +48,9 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
#================================================= #=================================================
ynh_script_progression --message="Registering Synapse app-service" --weight=1 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 $install_dir/mautrix-whatsapp -g -c $install_dir/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
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=3
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
#================================================= #=================================================
# RESTORE THE LOGROTATE CONFIGURATION # RESTORE THE LOGROTATE CONFIGURATION
#================================================= #=================================================
@ -116,13 +58,6 @@ ynh_script_progression --message="Restoring the logrotate configuration..." --we
ynh_restore_file --origin_path="/etc/logrotate.d/$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"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================

View file

@ -9,24 +9,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=5
app=$YNH_APP_INSTANCE_NAME
appserviceid=$(ynh_app_setting_get --app=$app --key=appserviceid)
botname=$(ynh_app_setting_get --app=$app --key=botname)
encryption=$(ynh_app_setting_get --app=$app --key=encryption)
domain=$(ynh_app_setting_get --app=$app --key=domain)
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
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" synapse_db_name="matrix_$synapse_instance"
bot_synapse_db_user="@$botname:$server_name" bot_synapse_db_user="@$botname:$server_name"
@ -68,14 +50,10 @@ upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=10 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 () { ynh_clean_setup () {
# Restore it if the upgrade fails # Restore it if the upgrade fails
ynh_restore_upgradebackup ynh_restore_upgradebackup
} }
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
@ -236,9 +214,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 # 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 # See more: https://docs.mau.fi/bridges/go/setup.html?bridge=whatsapp#systemd-service
if ynh_system_user_exists -u "$app"; then if ynh_system_user_exists -u "$app"; then
usermod --home "$final_path" $app usermod --home "$install_dir" $app
else else
ynh_system_user_create --username=$app --home_dir="$final_path" ynh_system_user_create --username=$app --home_dir="$install_dir"
fi fi
#================================================= #=================================================
@ -250,19 +228,12 @@ then
ynh_script_progression --message="Upgrading source files..." --weight=2 ynh_script_progression --message="Upgrading source files..." --weight=2
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" --source_id=$YNH_ARCH ynh_setup_source --dest_dir="$install_dir" --source_id=$YNH_ARCH
fi fi
chmod 750 "$final_path" chmod 750 "$install_dir"
chmod -R 750 "$final_path" chmod -R 750 "$install_dir"
chown -R $app:$app "$final_path" chown -R $app:$app "$install_dir"
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=100
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
@ -279,10 +250,10 @@ listrelay="*"
listuser="@user:domain.tld" listuser="@user:domain.tld"
listadmin="@admin:domain.tld" listadmin="@admin:domain.tld"
ynh_add_config --template="../conf/config.yaml" --destination="$final_path/config.yaml" ynh_add_config --template="../conf/config.yaml" --destination="$install_dir/config.yaml"
chmod 400 "$final_path/config.yaml" chmod 400 "$install_dir/config.yaml"
chown $app:$app "$final_path/config.yaml" chown $app:$app "$install_dir/config.yaml"
listrelay=$listrelay_ listrelay=$listrelay_
listuser=$listuser_ listuser=$listuser_
@ -298,13 +269,13 @@ set__listadmin
#================================================= #=================================================
ynh_script_progression --message="Registering Synapse app-service" --weight=1 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 $install_dir/mautrix-whatsapp -g -c $install_dir/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"
# Set permissions on app files # Set permissions on app files
chown -R $app:$app "$final_path" chown -R $app:$app "$install_dir"
ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml" ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml"
ynh_store_file_checksum --file="$final_path/config.yaml" ynh_store_file_checksum --file="$install_dir/config.yaml"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD