From f2f21b8ff07f2783bc3702139625736cbcd266d9 Mon Sep 17 00:00:00 2001 From: Dante Date: Sun, 4 Jun 2023 21:30:13 +0100 Subject: [PATCH 1/7] Packaging v2 WIP --- conf/amd64.src | 6 --- conf/arm64.src | 6 --- conf/armhf.src | 6 --- conf/systemd.service | 6 +-- config_panel.toml | 40 +++++++-------- manifest.json | 114 ------------------------------------------- manifest.toml | 110 +++++++++++++++++++++++++++++++++++++++++ scripts/_common.sh | 23 +++------ scripts/backup | 14 +----- scripts/config | 16 +++--- scripts/install | 110 ++++++----------------------------------- scripts/remove | 35 ------------- scripts/restore | 75 ++-------------------------- scripts/upgrade | 53 +++++--------------- 14 files changed, 181 insertions(+), 433 deletions(-) delete mode 100644 conf/amd64.src delete mode 100644 conf/arm64.src delete mode 100644 conf/armhf.src delete mode 100644 manifest.json create mode 100644 manifest.toml diff --git a/conf/amd64.src b/conf/amd64.src deleted file mode 100644 index 3716081..0000000 --- a/conf/amd64.src +++ /dev/null @@ -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 diff --git a/conf/arm64.src b/conf/arm64.src deleted file mode 100644 index 4296588..0000000 --- a/conf/arm64.src +++ /dev/null @@ -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 diff --git a/conf/armhf.src b/conf/armhf.src deleted file mode 100644 index e63c3ca..0000000 --- a/conf/armhf.src +++ /dev/null @@ -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 diff --git a/conf/systemd.service b/conf/systemd.service index bee8791..0e8c08b 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,13 +6,13 @@ After=matrix-synapse.service Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/ -ExecStart=__FINALPATH__/mautrix-whatsapp -c=__FINALPATH__/config.yaml +WorkingDirectory=__INSTALL_DIR__/ +ExecStart=__INSTALL_DIR__/mautrix-whatsapp -c=__INSTALL_DIR__/config.yaml Restart=always RestartSec=3 # Optional hardening to improve security -ReadWritePaths=__FINALPATH__/ /var/log/__APP__ +ReadWritePaths=__INSTALL_DIR__/ /var/log/__APP__ NoNewPrivileges=yes MemoryDenyWriteExecute=true PrivateDevices=yes diff --git a/config_panel.toml b/config_panel.toml index 27bff09..8e53315 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -42,7 +42,7 @@ services = ["__APP__"] yes = "true" 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." - bind = "relay>enabled:__FINALPATH__/config.yaml" + bind = "relay>enabled:__INSTALL_DIR__/config.yaml" [main.bridge.admin_only] ask = "Should only Bridge Admins be allowed to set themselves as Relay Users?" @@ -50,7 +50,7 @@ services = ["__APP__"] yes = "true" no = "false" help = "See User management -> Admins" - bind = ":__FINALPATH__/config.yaml" + bind = ":__INSTALL_DIR__/config.yaml" visible = "enable_relaybot" [main.bot] @@ -60,19 +60,19 @@ services = ["__APP__"] ask = "Username of the AppService Bot" 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" - bind = "bot>username:__FINALPATH__/config.yaml" + bind = "bot>username:__INSTALL_DIR__/config.yaml" [main.bot.displayname] ask = "Display name for Bot" type = "string" 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] ask = "Avatar for Bot" 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." - bind = ":__FINALPATH__/config.yaml" + bind = ":__INSTALL_DIR__/config.yaml" [privacy] name = "Privacy" @@ -95,7 +95,7 @@ services = ["__APP__"] yes = "true" 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." - bind = "encryption>allow:__FINALPATH__/config.yaml" + bind = "encryption>allow:__INSTALL_DIR__/config.yaml" [privacy.portal_rooms.encryption_default] ask = "Force-enable Encryption in all Portal Rooms the Bridge creates?" @@ -103,7 +103,7 @@ services = ["__APP__"] yes = "true" no = "false" 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" [privacy.portal_rooms.encryption_require] @@ -112,7 +112,7 @@ services = ["__APP__"] yes = "true" no = "false" help = "Require encryption, drop any unencrypted messages." - bind = "encryption>require:__FINALPATH__/config.yaml" + bind = "encryption>require:__INSTALL_DIR__/config.yaml" visible = "encryption" [privacy.config] @@ -124,7 +124,7 @@ services = ["__APP__"] yes = "true" no = "false" 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] ask = "Send Presence on typing?" @@ -132,7 +132,7 @@ services = ["__APP__"] yes = "true" no = "false" 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] ask = "Enable URL Preview?" @@ -140,7 +140,7 @@ services = ["__APP__"] yes = "true" no = "false" 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] name = "Advanced Settings" @@ -160,19 +160,19 @@ services = ["__APP__"] ask = "Localpart template of MXIDs for WhatsApp users" type = "string" 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] ask = "Device name in the 'WhatsApp Web' section of the smartphone app" type = "string" - bind = ":__FINALPATH__/config.yaml" + bind = ":__INSTALL_DIR__/config.yaml" [advanced.whatsapp.browser_name] ask = "Browser name that determines the logo shown in the smartphone app" type = "select" 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." - bind = ":__FINALPATH__/config.yaml" + bind = ":__INSTALL_DIR__/config.yaml" [advanced.appservice] name = "HomeServer Application Service" @@ -183,7 +183,7 @@ services = ["__APP__"] yes = "true" no = "false" 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] ask = "Receive Ephemeral Events via AppService transactions?" @@ -191,14 +191,14 @@ services = ["__APP__"] yes = "true" no = "false" 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" type = "select" choices = ["debug", "info", "warn", "error", "fatal"] 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] name = "Prometheus Metrics" @@ -208,12 +208,12 @@ services = ["__APP__"] type = "boolean" yes = "true" no = "false" - bind = "metrics>enabled:__FINALPATH__/config.yaml" + bind = "metrics>enabled:__INSTALL_DIR__/config.yaml" [advanced.metrics.listen_port] ask = "IP and Port for the Metrics listener?" type = "string" 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" diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 828a084..0000000 --- a/manifest.json +++ /dev/null @@ -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" - } - } - ] - } -} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..29872df --- /dev/null +++ b/manifest.toml @@ -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" \ No newline at end of file diff --git a/scripts/_common.sh b/scripts/_common.sh index 1431a9f..bc0deff 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,12 +1,5 @@ #!/bin/bash -#================================================= -# COMMON VARIABLES -#================================================= - -# dependencies used by the app (must be on a single line) -pkg_dependencies="g++ postgresql ffmpeg" - #================================================= # CONFIG PANEL SETTERS #================================================= @@ -22,24 +15,24 @@ apply_permissions() { then #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. - 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. - 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". - sed -i "/permissions:/,/relay:/{/: \"$role\"/d;}" "$final_path/config.yaml" + sed -i "/permissions:/,/relay:/{/: \"$role\"/d;}" "$install_dir/config.yaml" for user in "${usersArray[@]}" do if grep -q -x "${user}" <<< "$allDefinedEntries" then ynh_print_info "User $user already defined in another role." 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 done fi 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" ynh_app_setting_set --app=$app --key=listuser --value="$listuser" apply_permissions - ynh_store_file_checksum --file="$final_path/config.yaml" + ynh_store_file_checksum --file="$install_dir/config.yaml" } set__listrelay() { role="relay" ynh_app_setting_set --app=$app --key=listrelay --value="$listrelay" apply_permissions - ynh_store_file_checksum --file="$final_path/config.yaml" + ynh_store_file_checksum --file="$install_dir/config.yaml" } set__listadmin() { role="admin" ynh_app_setting_set --app=$app --key=listadmin --value="$listadmin" apply_permissions - ynh_store_file_checksum --file="$final_path/config.yaml" + ynh_store_file_checksum --file="$install_dir/config.yaml" } \ No newline at end of file diff --git a/scripts/backup b/scripts/backup index 917677c..2347381 100755 --- a/scripts/backup +++ b/scripts/backup @@ -17,18 +17,6 @@ source /usr/share/yunohost/helpers ynh_clean_setup () { 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 @@ -39,7 +27,7 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= # SPECIFIC BACKUP diff --git a/scripts/config b/scripts/config index b1a5de1..364874c 100644 --- a/scripts/config +++ b/scripts/config @@ -3,8 +3,6 @@ source _common.sh source /usr/share/yunohost/helpers ynh_abort_if_errors -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - #================================================= # SPECIFIC GETTERS FOR TOML SHORT KEY #================================================= @@ -15,7 +13,7 @@ get__botname() { } 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 < Date: Sun, 16 Jul 2023 11:40:28 +0100 Subject: [PATCH 2/7] Refactor restore, add tests and refactor upgrade --- check_process | 33 -------------------------------- manifest.toml | 5 +++++ scripts/restore | 24 +++++++++++++++++++++++ scripts/upgrade | 51 ++----------------------------------------------- tests.toml | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 82 insertions(+), 82 deletions(-) delete mode 100644 check_process create mode 100644 tests.toml diff --git a/check_process b/check_process deleted file mode 100644 index a30309e..0000000 --- a/check_process +++ /dev/null @@ -1,33 +0,0 @@ -;; 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_free_registration=$is_free_registration&jitsi_server=$jitsi_server" --force - ; Manifest - synapsenumber="1" - whatsappbot="whatsappbot" - bot_synapse_adm=0 - encryption=0 - botadmin="@johndoe:synapsedomain.tld" - botusers="@johndoe:synapsedomain.tld" - ; Checks - pkg_linter=1 - setup_sub_dir=0 - setup_root=0 - setup_nourl=1 - setup_private=0 - setup_public=0 - upgrade=1 - # 0.4.0 - upgrade=1 from_commit=717b32f454819c1bb936152c69d9693d34434741 - # 0.6.1 - upgrade=1 from_commit=fdd1e0ff652ae47b5e3c62477eea678c465659cf - backup_restore=1 - multi_instance=1 -;;; Options -Email= -Notification=none -;;; Upgrade options - ; commit=717b32f454819c1bb936152c69d9693d34434741 - name=0.4.0 - ; commit=fdd1e0ff652ae47b5e3c62477eea678c465659cf - name=0.6.1 diff --git a/manifest.toml b/manifest.toml index 29872df..5170831 100644 --- a/manifest.toml +++ b/manifest.toml @@ -32,6 +32,7 @@ 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." +default = "synapse" [install.botname] ask.en = "Choose a local Synapse user name for the WhatsApp bot" @@ -87,6 +88,10 @@ packages = "g++, postgresql, ffmpeg" [resources.database] type = "postgresql" +[resources.permissions] +main.allowed = "all_users" +main.auth_header = false + [resources.system_user] home = "/opt/yunohost/__APP__" diff --git a/scripts/restore b/scripts/restore index 65e19f2..5eb36d5 100755 --- a/scripts/restore +++ b/scripts/restore @@ -18,6 +18,8 @@ ynh_clean_setup () { true } +server_name=$(ynh_app_setting_get --app=$app --key=server_name) + synapse_db_name="matrix_$synapse_instance" bot_synapse_db_user="@$botname:$server_name" @@ -51,12 +53,34 @@ ynh_script_progression --message="Registering Synapse app-service" --weight=1 $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" +chmod 400 "$install_dir/config.yaml" +chown $app:$app "$install_dir/config.yaml" + +#================================================= +# 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 #================================================= ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 ynh_restore_file --origin_path="/etc/logrotate.d/$app" +mkdir --parents "/var/log/$app" +chmod -R 600 "/var/log/$app" +chmod 700 "/var/log/$app" +chown -R $app:$app /var/log/$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 diff --git a/scripts/upgrade b/scripts/upgrade index 7da3f10..8e731b8 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,35 +9,11 @@ source _common.sh source /usr/share/yunohost/helpers +server_name=$(ynh_app_setting_get --app=$app --key=server_name) + synapse_db_name="matrix_$synapse_instance" bot_synapse_db_user="@$botname:$server_name" -#================================================= -# GET CONFIG PANEL SETTINGS -#================================================= -async_media=$(ynh_app_setting_get --app=$app --key=async_media) -displayname=$(ynh_app_setting_get --app=$app --key=displayname) -avatar=$(ynh_app_setting_get --app=$app --key=avatar) -ephemeral_events=$(ynh_app_setting_get --app=$app --key=ephemeral_events) -enable_metrics=$(ynh_app_setting_get --app=$app --key=enable_metrics) -listen_port=$(ynh_app_setting_get --app=$app --key=listen_port) -os_name=$(ynh_app_setting_get --app=$app --key=os_name) -browser_name=$(ynh_app_setting_get --app=$app --key=browser_name) -username_template=$(ynh_app_setting_get --app=$app --key=username_template) -personal_filtering_spaces=$(ynh_app_setting_get --app=$app --key=personal_filtering_spaces) -delivery_receipts=$(ynh_app_setting_get --app=$app --key=delivery_receipts) -send_presence_on_typing=$(ynh_app_setting_get --app=$app --key=send_presence_on_typing) -url_previews=$(ynh_app_setting_get --app=$app --key=url_previews) -encryption_default=$(ynh_app_setting_get --app=$app --key=encryption_default) -encryption_require=$(ynh_app_setting_get --app=$app --key=encryption_require) -enable_relaybot=$(ynh_app_setting_get --app=$app --key=enable_relaybot) -admin_only=$(ynh_app_setting_get --app=$app --key=admin_only) -print_level=$(ynh_app_setting_get --app=$app --key=print_level) - -listrelay=$(ynh_app_setting_get --app=$app --key=listrelay) -listuser=$(ynh_app_setting_get --app=$app --key=listuser) -listadmin=$(ynh_app_setting_get --app=$app --key=listadmin) - #================================================= # CHECK VERSION #================================================= @@ -45,16 +21,6 @@ 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 - -ynh_clean_setup () { - # Restore it if the upgrade fails - ynh_restore_upgradebackup -} - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -206,19 +172,6 @@ then ynh_app_setting_delete --app=$app --key=botadmin fi -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=8 - -# 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 "$install_dir" $app -else - ynh_system_user_create --username=$app --home_dir="$install_dir" -fi - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..2f8243c --- /dev/null +++ b/tests.toml @@ -0,0 +1,51 @@ +test_format = 1.0 + +[default] + +# ------------ +# Tests to run +# ------------ + +# For special usecases, sometimes you need to setup other things on the machine +# prior to installing the app (such as installing another app) +# (Remove this key entirely if not needed) +preinstall = """ + sudo yunohost tools update apps + 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 + """ + +# ------------------------------- +# Default args to use for install +# ------------------------------- + +# By default, the CI will automagically fill the 'standard' args +# such as domain, path, admin, is_public and password with relevant values +# and also install args with a "default" provided in the manifest.. +# It should only make sense to declare custom args here for args with no default values + +args.botadmin = "@johndoe:server.name" +args.botusers = "server.name" + +# ------------------------------- +# Commits to test upgrade from +# ------------------------------- + +test_upgrade_from.717b32f4.name = "Upgrade from 0.4.0" + +test_upgrade_from.fdd1e0ff.name = "Upgrade from 0.6.1" + + +# This is an additional test suite +[multiple_botusers] + +preinstall = """ + sudo yunohost tools update apps + 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 + """ + +# On additional tests suites, you can decide to run only specific tests + +only = ["install.subdir"] + +args.botadmin = "@johndoe:server.name" +args.botusers = "@john:server.name,@jdoe:server.name,@janedoe:server.name" \ No newline at end of file From b7c0120eab72cb153d3e0ea0ed8abd0f83099ce8 Mon Sep 17 00:00:00 2001 From: Dante Date: Mon, 17 Jul 2023 10:18:46 +0100 Subject: [PATCH 3/7] Finish refactor upgrade and add RAM estimates to manifest --- manifest.toml | 18 +++++++++--------- scripts/upgrade | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest.toml b/manifest.toml index 5170831..471c9b8 100644 --- a/manifest.toml +++ b/manifest.toml @@ -3,7 +3,7 @@ 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" +version = "0.9.0~ynh1" maintainers = ["thardev"] [upstream] @@ -19,8 +19,8 @@ multi_instance = true ldap = false sso = false disk = "100M" -ram.build = "1M" -ram.runtime = "1M" +ram.build = "256M" +ram.runtime = "1024M" [install] @@ -107,9 +107,9 @@ main.default = 8449 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" \ No newline at end of file +amd64.url = "https://github.com/mautrix/whatsapp/releases/download/v0.9.0/mautrix-whatsapp-amd64" +amd64.sha256 = "27b5d3ee0cada177207b662072b42923956e38a9c10c4e167eeca17881f3bffb" +arm64.url = "https://github.com/mautrix/whatsapp/releases/download/v0.9.0/mautrix-whatsapp-arm64" +arm64.sha256 = "dc475a2af45988d6d428af18c5f2a30da24930201e0e667a0b749a198a3bd02d" +armhf.url = "https://github.com/mautrix/whatsapp/releases/download/v0.9.0/mautrix-whatsapp-arm" +armhf.sha256 = "22c28d17ec868c4579e8ed64e092b0947a268c82ed9714d3ae45ace05b477fd8" \ No newline at end of file diff --git a/scripts/upgrade b/scripts/upgrade index 8e731b8..41337ef 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -181,7 +181,7 @@ 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="$install_dir" --source_id=$YNH_ARCH + ynh_setup_source --dest_dir="$install_dir" fi chmod 750 "$install_dir" From 9377a553a2dbfc3a7e7ee168e4b9c711ebab9346 Mon Sep 17 00:00:00 2001 From: Dante Date: Tue, 1 Aug 2023 14:50:34 +0100 Subject: [PATCH 4/7] Finish refactor updater.sh, fix some install missing values and clean remove script --- .github/workflows/updater.sh | 25 ++++++++++--------------- scripts/install | 4 +++- scripts/remove | 21 --------------------- 3 files changed, 13 insertions(+), 37 deletions(-) diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh index 4e85e56..253aacc 100755 --- a/.github/workflows/updater.sh +++ b/.github/workflows/updater.sh @@ -14,8 +14,8 @@ #================================================= # Fetching information -current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') -repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') +current_version=$(yq ".version" manifest.toml | cut -d '~' -f 1 -) +repo=$(yq ".upstream.code" manifest.toml | sed 's/https:\/\/github.com\///') # Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'")) @@ -31,9 +31,9 @@ fi # Setting up the environment variables echo "Current version: $current_version" echo "Latest release from upstream: $version" -echo "VERSION=$version" >> $GITHUB_ENV +echo "VERSION=$version" >> "$GITHUB_ENV" # For the time being, let's assume the script will fail -echo "PROCEED=false" >> $GITHUB_ENV +echo "PROCEED=false" >> "$GITHUB_ENV" # Proceed only if the retrieved version is greater than the current one if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then @@ -91,15 +91,8 @@ curl --silent -4 -L $tarball -o "$tempdir/$version" checksum=$(sha256sum "$tempdir/$filename" | head -c 64) # Rewrite source file -cat < conf/$src.src -SOURCE_URL=$asset_url -SOURCE_SUM=$checksum -SOURCE_SUM_PRG=sha256sum -SOURCE_IN_SUBDIR=false -SOURCE_FILENAME=mautrix-whatsapp -SOURCE_EXTRACT=false -EOT -echo "... conf/$src.src updated" +sed -i "s|$src.url.*|src.url = \"$asset_url\"|g" manifest.toml +sed -i "s|$src.sha256.*|$src.sha256 = \"$checksum\"|g" manifest.toml else echo "... asset ignored" @@ -107,6 +100,8 @@ fi done +echo "manifest.toml assets updated" + #================================================= # SPECIFIC UPDATE STEPS #================================================= @@ -148,7 +143,7 @@ yq -i '.bridge.encryption.require = "__ENCRYPTION_REQUIRE__"' $configFilePath yq -i 'with(.bridge.permissions ; . = { "__LISTRELAY__": "relay", "__LISTUSER__": "user", "__LISTADMIN__": "admin" } | ... style="double")' $configFilePath yq -i '.bridge.relay.enabled = "__ENABLE_RELAYBOT__"' $configFilePath yq -i '.bridge.relay.admin_only = "__ADMIN_ONLY__"' $configFilePath -yq -i '.logging.writers.filename = "/var/log/__APP__/__APP__.log"' $configFilePath +yq -i '.logging.writers[1].filename = "/var/log/__APP__/__APP__.log"' $configFilePath yq -i '.logging.min_level = "__PRINT_LEVEL__"' $configFilePath #================================================= @@ -156,7 +151,7 @@ yq -i '.logging.min_level = "__PRINT_LEVEL__"' $configFilePath #================================================= # Replace new version in manifest -echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json +sed -i "s|version.*|version = \"$version~ynh1\"|g" manifest.toml # Delete temporary directory rm -rf $tempdir diff --git a/scripts/install b/scripts/install index 8270d10..119a545 100755 --- a/scripts/install +++ b/scripts/install @@ -17,9 +17,11 @@ ynh_clean_setup () { true } -# Retrieve some values from selected Synapse instance +# Retrieve some values from selected Synapse instance and store them server_name=$(ynh_app_setting_get --app $synapse_instance --key server_name) domain=$(ynh_app_setting_get --app $synapse_instance --key domain) +ynh_app_setting_set --app=$app --key=server_name --value=$server_name +ynh_app_setting_set --app=$app --key=domain --value=$domain synapse_db_name="matrix_$synapse_instance" # This is needed to convert the value from the manifest to a valid value for the config.yaml file. diff --git a/scripts/remove b/scripts/remove index 14486a8..eb852e4 100755 --- a/scripts/remove +++ b/scripts/remove @@ -49,27 +49,6 @@ ynh_script_progression --message="Removing logrotate configuration..." --weight= # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# REMOVE THE POSTGRESQL DATABASE -#================================================= -ynh_script_progression --message="Removing the PostgreSQL database..." --weight=4 - -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 USER \"$app\";" -fi - -if ynh_psql_user_exists --user="$bot_synapse_db_user"; then - 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 USER \"$bot_synapse_db_user\";" -fi - -if ynh_psql_user_exists --user="$botname"; then - ynh_psql_execute_as_root --database="$synapse_db_name" --sql="DROP OWNED BY \"$botname\";" - ynh_psql_execute_as_root --database="$synapse_db_name" --sql="DROP USER \"$botname\";" -fi -#yunohost app action run $synapse_instance drop_user -a username=$botname - #================================================= # SPECIFIC REMOVE #================================================= From 710985832050c9f3c85f1f562008b718ead96252 Mon Sep 17 00:00:00 2001 From: Dante Date: Wed, 2 Aug 2023 12:09:55 +0100 Subject: [PATCH 5/7] Create new docs and fix linter issues --- doc/ADMIN.md | 18 +++++++ doc/ADMIN_fr.md | 17 +++++++ doc/DEVELOPMENT.md | 9 ++++ doc/DEVELOPMENT_fr.md | 10 ++++ doc/DISCLAIMER.md | 103 ----------------------------------------- doc/DISCLAIMER_fr.md | 87 ---------------------------------- doc/POST_INSTALL.md | 37 +++++++++++++++ doc/POST_INSTALL_fr.md | 24 ++++++++++ doc/PRE_INSTALL.md | 33 +++++++++++++ doc/PRE_INSTALL_fr.md | 31 +++++++++++++ scripts/backup | 8 ---- scripts/install | 8 ---- scripts/restore | 10 ---- tests.toml | 4 +- 14 files changed, 181 insertions(+), 218 deletions(-) create mode 100644 doc/ADMIN.md create mode 100644 doc/ADMIN_fr.md create mode 100644 doc/DEVELOPMENT.md create mode 100644 doc/DEVELOPMENT_fr.md delete mode 100644 doc/DISCLAIMER.md delete mode 100644 doc/DISCLAIMER_fr.md create mode 100644 doc/POST_INSTALL.md create mode 100644 doc/POST_INSTALL_fr.md create mode 100644 doc/PRE_INSTALL.md create mode 100644 doc/PRE_INSTALL_fr.md diff --git a/doc/ADMIN.md b/doc/ADMIN.md new file mode 100644 index 0000000..a205c7b --- /dev/null +++ b/doc/ADMIN.md @@ -0,0 +1,18 @@ +## 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 using the existing config panel in the Yunohost admin panel or by modifying the +following configuration file with SSH: +```/opt/yunohost/mautrix_whatsapp/config.yaml``` +and then restarting the mautrix_whatsapp service. + +#### User permissions + + +#### End-to-bridge encryption +The bridge can optionally encrypt messages between Matrix users and the bridge to hide messages from the homeserver. Using Postgres is strongly recommended when using end-to-bridge encryption. + +If you want to enable it, go to the config panel section `Privacy -> Portal Rooms & Encryption Settings`. If you enable `Allow Encryption between Matrix Client and Bridge Server?`, the bridge won't enable encryption on its own, but will work in encrypted rooms. +Alternatively two more options will appear, `Force-enable Encryption in all Portal Rooms the Bridge creates?` which will automatically enable encryption in new portals and `Require encryption?` which will enforce encryption on any of the messages that you send (this will make the bridge drop any future unencrypted messages). + +There is also the possibity to configure it in the bridge configuration YAML file in the section `bridge: encryption`. \ No newline at end of file diff --git a/doc/ADMIN_fr.md b/doc/ADMIN_fr.md new file mode 100644 index 0000000..278bae3 --- /dev/null +++ b/doc/ADMIN_fr.md @@ -0,0 +1,17 @@ +### Configuration de la passerelle + +La passerelle est [configurée avec les paramètres standards adaptés pour votre YunoHost et l'instance Matrix-Synapse sélectionnée](https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh/blob/master/conf/config.yaml). +Une configuration plus fine peut être effectuée en utilisant le panneau de configuration existant dans le panneau d'administration de Yunohost ou en modifiant le fichier de configuration suivant avec SSH: +``` /opt/yunohost/mautrix_whatsapp/config.yaml``` +puis en redémarrant le service mautrix_whatsapp. + +#### User permissions + + +#### End-to-bridge encryption +Le robot peut éventuellement chiffrer les messages entre les utilisateurs de Matrix et la passarelle pour cacher les messages du serveur domestique. L'utilisation de Postgres est fortement recommandée lors de l'utilisation du chiffrement end-to-bridge. + +Si vous voulez l'activer, allez dans la section `Privacy -> Portal Rooms & Encryption Settings` du panneau de configuration. Si vous activez `Allow Encryption between Matrix Client and Bridge Server?`, la passarelle n'activera pas le cryptage d'elle-même, mais fonctionnera dans les salles cryptées. +Sinon, deux autres options apparaissent, `Force-enable Encryption in all Portal Rooms the Bridge creates?` qui activera automatiquement le cryptage dans les nouveaux portails et `Require encryption?` qui imposera le cryptage sur tous les messages que vous envoyez (ce qui fera que le robot abandonnera tous les messages non cryptés à l'avenir). + +Il est également possible de le configurer dans le fichier YAML de configuration du robot dans la section `bridge: encryption`. \ No newline at end of file diff --git a/doc/DEVELOPMENT.md b/doc/DEVELOPMENT.md new file mode 100644 index 0000000..cf74fbd --- /dev/null +++ b/doc/DEVELOPMENT.md @@ -0,0 +1,9 @@ +## Development code quality + +The `.github/workflows/updater.sh` script needs to be synced with changes in `conf/config.yaml` therefore a `pre-commit` +hook is used to display a reminder to update `.github/workflows/updater.sh` (if needed) when `conf/config.yaml` has been modified. + +Please enable Git hooks using following command to ensure code quality and stability. +``` bash +git config --local core.hooksPath .githooks +``` \ No newline at end of file diff --git a/doc/DEVELOPMENT_fr.md b/doc/DEVELOPMENT_fr.md new file mode 100644 index 0000000..11bd6c0 --- /dev/null +++ b/doc/DEVELOPMENT_fr.md @@ -0,0 +1,10 @@ +## Development code quality + +Le script `.github/workflows/updater.sh` doit être synchronisé avec les changements dans `conf/config.yaml`, +donc un hook `pre-commit` est utilisé pour afficher un rappel pour mettre à jour +`.github/workflows/updater.sh` (si nécessaire) lorsque `conf/config.yaml` a été modifié. + +Veuillez activer les hooks Git en utilisant la commande suivante pour assurer la qualité et la stabilité du code. +``` bash +git config --local core.hooksPath .githooks +``` \ No newline at end of file diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md deleted file mode 100644 index aed5895..0000000 --- a/doc/DISCLAIMER.md +++ /dev/null @@ -1,103 +0,0 @@ -## List of known public services - -* Ask on one of the following rooms: #mautrix_yunohost:matrix.fdn.fr or #whatsapp:maunium.net - -## 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 -* 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". -* Type ``login`` -* Capture the QR code with the camera in the whatsapp of your VM or smartphone (WhatsApp Web) -* Send ``help`` to the bot in the created room to know how to control the bot. -See also [upstream wiki Authentication page](https://docs.mau.fi/bridges/go/whatsapp/authentication.html) - -### Bridge an existing room | Bridge Whatsapp to Signal over Matrix -By default, the bridge creates a portal room for each WA group that the WA user actively uses. -Your can also create a portal for an existing Matrix room. **Note that this can be a room created by another bridge, e.g. a Signal portal room** -1. Invite the bridge bot to the room (with an authorized user) -2. type `!wa create` -3. Your logged in WA user creates a new corresponding group. -4. Get the WA invite link `!wa invite-link` and share it with friends. Or invite Whatsapp puppets to room. -5. Optional: Activate relaybot, see next section. - -### Relaybot: Bridge a group for several Matrix and several WhatsApp users to chat together -**When upgrading from /dev/null | awk '/-----BEGIN CERTIFICATE-----/, /-----END CERTIFICATE-----/' >> /usr/local/share/ca-certificates/synapse.vm.crt -update-ca-certificates -``` - -### Miscellaneous information - - * Matrix room (matrix bridges in YunoHost): #mautrix_yunohost:matrix.fdn.fr - * Matrix room (upstream app): #whatsapp:maunium.net -In case you need to upload your logs somewhere, be aware that they contain your contacts' and your phone numbers. Strip them out with -``| sed -r 's/[0-9]{10,}/📞/g' `` - * "Mautrix-WhatsApp" bridge is based on the [Rhymen/go-whatsapp](https://github.com/Rhymen/go-whatsapp) implementation of the [sigalor/whatsapp-web-reveng](https://github.com/sigalor/whatsapp-web-reveng) project. - -## Development code quality - -The `.github/workflows/updater.sh` script needs to be synced with changes in `conf/config.yaml` therefore a `pre-commit` -hook is used to display a reminder to update `.github/workflows/updater.sh` (if needed) when `conf/config.yaml` has been modified. - -Please enable Git hooks using following command to ensure code quality and stability. -``` bash -git config --local core.hooksPath .githooks -``` \ No newline at end of file diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md deleted file mode 100644 index 5c4a5ad..0000000 --- a/doc/DISCLAIMER_fr.md +++ /dev/null @@ -1,87 +0,0 @@ -## Liste de passerelles publiques - -* Demandez sur un des salons suivants: #mautrix_yunohost:matrix.fdn.fr or #whatsapp:maunium.net - -## 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 -* 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". -* Tapez ``login`` -* Scannez le QR-code avec la caméra Whatsapp de votre Machine Virtuelle ou ordiphone (option WhatsApp Web dans l'appli) -* Envoyez ``help`` au Robot dans le "Administration Room" pour une liste des commandes d'administration de la passerelle. -Voir aussi [upstream wiki Authentication page](https://docs.mau.fi/bridges/go/whatsapp/authentication.html) - -#### Robot-Relai "Relaybot": Relayer les conversations de TOUS les comptes Matrix et TOUS les comptes WhatsApp présents dans UN groupe/salon - -* Prérequis : Créer un nouveau salon vide "Relaybot Administration Room" et rechercher son identifiant. -* Activer l'option Robot-Relai "Relaybot" dans la configuration de la passerelle (default=disabled, voir ci-dessous) et ajouter l'identifiant du salon d'administration du Relaybot "Relaybot Administration Room". -* Redémarrer le service mautrix_whatsapp -* Vous pouvez maintenant relayer un groupe WhatsApp en y invitant le numéro de téléphone du compte WhatsApp connecté au RobotRelai. Côté WhatsApp, tous les messages venant de Matrix seront vus comme envoyés depuis le compte WhatsApp connecté, avec un préfix indiquant le compte Matrix correspondant. Côté Matrix, la passerelle va créer des comptes Matrix pour chaque compte WhatsApp présent dans le groupe relayé. Les messages sont indiqués comme provenant soit du numéro de téléphone, soit du pseudo WhatsApp. -Voir aussi [la page wiki principale sur le Robot-Relai](https://docs.mau.fi/bridges/go/whatsapp/relaybot.html) - -### Configuration de la passerelle - -La passerelle est [configurée avec les paramètres standards adaptés pour votre YunoHost et l'instance Matrix-Synapse sélectionnée](https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh/blob/master/conf/config.yaml). Vous pouvez par exemple ajouter des administrateur.ice.s et utilisateur.ice.s du Robot autorisés en modifiant le fichier de configuration par liaison SSH: -``` sudo nano /opt/yunohost/mautrix_whatsapp/config.yaml``` -puis en redémarrant le service: -``` sudo yunohost service restart mautrix_whatsapp``` - -#### End-to-bridge encryption -Le robot peut éventuellement chiffrer les messages entre les utilisateurs de Matrix et la passarelle pour cacher les messages du serveur domestique. L'utilisation de Postgres est fortement recommandée lors de l'utilisation du chiffrement end-to-bridge. - -Si vous voulez l'activer, cherchez l'option ```bridge → encryption``` dans le fichier de configuration. Si vous définissez uniquement l'option ``allow: true``, le robot n'activera pas le chiffrement de lui-même, mais travaillera dans les portails chiffrés. Si vous définissez ```default: true```, la passerelle activera automatiquement le chiffrement dans les nouveaux portails. -Il y a également la possibilité de définir ```require: true``` pour imposer le chiffrement sur tous les messages que vous envoyez (cela interdira tous les messages non chiffrés). - -### Support multi-comptes - -* Les utilisateur.ice.s du Robot ne sont pas liés aux comptes Yunohost. N'importe quel compte Matrix ou serveur Synapse autorisés dans la configuration de la passerelle peut inviter/utiliser le Robot. -* Le robot WhatsApp est un utilisateur Matrix-Synapse local, mais accessible via la fédération (Synapse public ou privé). -* Plusieurs comptes WhatsApp et Matrix peuvent être liés avec une seule passerelle, chaque compte 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. Autrement dit, la passerelle construit un seul miroir du réseau de discussion existant sur WhatsApp (utilisateurs et salons). -* Voir https://github.com/YunoHost-Apps/synapse_ynh#multi-users-support - -### Support multi-instance - -* L'installation multi-instance devrait fonctionner. Plusieurs instances de passerelles pourraient être installées pour une instance de Matrix-Synapse. Cela permet à un compte matrix de se relier à plusieurs comptes WhatsApp. -* Plusieurs instances de passerelles pourraient être installées pour que chaque instance de Matrix-Synapse puisse en bénéficier. Mais une passerelle peut être utilisée par les comptes de plusieurs instances Matrix-Synapse. - -### Architectures supportées - -ARM, ARM64, AMD64 - -### Limitations - -* Les appels Audio/Video ne sont pas relayés. Seule une notification apparait. -* Si WhatsApp perd la connexion, par ex. l'ordiphone est mis en mode avion ou les notifications poussées sont désactivées, le robot doit parfois être redémarré à la main en envoyant un message ``wa !reconnnect`` dans le salon d'administration. - -### Informations additionnelles - -* Il est recommandé d'installer WhatsApp sur une machine Android virtuelle tournant sur un serveur, cf. le [page Android-VM-Setup du wiki](https://docs.mau.fi/bridges/go/whatsapp/android-vm-setup.html) - -Pour tester la communication entre le Service d'Application et Matrix-Synapse sur une Machine Virtuelle (ex. avec un nom de domaine: synapse.vm), vous devez installer un certificat: -``` -echo | openssl s_client -showcerts -servername synapse.vm -connect synapse.vm:443 2>/dev/null | awk '/-----BEGIN CERTIFICATE-----/, /-----END CERTIFICATE-----/' >> /usr/local/share/ca-certificates/synapse.vm.crt -update-ca-certificates -``` - -### Informations diverses - -* Salon Matrix sur les Passerelles dans Yunohost): #mautrix_yunohost:matrix.fdn.fr -* Salon Matrix (application principale): #whatsapp:maunium.net -Si vous devez téléverser vos fichiers log quelque-part, soyez avertis qu'ils contiennent des informations sur vos contacts et vos numéros de téléphone. Effacez-les avec -``| sed -r 's/[0-9]{10,}/📞/g' `` -* La passerelle "Mautrix-WhatsApp" repose sur l'implémentation [Rhymen/go-whatsapp](https://github.com/Rhymen/go-whatsapp) du projet [sigalor/whatsapp-web-reveng](https://github.com/sigalor/whatsapp-web-reveng). - -## Development code quality - -Le script `.github/workflows/updater.sh` doit être synchronisé avec les changements dans `conf/config.yaml`, -donc un hook `pre-commit` est utilisé pour afficher un rappel pour mettre à jour -`.github/workflows/updater.sh` (si nécessaire) lorsque `conf/config.yaml` a été modifié. - -Veuillez activer les hooks Git en utilisant la commande suivante pour assurer la qualité et la stabilité du code. -``` bash -git config --local core.hooksPath .githooks -``` \ No newline at end of file diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md new file mode 100644 index 0000000..29bd0ee --- /dev/null +++ b/doc/POST_INSTALL.md @@ -0,0 +1,37 @@ +## List of known public services + +* Ask on one of the following rooms: #mautrix_yunohost:matrix.fdn.fr or #whatsapp:maunium.net + +## 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 +* 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". +* Type ``login`` +* Capture the QR code with the camera in the WhatsApp of your VM or smartphone (WhatsApp Web) +* 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 +By default, the bridge creates a portal room for each WhatsApp group that the WhatsApp user actively uses. +Your can also create a portal for an existing Matrix room. **Note that this can be a room created by another bridge, e.g. a Signal portal room** +1. Invite the bridge bot to the room (with an authorized user) +2. Type `!wa create` +3. Your logged in WA user creates a new corresponding group. +4. Get the WA invite link `!wa invite-link` and share it with friends. Or invite WhatsApp puppets to room. +5. Optional: Activate relaybot, see next section. + +### Relaybot: Bridge a group for several Matrix and several WhatsApp users to chat together + +To be able to bridge not only your logged in Matrix account but also Matrix friends you invite to a portal room, you need to: +1. Enable relaybot setting in the config panel section `Main Settings -> Puppetting Bridge Settings` or in the bridge configuration YAML file `relay: enabled: true`. Also make sure that the users you want to invite have at least the `relay` level in the `permissions` section (this can be configured in the config panel section `Main Settings -> Permissions for using the bridge`). +2. Login to your WhatsApp account in the (main) administration room +3. Depending on what has been selected during installation this could be done only by admins, but can also be changed in the config panel section `Main Settings -> Puppetting Bridge Settings` or in the bridge configuration YAML file `relay: admin_only`. +4. Write `!wa set-relay` in each of the rooms you want to relay to (re-)activate the relaybot function. + + +* In WhatsApp: all messages will be seen as received from the account who is logged in with a prefix for the source matrix user. +* On the matrix side: the bridge will create matrix puppets corresponding to the WhatsApp users when they send a message. + See also [upstream wiki Relaybot page](https://docs.mau.fi/bridges/general/relay-mode.html) \ No newline at end of file diff --git a/doc/POST_INSTALL_fr.md b/doc/POST_INSTALL_fr.md new file mode 100644 index 0000000..92a1ccc --- /dev/null +++ b/doc/POST_INSTALL_fr.md @@ -0,0 +1,24 @@ +## Liste de passerelles publiques + +* Demandez sur un des salons suivants: #mautrix_yunohost:matrix.fdn.fr or #whatsapp:maunium.net + +## 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 +* 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". +* Tapez ``login`` +* Scannez le QR-code avec la caméra Whatsapp de votre Machine Virtuelle ou ordiphone (option WhatsApp Web dans l'appli) +* Envoyez ``help`` au Robot dans le "Administration Room" pour une liste des commandes d'administration de la passerelle. + Voir aussi [upstream wiki Authentication page](https://docs.mau.fi/bridges/go/whatsapp/authentication.html) + +### Robot-Relai "Relaybot": Relayer les conversations de TOUS les comptes Matrix et TOUS les comptes WhatsApp présents dans UN groupe/salon + +1. Activer l'option `Should Relay Mode be allowed?` dans le panneau de configuration (section `Main Settings -> Puppetting Bridge Settings`) ou dans le fichier YAML de configuration du robot `relay: enabled: true`. Assurez-vous également que les utilisateurs que vous voulez inviter ont au moins le niveau `relay` dans la section `permissions` (ceci peut être configuré dans la section `Main Settings -> Permissions for using the bridge` du panneau de configuration). +2. En fonction de ce qui a été sélectionné lors de l'installation, cela peut être fait uniquement par les administrateurs, mais peut également être modifié dans la section `Main Settings -> Puppetting Bridge Settings` du panneau de configuration ou dans le fichier YAML de configuration du robot `relay: admin_only` +3. Ecrivez `!wa set-relay` dans chacune des pièces que vous voulez relayer pour (ré)activer la fonction de relaybot. + +* Vous pouvez maintenant relayer un groupe WhatsApp en y invitant le numéro de téléphone du compte WhatsApp connecté au RobotRelai. Côté WhatsApp, tous les messages venant de Matrix seront vus comme envoyés depuis le compte WhatsApp connecté, avec un préfix indiquant le compte Matrix correspondant. Côté Matrix, la passerelle va créer des comptes Matrix pour chaque compte WhatsApp présent dans le groupe relayé. Les messages sont indiqués comme provenant soit du numéro de téléphone, soit du pseudo WhatsApp. + Voir aussi [la page wiki principale sur le Robot-Relai](https://docs.mau.fi/bridges/go/whatsapp/relaybot.html) \ No newline at end of file diff --git a/doc/PRE_INSTALL.md b/doc/PRE_INSTALL.md new file mode 100644 index 0000000..5d48c4e --- /dev/null +++ b/doc/PRE_INSTALL.md @@ -0,0 +1,33 @@ +## 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). +* Several WhatsApp and Matrix users can be bridged with one bridge, each user has its own bot administration room. +* 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 + +## 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. +* WhatsApp needs to get presence from the official app every two weeks at least, so bridge will send a reminder in the administration room. + +## Additional information + +* It is recommended to install WhatsApp on a virtual android running on a server, see [upstream wiki Android-VM-Setup page](https://docs.mau.fi/bridges/go/whatsapp/android-vm-setup.html) +**More information on the documentation page:** + https://docs.mau.fi/bridges/go/whatsapp/index.html + +To test communication between the App Service and Matrix-Synapse on a VM (e.g. with domain name: synapse.vm), you must install a certificate: +``` +echo | openssl s_client -showcerts -servername synapse.vm -connect synapse.vm:443 2>/dev/null | awk '/-----BEGIN CERTIFICATE-----/, /-----END CERTIFICATE-----/' >> /usr/local/share/ca-certificates/synapse.vm.crt +update-ca-certificates +``` + +## Miscellaneous information + +* Matrix room (matrix bridges in YunoHost): #mautrix_yunohost:matrix.fdn.fr +* Matrix room (upstream app): #whatsapp:maunium.net + In case you need to upload your logs somewhere, be aware that they contain your contacts' and your phone numbers. Strip them out with + ``| sed -r 's/[0-9]{10,}/📞/g' `` +* "Mautrix-WhatsApp" bridge is based on the [Rhymen/go-whatsapp](https://github.com/Rhymen/go-whatsapp) implementation of the [sigalor/whatsapp-web-reveng](https://github.com/sigalor/whatsapp-web-reveng) project. \ No newline at end of file diff --git a/doc/PRE_INSTALL_fr.md b/doc/PRE_INSTALL_fr.md new file mode 100644 index 0000000..7ee8375 --- /dev/null +++ b/doc/PRE_INSTALL_fr.md @@ -0,0 +1,31 @@ +## Support multi-comptes + +* Les utilisateur.ice.s du Robot ne sont pas liés aux comptes Yunohost. N'importe quel compte Matrix ou serveur Synapse autorisés dans la configuration de la passerelle peut inviter/utiliser le Robot. +* Le robot WhatsApp est un utilisateur Matrix-Synapse local, mais accessible via la fédération (Synapse public ou privé). +* Plusieurs comptes WhatsApp et Matrix peuvent être liés avec une seule passerelle, chaque compte 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. Autrement dit, la passerelle construit un seul miroir du réseau de discussion existant sur WhatsApp (utilisateurs et salons). +* Voir https://github.com/YunoHost-Apps/synapse_ynh#multi-users-support + +## Limitations + +* Les appels Audio/Video ne sont pas relayés. Seule une notification apparait. +* Si WhatsApp perd la connexion, par ex. l'ordiphone est mis en mode avion ou les notifications poussées sont désactivées, le robot doit parfois être redémarré à la main en envoyant un message ``wa !reconnnect`` dans le salon d'administration. +* WhatsApp doit obtenir la présence de l'application officielle toutes les deux semaines au moins, c'est pourquoi le robot enverra un rappel dans la salle d'administration. + +## Informations additionnelles + +* Il est recommandé d'installer WhatsApp sur une machine Android virtuelle tournant sur un serveur, cf. le [page Android-VM-Setup du wiki](https://docs.mau.fi/bridges/go/whatsapp/android-vm-setup.html) + +Pour tester la communication entre le Service d'Application et Matrix-Synapse sur une Machine Virtuelle (ex. avec un nom de domaine: synapse.vm), vous devez installer un certificat: +``` +echo | openssl s_client -showcerts -servername synapse.vm -connect synapse.vm:443 2>/dev/null | awk '/-----BEGIN CERTIFICATE-----/, /-----END CERTIFICATE-----/' >> /usr/local/share/ca-certificates/synapse.vm.crt +update-ca-certificates +``` + +## Informations diverses + +* Salon Matrix sur les Passerelles dans Yunohost): #mautrix_yunohost:matrix.fdn.fr +* Salon Matrix (application principale): #whatsapp:maunium.net + Si vous devez téléverser vos fichiers log quelque-part, soyez avertis qu'ils contiennent des informations sur vos contacts et vos numéros de téléphone. Effacez-les avec + ``| sed -r 's/[0-9]{10,}/📞/g' `` +* La passerelle "Mautrix-WhatsApp" repose sur l'implémentation [Rhymen/go-whatsapp](https://github.com/Rhymen/go-whatsapp) du projet [sigalor/whatsapp-web-reveng](https://github.com/sigalor/whatsapp-web-reveng). \ No newline at end of file diff --git a/scripts/backup b/scripts/backup index 2347381..251bb1b 100755 --- a/scripts/backup +++ b/scripts/backup @@ -10,14 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - true -} - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= diff --git a/scripts/install b/scripts/install index 119a545..f21790d 100755 --- a/scripts/install +++ b/scripts/install @@ -9,14 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - true -} - # Retrieve some values from selected Synapse instance and store them server_name=$(ynh_app_setting_get --app $synapse_instance --key server_name) domain=$(ynh_app_setting_get --app $synapse_instance --key domain) diff --git a/scripts/restore b/scripts/restore index 5eb36d5..405c99f 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,14 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - true -} - server_name=$(ynh_app_setting_get --app=$app --key=server_name) synapse_db_name="matrix_$synapse_instance" @@ -41,8 +33,6 @@ chown -R $app:$app "$install_dir" #================================================= ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=8 -ynh_psql_test_if_first_run -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 #================================================= diff --git a/tests.toml b/tests.toml index 2f8243c..3d1080e 100644 --- a/tests.toml +++ b/tests.toml @@ -30,9 +30,9 @@ args.botusers = "server.name" # Commits to test upgrade from # ------------------------------- -test_upgrade_from.717b32f4.name = "Upgrade from 0.4.0" +test_upgrade_from.1d57a3b.name = "Upgrade from 0.7.2" # After config panel was implemented -test_upgrade_from.fdd1e0ff.name = "Upgrade from 0.6.1" +test_upgrade_from.ede12ed.name = "Upgrade from 0.8.0" # This is an additional test suite From 4c5c2ead23b7ad063e859cfa46e5f61551921822 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Wed, 2 Aug 2023 11:10:25 +0000 Subject: [PATCH 6/7] Auto-update README --- README.md | 105 --------------------------------------------------- README_fr.md | 89 ------------------------------------------- 2 files changed, 194 deletions(-) diff --git a/README.md b/README.md index dcff677..4139d18 100644 --- a/README.md +++ b/README.md @@ -26,111 +26,6 @@ Therefore, [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh) **Shipped version:** 0.9.0~ynh1 -## Disclaimers / important information - -## List of known public services - -* Ask on one of the following rooms: #mautrix_yunohost:matrix.fdn.fr or #whatsapp:maunium.net - -## 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 -* 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". -* Type ``login`` -* Capture the QR code with the camera in the whatsapp of your VM or smartphone (WhatsApp Web) -* Send ``help`` to the bot in the created room to know how to control the bot. -See also [upstream wiki Authentication page](https://docs.mau.fi/bridges/go/whatsapp/authentication.html) - -### Bridge an existing room | Bridge Whatsapp to Signal over Matrix -By default, the bridge creates a portal room for each WA group that the WA user actively uses. -Your can also create a portal for an existing Matrix room. **Note that this can be a room created by another bridge, e.g. a Signal portal room** -1. Invite the bridge bot to the room (with an authorized user) -2. type `!wa create` -3. Your logged in WA user creates a new corresponding group. -4. Get the WA invite link `!wa invite-link` and share it with friends. Or invite Whatsapp puppets to room. -5. Optional: Activate relaybot, see next section. - -### Relaybot: Bridge a group for several Matrix and several WhatsApp users to chat together -**When upgrading from /dev/null | awk '/-----BEGIN CERTIFICATE-----/, /-----END CERTIFICATE-----/' >> /usr/local/share/ca-certificates/synapse.vm.crt -update-ca-certificates -``` - -### Miscellaneous information - - * Matrix room (matrix bridges in YunoHost): #mautrix_yunohost:matrix.fdn.fr - * Matrix room (upstream app): #whatsapp:maunium.net -In case you need to upload your logs somewhere, be aware that they contain your contacts' and your phone numbers. Strip them out with -``| sed -r 's/[0-9]{10,}/📞/g' `` - * "Mautrix-WhatsApp" bridge is based on the [Rhymen/go-whatsapp](https://github.com/Rhymen/go-whatsapp) implementation of the [sigalor/whatsapp-web-reveng](https://github.com/sigalor/whatsapp-web-reveng) project. - -## Development code quality - -The `.github/workflows/updater.sh` script needs to be synced with changes in `conf/config.yaml` therefore a `pre-commit` -hook is used to display a reminder to update `.github/workflows/updater.sh` (if needed) when `conf/config.yaml` has been modified. - -Please enable Git hooks using following command to ensure code quality and stability. -``` bash -git config --local core.hooksPath .githooks -``` ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index b3e6656..fb5b4e2 100644 --- a/README_fr.md +++ b/README_fr.md @@ -26,95 +26,6 @@ C'est pourquoi [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_y **Version incluse :** 0.9.0~ynh1 -## Avertissements / informations importantes - -## Liste de passerelles publiques - -* Demandez sur un des salons suivants: #mautrix_yunohost:matrix.fdn.fr or #whatsapp:maunium.net - -## 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 -* 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". -* Tapez ``login`` -* Scannez le QR-code avec la caméra Whatsapp de votre Machine Virtuelle ou ordiphone (option WhatsApp Web dans l'appli) -* Envoyez ``help`` au Robot dans le "Administration Room" pour une liste des commandes d'administration de la passerelle. -Voir aussi [upstream wiki Authentication page](https://docs.mau.fi/bridges/go/whatsapp/authentication.html) - -#### Robot-Relai "Relaybot": Relayer les conversations de TOUS les comptes Matrix et TOUS les comptes WhatsApp présents dans UN groupe/salon - -* Prérequis : Créer un nouveau salon vide "Relaybot Administration Room" et rechercher son identifiant. -* Activer l'option Robot-Relai "Relaybot" dans la configuration de la passerelle (default=disabled, voir ci-dessous) et ajouter l'identifiant du salon d'administration du Relaybot "Relaybot Administration Room". -* Redémarrer le service mautrix_whatsapp -* Vous pouvez maintenant relayer un groupe WhatsApp en y invitant le numéro de téléphone du compte WhatsApp connecté au RobotRelai. Côté WhatsApp, tous les messages venant de Matrix seront vus comme envoyés depuis le compte WhatsApp connecté, avec un préfix indiquant le compte Matrix correspondant. Côté Matrix, la passerelle va créer des comptes Matrix pour chaque compte WhatsApp présent dans le groupe relayé. Les messages sont indiqués comme provenant soit du numéro de téléphone, soit du pseudo WhatsApp. -Voir aussi [la page wiki principale sur le Robot-Relai](https://docs.mau.fi/bridges/go/whatsapp/relaybot.html) - -### Configuration de la passerelle - -La passerelle est [configurée avec les paramètres standards adaptés pour votre YunoHost et l'instance Matrix-Synapse sélectionnée](https://github.com/YunoHost-Apps/mautrix_whatsapp_ynh/blob/master/conf/config.yaml). Vous pouvez par exemple ajouter des administrateur.ice.s et utilisateur.ice.s du Robot autorisés en modifiant le fichier de configuration par liaison SSH: -``` sudo nano /opt/yunohost/mautrix_whatsapp/config.yaml``` -puis en redémarrant le service: -``` sudo yunohost service restart mautrix_whatsapp``` - -#### End-to-bridge encryption -Le robot peut éventuellement chiffrer les messages entre les utilisateurs de Matrix et la passarelle pour cacher les messages du serveur domestique. L'utilisation de Postgres est fortement recommandée lors de l'utilisation du chiffrement end-to-bridge. - -Si vous voulez l'activer, cherchez l'option ```bridge → encryption``` dans le fichier de configuration. Si vous définissez uniquement l'option ``allow: true``, le robot n'activera pas le chiffrement de lui-même, mais travaillera dans les portails chiffrés. Si vous définissez ```default: true```, la passerelle activera automatiquement le chiffrement dans les nouveaux portails. -Il y a également la possibilité de définir ```require: true``` pour imposer le chiffrement sur tous les messages que vous envoyez (cela interdira tous les messages non chiffrés). - -### Support multi-comptes - -* Les utilisateur.ice.s du Robot ne sont pas liés aux comptes Yunohost. N'importe quel compte Matrix ou serveur Synapse autorisés dans la configuration de la passerelle peut inviter/utiliser le Robot. -* Le robot WhatsApp est un utilisateur Matrix-Synapse local, mais accessible via la fédération (Synapse public ou privé). -* Plusieurs comptes WhatsApp et Matrix peuvent être liés avec une seule passerelle, chaque compte 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. Autrement dit, la passerelle construit un seul miroir du réseau de discussion existant sur WhatsApp (utilisateurs et salons). -* Voir https://github.com/YunoHost-Apps/synapse_ynh#multi-users-support - -### Support multi-instance - -* L'installation multi-instance devrait fonctionner. Plusieurs instances de passerelles pourraient être installées pour une instance de Matrix-Synapse. Cela permet à un compte matrix de se relier à plusieurs comptes WhatsApp. -* Plusieurs instances de passerelles pourraient être installées pour que chaque instance de Matrix-Synapse puisse en bénéficier. Mais une passerelle peut être utilisée par les comptes de plusieurs instances Matrix-Synapse. - -### Architectures supportées - -ARM, ARM64, AMD64 - -### Limitations - -* Les appels Audio/Video ne sont pas relayés. Seule une notification apparait. -* Si WhatsApp perd la connexion, par ex. l'ordiphone est mis en mode avion ou les notifications poussées sont désactivées, le robot doit parfois être redémarré à la main en envoyant un message ``wa !reconnnect`` dans le salon d'administration. - -### Informations additionnelles - -* Il est recommandé d'installer WhatsApp sur une machine Android virtuelle tournant sur un serveur, cf. le [page Android-VM-Setup du wiki](https://docs.mau.fi/bridges/go/whatsapp/android-vm-setup.html) - -Pour tester la communication entre le Service d'Application et Matrix-Synapse sur une Machine Virtuelle (ex. avec un nom de domaine: synapse.vm), vous devez installer un certificat: -``` -echo | openssl s_client -showcerts -servername synapse.vm -connect synapse.vm:443 2>/dev/null | awk '/-----BEGIN CERTIFICATE-----/, /-----END CERTIFICATE-----/' >> /usr/local/share/ca-certificates/synapse.vm.crt -update-ca-certificates -``` - -### Informations diverses - -* Salon Matrix sur les Passerelles dans Yunohost): #mautrix_yunohost:matrix.fdn.fr -* Salon Matrix (application principale): #whatsapp:maunium.net -Si vous devez téléverser vos fichiers log quelque-part, soyez avertis qu'ils contiennent des informations sur vos contacts et vos numéros de téléphone. Effacez-les avec -``| sed -r 's/[0-9]{10,}/📞/g' `` -* La passerelle "Mautrix-WhatsApp" repose sur l'implémentation [Rhymen/go-whatsapp](https://github.com/Rhymen/go-whatsapp) du projet [sigalor/whatsapp-web-reveng](https://github.com/sigalor/whatsapp-web-reveng). - -## Development code quality - -Le script `.github/workflows/updater.sh` doit être synchronisé avec les changements dans `conf/config.yaml`, -donc un hook `pre-commit` est utilisé pour afficher un rappel pour mettre à jour -`.github/workflows/updater.sh` (si nécessaire) lorsque `conf/config.yaml` a été modifié. - -Veuillez activer les hooks Git en utilisant la commande suivante pour assurer la qualité et la stabilité du code. -``` bash -git config --local core.hooksPath .githooks -``` ## Documentations et ressources * Site officiel de l’app : From 8100f90957ffa10e0684f453e690d8e98c9111f1 Mon Sep 17 00:00:00 2001 From: Dante Date: Wed, 2 Aug 2023 15:12:00 +0100 Subject: [PATCH 7/7] Fix upgrade script, config panel getters are needed --- scripts/upgrade | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 41337ef..020b6e5 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -14,6 +14,32 @@ server_name=$(ynh_app_setting_get --app=$app --key=server_name) synapse_db_name="matrix_$synapse_instance" bot_synapse_db_user="@$botname:$server_name" +#================================================= +# GET CONFIG PANEL SETTINGS +#================================================= +async_media=$(ynh_app_setting_get --app=$app --key=async_media) +displayname=$(ynh_app_setting_get --app=$app --key=displayname) +avatar=$(ynh_app_setting_get --app=$app --key=avatar) +ephemeral_events=$(ynh_app_setting_get --app=$app --key=ephemeral_events) +enable_metrics=$(ynh_app_setting_get --app=$app --key=enable_metrics) +listen_port=$(ynh_app_setting_get --app=$app --key=listen_port) +os_name=$(ynh_app_setting_get --app=$app --key=os_name) +browser_name=$(ynh_app_setting_get --app=$app --key=browser_name) +username_template=$(ynh_app_setting_get --app=$app --key=username_template) +personal_filtering_spaces=$(ynh_app_setting_get --app=$app --key=personal_filtering_spaces) +delivery_receipts=$(ynh_app_setting_get --app=$app --key=delivery_receipts) +send_presence_on_typing=$(ynh_app_setting_get --app=$app --key=send_presence_on_typing) +url_previews=$(ynh_app_setting_get --app=$app --key=url_previews) +encryption_default=$(ynh_app_setting_get --app=$app --key=encryption_default) +encryption_require=$(ynh_app_setting_get --app=$app --key=encryption_require) +enable_relaybot=$(ynh_app_setting_get --app=$app --key=enable_relaybot) +admin_only=$(ynh_app_setting_get --app=$app --key=admin_only) +print_level=$(ynh_app_setting_get --app=$app --key=print_level) + +listrelay=$(ynh_app_setting_get --app=$app --key=listrelay) +listuser=$(ynh_app_setting_get --app=$app --key=listuser) +listadmin=$(ynh_app_setting_get --app=$app --key=listadmin) + #================================================= # CHECK VERSION #=================================================