From adf335737f3a56cd4fbe6ccbdf77cba3fa2addfa Mon Sep 17 00:00:00 2001 From: Gredin67 Date: Mon, 21 Mar 2022 00:19:52 +0100 Subject: [PATCH 01/13] Update app.src --- conf/app.src | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/app.src b/conf/app.src index cf2c1fd..88d88ae 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://mau.dev/mautrix/signal/-/archive/v0.2.2/signal-v0.2.2.tar.gz -SOURCE_SUM=204b82c8540f782c0e060d95949ff7d525f2deca93154a92420fa28474beef3a +SOURCE_URL=https://mau.dev/mautrix/signal/-/archive/v0.2.3/signal-v0.2.3.tar.gz +SOURCE_SUM=a03aada5162e7524cdb21a750fd041a1128551065cb6302b1a0275bb75d380be SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true From 5e76b849e87a437c992ec9e63486a7aa44b59500 Mon Sep 17 00:00:00 2001 From: Gredin67 Date: Mon, 21 Mar 2022 00:20:35 +0100 Subject: [PATCH 02/13] Update config.yaml --- conf/config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/config.yaml b/conf/config.yaml index 3e272d8..85a2416 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -198,7 +198,7 @@ bridge: # Whether or not the provisioning API should be enabled. enabled: false # The prefix to use in the provisioning API endpoints. - prefix: /_matrix/provision/v1 + prefix: /_matrix/provision # The shared secret to authorize users of the API. # Set to "generate" to generate and save a new token. shared_secret: generate @@ -214,7 +214,7 @@ bridge: # Sent when joining a management room and the user is already logged in. welcome_connected: "Use `help` for help." # Sent when joining a management room and the user is not logged in. - welcome_unconnected: "Use `help` for help or `register` to log in." + welcome_unconnected: "Use `help` for help or `link` to log in." # Optional extra text sent when joining a management room. additional_help: "" From 994f80c4f488e7cfa5ffa17baa829834d0de90ab Mon Sep 17 00:00:00 2001 From: Gredin67 Date: Mon, 21 Mar 2022 00:22:50 +0100 Subject: [PATCH 03/13] Update manifest.json --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 2437d5f..8ab095c 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Matrix / Synapse puppeting bridge for Signal", "fr": "Passerelle Matrix / Synapse pour Signal" }, - "version": "0.2.2~ynh1", + "version": "0.2.3~ynh1", "url": "https://github.com/mautrix/signal", "license": "AGPL-3.0-or-later", "maintainer": { From 23200cbf501b3d35a14e3c372d56afd43f0dd3ef Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sun, 20 Mar 2022 23:22:52 +0000 Subject: [PATCH 04/13] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4145e34..3bc2586 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Matrix / Synapse puppeting bridge for Signal -**Shipped version:** 0.2.2~ynh1 +**Shipped version:** 0.2.3~ynh1 diff --git a/README_fr.md b/README_fr.md index 62f1d38..bd2ea5b 100644 --- a/README_fr.md +++ b/README_fr.md @@ -13,7 +13,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour Passerelle Matrix / Synapse pour Signal -**Version incluse :** 0.2.2~ynh1 +**Version incluse :** 0.2.3~ynh1 From 660cb690eb14cba0273c2a9fb706618035df4430 Mon Sep 17 00:00:00 2001 From: Gredin67 Date: Sun, 14 Aug 2022 19:56:08 +0200 Subject: [PATCH 05/13] Bullseye (#45) * libolm-dev bullseye * remove extra_dep before upgrade * do not specify signald version * Add support for end-to-bridge encryption (#37) * avoid dev headers * Upgrade mautrix-signal to v0.3.0 (#47) * set user in signald group * request yunohost 11 Co-authored-by: nathanael-h <7300309+nathanael-h@users.noreply.github.com> Co-authored-by: Mayeul Cantan Co-authored-by: yunohost-bot --- README.md | 15 +++++++-------- README_fr.md | 21 ++++++++++++--------- conf/app.src | 4 ++-- conf/signald.src | 4 ++-- manifest.json | 4 ++-- scripts/_common.sh | 2 +- scripts/install | 2 -- scripts/restore | 3 +-- scripts/upgrade | 1 - 9 files changed, 27 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 3bc2586..4749813 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ It shall NOT be edited by hand. # Matrix Signal bridge for YunoHost -[![Integration level](https://dash.yunohost.org/integration/mautrix_signal.svg)](https://dash.yunohost.org/appci/app/mautrix_signal) ![](https://ci-apps.yunohost.org/ci/badges/mautrix_signal.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mautrix_signal.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/mautrix_signal.svg)](https://dash.yunohost.org/appci/app/mautrix_signal) ![Working status](https://ci-apps.yunohost.org/ci/badges/mautrix_signal.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/mautrix_signal.maintain.svg) [![Install Matrix Signal bridge with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mautrix_signal) *[Lire ce readme en français.](./README_fr.md)* @@ -17,9 +17,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Matrix / Synapse puppeting bridge for Signal -**Shipped version:** 0.2.3~ynh1 - - +**Shipped version:** 0.3.0~ynh1 ## Disclaimers / important information @@ -99,18 +97,19 @@ In case you need to upload your logs somewhere, be aware that they contain your * Signal chats are not grouped in a Matrix community (as opposed to the Mautrix-WhatsApp or Mautrix-Facebook bridges) ## Documentation and resources -* YunoHost documentation for this app: https://yunohost.org/app_mautrix_signal -* Report a bug: https://github.com/YunoHost-Apps/mautrix_signal_ynh/issues +* YunoHost documentation for this app: +* Report a bug: ## Developer info Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/mautrix_signal_ynh/tree/testing). To try the testing branch, please proceed like that. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/mautrix_signal_ynh/tree/testing --debug or sudo yunohost app upgrade mautrix_signal -u https://github.com/YunoHost-Apps/mautrix_signal_ynh/tree/testing --debug ``` -**More info regarding app packaging:** https://yunohost.org/packaging_apps \ No newline at end of file +**More info regarding app packaging:** diff --git a/README_fr.md b/README_fr.md index bd2ea5b..f07fd7a 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,10 +1,14 @@ + + # Matrix Signal bridge pour YunoHost -[![Niveau d'intégration](https://dash.yunohost.org/integration/mautrix_signal.svg)](https://dash.yunohost.org/appci/app/mautrix_signal) ![](https://ci-apps.yunohost.org/ci/badges/mautrix_signal.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mautrix_signal.maintain.svg) +[![Niveau d'intégration](https://dash.yunohost.org/integration/mautrix_signal.svg)](https://dash.yunohost.org/appci/app/mautrix_signal) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/mautrix_signal.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/mautrix_signal.maintain.svg) [![Installer Matrix Signal bridge avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mautrix_signal) *[Read this readme in english.](./README.md)* -*[Lire ce readme en français.](./README_fr.md)* > *Ce package vous permet d'installer Matrix Signal bridge rapidement et simplement sur un serveur YunoHost. Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* @@ -13,9 +17,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour Passerelle Matrix / Synapse pour Signal -**Version incluse :** 0.2.3~ynh1 - - +**Version incluse :** 0.3.0~ynh1 ## Avertissements / informations importantes @@ -86,18 +88,19 @@ Si vous devez téléverser vos fichiers log quelque-part, soyez avertis qu'ils c ## Documentations et ressources -* Documentation YunoHost pour cette app : https://yunohost.org/app_mautrix_signal -* Signaler un bug : https://github.com/YunoHost-Apps/mautrix_signal_ynh/issues +* Documentation YunoHost pour cette app : +* Signaler un bug : ## Informations pour les développeurs Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/mautrix_signal_ynh/tree/testing). Pour essayer la branche testing, procédez comme suit. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/mautrix_signal_ynh/tree/testing --debug ou sudo yunohost app upgrade mautrix_signal -u https://github.com/YunoHost-Apps/mautrix_signal_ynh/tree/testing --debug ``` -**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps \ No newline at end of file +**Plus d'infos sur le packaging d'applications :** diff --git a/conf/app.src b/conf/app.src index 88d88ae..8b8251a 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://mau.dev/mautrix/signal/-/archive/v0.2.3/signal-v0.2.3.tar.gz -SOURCE_SUM=a03aada5162e7524cdb21a750fd041a1128551065cb6302b1a0275bb75d380be +SOURCE_URL=https://mau.dev/mautrix/signal/-/archive/v0.3.0/signal-v0.3.0.tar.gz +SOURCE_SUM=3d66cd1c27a82f964a1523acfd1a4f1ef1793815ec7730a89b26afd7e450dfd6 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/signald.src b/conf/signald.src index 86432ed..b0c641a 100644 --- a/conf/signald.src +++ b/conf/signald.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://gitlab.com/signald/signald/-/archive/0.14.1/signald-0.14.1.tar.gz -SOURCE_SUM=50343a3e4ac56da35f393d54e2a222fead5ae8448ff5a62e449805ee6b0348f8 +SOURCE_URL=https://gitlab.com/signald/signald/-/archive/0.17.0/signald-0.17.0.tar.gz +SOURCE_SUM=225e36637daccf5f01138b7e29e3b2195bced7b13a290d163e34fe1f5d4a5d2a SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 8ab095c..03ebb51 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Matrix / Synapse puppeting bridge for Signal", "fr": "Passerelle Matrix / Synapse pour Signal" }, - "version": "0.2.3~ynh1", + "version": "0.3.0~ynh1", "url": "https://github.com/mautrix/signal", "license": "AGPL-3.0-or-later", "maintainer": { @@ -15,7 +15,7 @@ "url": "https://github.com/YunoHost-Apps/mautrix_signal_ynh" }, "requirements": { - "yunohost": ">= 4.3.0" + "yunohost": ">= 11.0.0" }, "multi_instance": true, "services": [ diff --git a/scripts/_common.sh b/scripts/_common.sh index dc3f00b..d6c94cd 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="postgresql python3 python3-dev build-essential" +pkg_dependencies="postgresql python3 python3-dev build-essential libolm-dev" extra_dependencies="libunixsocket-java signald signaldctl" #================================================= # PERSONAL HELPERS diff --git a/scripts/install b/scripts/install index 39cd98b..cad2217 100755 --- a/scripts/install +++ b/scripts/install @@ -100,8 +100,6 @@ ynh_script_progression --message="Installing dependencies..." --weight=10 ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies -ynh_install_extra_app_dependencies --repo="http://http.debian.net/debian buster-backports main" --package="libolm-dev" --key="https://keyserver.ubuntu.com/pks/lookup?search=0x0E98404D386FA1D9&op=get" - ynh_script_progression --message="Installing dependencies..." --weight=10 ynh_install_extra_app_dependencies --repo="https://updates.signald.org unstable main" --package="$extra_dependencies" --key="https://updates.signald.org/apt-signing-key.asc" sleep 3 diff --git a/scripts/restore b/scripts/restore index dae47df..0ea2fb1 100755 --- a/scripts/restore +++ b/scripts/restore @@ -69,9 +69,8 @@ test ! -d $final_path || ynh_die --message="There is already a directory: $final ynh_script_progression --message="Reinstalling dependencies..." --weight=1 ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - # libolm-dev avoided by pre-compiled python-olm -ynh_install_extra_app_dependencies --repo="http://http.debian.net/debian buster-backports main" --package="libolm-dev" --key="https://keyserver.ubuntu.com/pks/lookup?search=0x0E98404D386FA1D9&op=get" + ynh_install_extra_app_dependencies --repo="https://updates.signald.org unstable main" --package="$extra_dependencies" --key="https://updates.signald.org/apt-signing-key.asc" #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index c92932b..9e6d225 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -81,7 +81,6 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=5 ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies -ynh_install_extra_app_dependencies --repo="http://http.debian.net/debian buster-backports main" --package="libolm-dev" --key="https://keyserver.ubuntu.com/pks/lookup?search=0x0E98404D386FA1D9&op=get" ynh_install_extra_app_dependencies --repo="https://updates.signald.org unstable main" --package="$extra_dependencies" --key="https://updates.signald.org/apt-signing-key.asc" #================================================= From 91165d6ac4f52a72a6b30b19d24aef4ab28a4806 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sun, 14 Aug 2022 17:58:46 +0000 Subject: [PATCH 06/13] Auto-update README --- README.md | 1 - README_fr.md | 1 - 2 files changed, 2 deletions(-) diff --git a/README.md b/README.md index bd1d6c3..4749813 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,6 @@ Matrix / Synapse puppeting bridge for Signal **Shipped version:** 0.3.0~ynh1 - ## Disclaimers / important information ## List of known public services diff --git a/README_fr.md b/README_fr.md index 63a3d4f..f07fd7a 100644 --- a/README_fr.md +++ b/README_fr.md @@ -19,7 +19,6 @@ Passerelle Matrix / Synapse pour Signal **Version incluse :** 0.3.0~ynh1 - ## Avertissements / informations importantes From 97131a023193694a309b7763104fcf49bae9eacb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 4 Sep 2022 20:47:56 +0200 Subject: [PATCH 07/13] Update check_process --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index dfb729a..f2831f3 100644 --- a/check_process +++ b/check_process @@ -5,7 +5,7 @@ # auto_remove=1 ; pre-install sudo yunohost tools update apps - sudo yunohost app install https://github.com/YunoHost-Apps/synapse_ynh/ -a "domain=$domain&server_name=$server_name&is_public=$is_public&jitsi_server=$jitsi_server" --force + sudo yunohost app install https://github.com/YunoHost-Apps/synapse_ynh/ -a "domain=$domain&server_name=$server_name&is_free_registration=$is_free_registration&jitsi_server=$jitsi_server" --force ; Manifest # mautrix_signal manifest parameters port="8449" (PORT) From d3412485995f69c6c20561bd9db8224d54ec6437 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 4 Sep 2022 22:28:27 +0200 Subject: [PATCH 08/13] Apply example_ynh --- .../ISSUE_TEMPLATE.md | 4 +- .github/PULL_REQUEST_TEMPLATE.md | 16 ++ .github/workflows/updater.sh | 107 +++++++++++ .github/workflows/updater.yml | 49 +++++ check_process | 11 +- conf/app.src | 6 +- conf/config.yaml | 17 +- doc/DESCRIPTION.md | 1 + doc/DESCRIPTION_fr.md | 4 + doc/DISCLAIMER.md | 2 +- doc/DISCLAIMER_fr.md | 1 - manifest.json | 167 +++++++++--------- pull_request_template.md | 18 -- scripts/_common.sh | 3 +- scripts/backup | 2 - scripts/install | 102 +++++------ scripts/remove | 74 ++++---- scripts/restore | 91 ++++------ scripts/upgrade | 106 +++++------ sources/extra_files/app/.gitignore | 2 - sources/patches/.gitignore | 2 - 21 files changed, 439 insertions(+), 346 deletions(-) rename issue_template.md => .github/ISSUE_TEMPLATE.md (94%) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/updater.sh create mode 100644 .github/workflows/updater.yml create mode 100644 doc/DESCRIPTION.md create mode 100644 doc/DESCRIPTION_fr.md delete mode 100644 pull_request_template.md delete mode 100644 sources/extra_files/app/.gitignore delete mode 100644 sources/patches/.gitignore diff --git a/issue_template.md b/.github/ISSUE_TEMPLATE.md similarity index 94% rename from issue_template.md rename to .github/ISSUE_TEMPLATE.md index 118148d..2729a6b 100644 --- a/issue_template.md +++ b/.github/ISSUE_TEMPLATE.md @@ -8,7 +8,7 @@ about: When creating a bug report, please use the following template to provide 1. *Read this whole template first.* 2. *Determine if you are on the right place:* - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!* - - *Otherwise, the issue may be due to mautrix_signal itself. Refer to its documentation or repository for help.* + - *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.* - *When in doubt, post here and we will figure it out together.* 3. *Delete the italic comments as you write over them below, and remove this guide.* --- @@ -31,7 +31,7 @@ about: When creating a bug report, please use the following template to provide - *If you performed a command from the CLI, the command itself is enough. For example:* ```sh - sudo yunohost app install mautrix_signal + sudo yunohost app install the_app ``` - *If you used the webadmin, please perform the equivalent command from the CLI first.* - *If the error occurs in your browser, explain what you did:* diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..ef70e18 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,16 @@ +## Problem + +- *Description of why you made this PR* + +## Solution + +- *And how do you fix that problem* + +## PR Status + +- [ ] Code finished and ready to be reviewed/tested +- [ ] The fix/enhancement were manually tested (if applicable) + +## Automatic tests + +Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization) diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh new file mode 100644 index 0000000..f3c6759 --- /dev/null +++ b/.github/workflows/updater.sh @@ -0,0 +1,107 @@ +#!/bin/bash + +#================================================= +# PACKAGE UPDATING HELPER +#================================================= + +# This script is meant to be run by GitHub Actions +# The YunoHost-Apps organisation offers a template Action to run this script periodically +# Since each app is different, maintainers can adapt its contents so as to perform +# automatic actions when a new upstream release is detected. + +#================================================= +# FETCHING LATEST RELEASE AND ITS ASSETS +#================================================= + +# Fetching information +current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') +repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') +# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) +version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) +assets="https://github.com/mautrix/signal/archive/refs/tags/$version.tar.gz" + +# Later down the script, we assume the version has only digits and dots +# Sometimes the release name starts with a "v", so let's filter it out. +# You may need more tweaks here if the upstream repository has different naming conventions. +if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then + version=${version:1} +fi + +# Setting up the environment variables +echo "Current version: $current_version" +echo "Latest release from upstream: $version" +echo "VERSION=$version" >> $GITHUB_ENV +echo "REPO=$repo" >> $GITHUB_ENV +# For the time being, let's assume the script will fail +echo "PROCEED=false" >> $GITHUB_ENV + +# Proceed only if the retrieved version is greater than the current one +if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then + echo "::warning ::No new version available" + exit 0 +# Proceed only if a PR for this new version does not already exist +elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then + echo "::warning ::A branch already exists for this update" + exit 0 +fi + +#================================================= +# UPDATE SOURCE FILES +#================================================= + +# Let's download source tarball +asset_url=$assets + +echo "Handling asset at $asset_url" + +src="app" + +# Create the temporary directory +tempdir="$(mktemp -d)" + +# Download sources and calculate checksum +filename=${asset_url##*/} +curl --silent -4 -L $asset_url -o "$tempdir/$filename" +checksum=$(sha256sum "$tempdir/$filename" | head -c 64) + +# Delete temporary directory +rm -rf $tempdir + +# Get extension +if [[ $filename == *.tar.gz ]]; then + extension=tar.gz +else + extension=${filename##*.} +fi + +# Rewrite source file +cat < conf/$src.src +SOURCE_URL=$asset_url +SOURCE_SUM=$checksum +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=$extension +SOURCE_IN_SUBDIR=true +SOURCE_FILENAME=mautrix-facebook.tar.gz +SOURCE_EXTRACT=false +EOT +echo "... conf/$src.src updated" + +#================================================= +# SPECIFIC UPDATE STEPS +#================================================= + +# Any action on the app's source code can be done. +# The GitHub Action workflow takes care of committing all changes after this script ends. + +#================================================= +# GENERIC FINALIZATION +#================================================= + +# Replace new version in manifest +echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json + +# No need to update the README, yunohost-bot takes care of it + +# The Action will proceed only if the PROCEED environment variable is set to true +echo "PROCEED=true" >> $GITHUB_ENV +exit 0 diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml new file mode 100644 index 0000000..fb72ba0 --- /dev/null +++ b/.github/workflows/updater.yml @@ -0,0 +1,49 @@ +# This workflow allows GitHub Actions to automagically update your app whenever a new upstream release is detected. +# You need to enable Actions in your repository settings, and fetch this Action from the YunoHost-Apps organization. +# This file should be enough by itself, but feel free to tune it to your needs. +# It calls updater.sh, which is where you should put the app-specific update steps. +name: Check for new upstream releases +on: + # Allow to manually trigger the workflow + workflow_dispatch: + # Run it every day at 6:00 UTC + schedule: + - cron: '0 6 * * *' +jobs: + updater: + runs-on: ubuntu-latest + steps: + - name: Fetch the source code + uses: actions/checkout@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + - name: Run the updater script + id: run_updater + run: | + # Setting up Git user + git config --global user.name 'yunohost-bot' + git config --global user.email 'yunohost-bot@users.noreply.github.com' + # Run the updater script + /bin/bash .github/workflows/updater.sh + - name: Commit changes + id: commit + if: ${{ env.PROCEED == 'true' }} + run: | + git commit -am "Upgrade to v$VERSION" + - name: Create Pull Request + id: cpr + if: ${{ env.PROCEED == 'true' }} + uses: peter-evans/create-pull-request@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: Update to version ${{ env.VERSION }} + committer: 'yunohost-bot ' + author: 'yunohost-bot ' + signoff: false + base: testing + branch: ci-auto-update-v${{ env.VERSION }} + delete-branch: true + title: 'Upgrade to version ${{ env.VERSION }}' + body: | + Upgrade to v${{ env.VERSION }} + draft: false diff --git a/check_process b/check_process index f2831f3..66929a0 100644 --- a/check_process +++ b/check_process @@ -1,13 +1,9 @@ -# See here for more information -# https://github.com/YunoHost/package_check#syntax-of-check_process - ;; Test complet # auto_remove=1 ; 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 - # mautrix_signal manifest parameters port="8449" (PORT) synapsenumber="1" botname="signalbot" @@ -23,15 +19,12 @@ setup_public=0 upgrade=1 # upgrade=1 from_commit=fc1ba62e6529bb529a413d5895398baa5f2029d7 + # 0.2.3~ynh1 + upgrade=1 from_commit=40c16d3c8898196c6e1a43e8f0af70c052dd41f6 backup_restore=1 multi_instance=1 port_already_use=1 change_url=0 actions=0 config_panel=0 -#;;; Levels -# # If the level 5 (Package linter) is forced to 1. Please add justifications here. -# Level 5=auto ;;; Upgrade options -# ; commit=fc1ba62e6529bb529a413d5895398baa5f2029d7 -# name=0.2.0 diff --git a/conf/app.src b/conf/app.src index 8b8251a..e6ca9ea 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,7 +1,7 @@ -SOURCE_URL=https://mau.dev/mautrix/signal/-/archive/v0.3.0/signal-v0.3.0.tar.gz -SOURCE_SUM=3d66cd1c27a82f964a1523acfd1a4f1ef1793815ec7730a89b26afd7e450dfd6 +SOURCE_URL=https://github.com/mautrix/signal/archive/refs/tags/v0.3.0.tar.gz +SOURCE_SUM=ea1ed7848dbb8cbb947d441a01f6f0c8fad0791601d6e36d90c3e50cbade30d3 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true +SOURCE_FILENAME=mautrix-signal.tar.gz SOURCE_EXTRACT=false -#SOURCE_FILENAME=mautrix-signal.tar.gz diff --git a/conf/config.yaml b/conf/config.yaml index 85a2416..666cdd7 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -7,6 +7,9 @@ homeserver: # Whether or not to verify the SSL certificate of the homeserver. # Only applies if address starts with https:// verify_ssl: true + # Whether or not the homeserver supports asmux-specific endpoints, + # such as /_matrix/client/unstable/net.maunium.asmux/dms for atomically + # updating m.direct. asmux: false # Number of retries for all HTTP requests if the homeserver isn't reachable. http_retry_count: 4 @@ -138,12 +141,12 @@ bridge: # Note that updating the m.direct event is not atomic (except with mautrix-asmux) # and is therefore prone to race conditions. sync_direct_chat_list: false - # Allow using double puppeting from any server with a valid client .well-known file. - double_puppet_allow_discovery: false - # Servers to allow double puppeting from, even if double_puppet_allow_discovery is false. + # Servers to always allow double puppeting from, even if double_puppet_allow_discovery is false. double_puppet_server_map: example.com: https://example.com - # Shared secret for https://github.com/devture/matrix-synapse-shared-secret-auth + # Allow using double puppeting from any server with a valid client .well-known file. + double_puppet_allow_discovery: false + # Shared secrets for https://github.com/devture/matrix-synapse-shared-secret-auth # # If set, custom puppets will be enabled automatically for local users # instead of users having to find an access token and run `login-matrix` @@ -151,7 +154,7 @@ bridge: # If using this for other servers than the bridge's server, # you must also set the URL in the double_puppet_server_map. login_shared_secret_map: - example.com: foo + example.com: foobar # Whether or not created rooms should have federation enabled. # If false, created portal rooms will never be federated. federate_rooms: true @@ -280,9 +283,9 @@ logging: formatter: colored loggers: mau: - level: __LOG_LEVEL__ + level: INFO aiohttp: level: INFO root: - level: __LOG_LEVEL__ + level: INFO handlers: [file, console] diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..4fcdbd1 --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1 @@ +A puppeting bridge between Matrix and Signal packaged as a YunoHost service. Messages, notifications (and sometimes media) are bridged between a Signal user and a Matrix user. Currently the Matrix user can NOT invite other Matrix user in a bridged Signal room, so only someone with a Signal account can participate to Signal group conversations. The ["Mautrix-Signal"](https://docs.mau.fi/bridges/python/signal/index.html) bridge consists in a Synapse App Service and relies on postgresql (mysql also possible). Therefore, [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh) should be installed beforehand. diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md new file mode 100644 index 0000000..55baa9e --- /dev/null +++ b/doc/DESCRIPTION_fr.md @@ -0,0 +1,4 @@ +Une passerelle entre Matrix et Signal empaquetée comme un service YunoHost. Les messages, médias et notifications sont relayées entre un compte Signal et un compte Matrix. +La passerelle ["Mautrix-Signal"](https://docs.mau.fi/bridges/python/signal/index.html) consiste en un Service d'Application Matrix-Synapse et repose sur une base-de-données postgresql. C'est pourquoi [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh) doit être préalablemnet installé. + +** Attention : sauvegardez et restaurez toujours les deux applications Yunohost matrix-synapse et mautrix_signal en même temps!** diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md index 7c0f6ae..956d04e 100644 --- a/doc/DISCLAIMER.md +++ b/doc/DISCLAIMER.md @@ -71,4 +71,4 @@ In case you need to upload your logs somewhere, be aware that they contain your ## Limitations * It looks like media are not bridged. -* Signal chats are not grouped in a Matrix community (as opposed to the Mautrix-WhatsApp or Mautrix-Facebook bridges) \ No newline at end of file +* Signal chats are not grouped in a Matrix community (as opposed to the Mautrix-WhatsApp or Mautrix-Facebook bridges) diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md index d09bcb4..3bb81f8 100644 --- a/doc/DISCLAIMER_fr.md +++ b/doc/DISCLAIMER_fr.md @@ -1,4 +1,3 @@ - ## Liste de passerelles publiques * Demandez sur un des salons suivants: #mautrix_yunohost:matrix.fdn.fr or #signal:maunium.net diff --git a/manifest.json b/manifest.json index 03ebb51..75dde7e 100644 --- a/manifest.json +++ b/manifest.json @@ -1,84 +1,89 @@ { - "name": "Matrix Signal bridge", - "id": "mautrix_signal", - "packaging_format": 1, - "description": { - "en": "Matrix / Synapse puppeting bridge for Signal", - "fr": "Passerelle Matrix / Synapse pour Signal" - }, - "version": "0.3.0~ynh1", - "url": "https://github.com/mautrix/signal", - "license": "AGPL-3.0-or-later", - "maintainer": { - "name": "Gredin67", - "email": "mautrix_signal_ynh@sans-nuage.fr", - "url": "https://github.com/YunoHost-Apps/mautrix_signal_ynh" - }, - "requirements": { - "yunohost": ">= 11.0.0" - }, - "multi_instance": true, - "services": [ + "name": "Matrix Signal bridge", + "id": "mautrix_signal", + "packaging_format": 1, + "description": { + "en": "Matrix / Synapse puppeting bridge for Signal", + "fr": "Passerelle Matrix / Synapse pour Signal" + }, + "version": "0.3.0~ynh1", + "url": "https://github.com/mautrix/signal", + "upstream": { + "license": "AGPL-3.0-or-later", + "userdoc": "https://docs.mau.fi/bridges/python/signal/index.html ", + "code": "https://github.com/mautrix/signal" + }, + "license": "AGPL-3.0-or-later", + "maintainer": { + "name": "Gredin67", + "email": "mautrix_signal_ynh@sans-nuage.fr", + "url": "https://github.com/YunoHost-Apps/mautrix_signal_ynh" + }, + "requirements": { + "yunohost": ">= 11.0.0" + }, + "multi_instance": true, + "services": [ "postgresql" - ], - "arguments": { - "install": [ - { - "name": "synapsenumber", - "type": "string", - "ask": { - "en": "Choose the local synapse instance number to communicate with mautrix_signal", - "fr": "Choisissez le numéro de l'instance synapse qui doit communiquer avec mautrix_signal" - }, - "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 Signal bot", - "fr": "Choisissez un nom d'utilisateur synapse local pour le robot Signal" - }, - "example": "signalbot", - "help": { - "en": "A system user will be created. Invite @signalbot:localsynapse.servername from an authorized Matrix account to start bridging. Give the matrix server_name, not the full domain/url.", - "fr": "Un utilisateur système sera créé. Inviter @signalbot:localsynapse.servername depuis un compte Matrix autorisé pour démarrer une passerelle. Donner le nom du serveur matrix, pas le domaine/url complet." - }, - "default": "signalbot" - }, - { - "name": "botadmin", - "type": "string", - "ask": { - "en": "Choose the Matrix account administrator of the Signal bot", - "fr": "Choisissez le compte Matrix administrateur du robot Signal" - }, - "example": "@johndoe:localsynapse.servername or @johndoe:matrix.org", - "help": { - "en": "The Signal bot administrator does not need to be a local synapse account.", - "fr": "Le compte administrateur du robot Signal peut ne pas être un compte local synapse." - }, - "default": "Your main Matrix account" - }, - { - "name": "botusers", - "type": "string", - "ask": { - "en": "Choose Matrix user(s) authorized to bridge with the Signal bot", - "fr": "Choisissez le/les compte(s) Matrix autorisés à utiliser la passerelle Signal" - }, - "example": "admin or domain or @johndoe:server.name or server.name or *", - "default": "domain", - "help": { - "en": "Either the administrator only (admin), all local Synapse users (domain), a remote or local user (@johndoe:server.name), a remote server (matrix.org), or all remote/local servers (*) can be authorized. Give the Matrix server_name, not the full domain/URL.", - "fr": "L'administrateur seulement (admin), tous les comptes Synapse locaux (domain), un compte local ou distant (@johndoe:server.name), un serveur distant (matrix.org), ou tous les serveurs remote/local (*). Donner le nom du serveur Matrix, pas le domaine/URL complet." - } - } - ] - } + ], + "arguments": { + "install": [ + { + "name": "synapsenumber", + "type": "string", + "ask": { + "en": "Choose the local synapse instance number to communicate with mautrix_signal", + "fr": "Choisissez le numéro de l'instance synapse qui doit communiquer avec mautrix_signal" + }, + "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 Signal bot", + "fr": "Choisissez un nom d'utilisateur synapse local pour le robot Signal" + }, + "example": "signalbot", + "help": { + "en": "A system user will be created. Invite @signalbot:localsynapse.servername from an authorized Matrix account to start bridging. Give the matrix server_name, not the full domain/url.", + "fr": "Un utilisateur système sera créé. Inviter @signalbot:localsynapse.servername depuis un compte Matrix autorisé pour démarrer une passerelle. Donner le nom du serveur matrix, pas le domaine/url complet." + }, + "default": "signalbot" + }, + { + "name": "botadmin", + "type": "string", + "ask": { + "en": "Choose the Matrix account administrator of the Signal bot", + "fr": "Choisissez le compte Matrix administrateur du robot Signal" + }, + "example": "@johndoe:localsynapse.servername or @johndoe:matrix.org", + "help": { + "en": "The Signal bot administrator does not need to be a local synapse account.", + "fr": "Le compte administrateur du robot Signal peut ne pas être un compte local synapse." + }, + "default": "Your main Matrix account" + }, + { + "name": "botusers", + "type": "string", + "ask": { + "en": "Choose Matrix user(s) authorized to bridge with the Signal bot", + "fr": "Choisissez le/les compte(s) Matrix autorisés à utiliser la passerelle Signal" + }, + "example": "admin or domain or @johndoe:server.name or server.name or *", + "default": "domain", + "help": { + "en": "Either the administrator only (admin), all local Synapse users (domain), a remote or local user (@johndoe:server.name), a remote server (matrix.org), or all remote/local servers (*) can be authorized. Give the Matrix server_name, not the full domain/URL.", + "fr": "L'administrateur seulement (admin), tous les comptes Synapse locaux (domain), un compte local ou distant (@johndoe:server.name), un serveur distant (matrix.org), ou tous les serveurs remote/local (*). Donner le nom du serveur Matrix, pas le domaine/URL complet." + } + } + ] + } } diff --git a/pull_request_template.md b/pull_request_template.md deleted file mode 100644 index 8821801..0000000 --- a/pull_request_template.md +++ /dev/null @@ -1,18 +0,0 @@ -## Problem -- *Description of why you made this PR* - -## Solution -- *And how do you fix that problem* - -## PR Status -- [ ] Code finished. -- [ ] Tested with Package_check. -- [ ] Fix or enhancement tested. -- [ ] Upgrade from last version tested. -- [ ] Can be reviewed and tested. - -## Package_check results ---- -*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results* - -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/mautrix_signal_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/mautrix_signal_ynh%20PR-NUM-%20(USERNAME)/) diff --git a/scripts/_common.sh b/scripts/_common.sh index d6c94cd..38213d8 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,9 +4,10 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app +# dependencies used by the app (must be on a single line) pkg_dependencies="postgresql python3 python3-dev build-essential libolm-dev" extra_dependencies="libunixsocket-java signald signaldctl" + #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 5537ce1..29e1846 100755 --- a/scripts/backup +++ b/scripts/backup @@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. true } # Exit if an error occurs during the execution of the script @@ -57,7 +56,6 @@ ynh_backup --src_path="/var/log/$app" #================================================= ynh_backup --src_path="/etc/systemd/system/$app.service" -#ynh_backup --src_path="/etc/systemd/system/signald.service" #================================================= # BACKUP VARIOUS FILES diff --git a/scripts/install b/scripts/install index cad2217..556c412 100755 --- a/scripts/install +++ b/scripts/install @@ -14,7 +14,6 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. true } # Exit if an error occurs during the execution of the script @@ -24,29 +23,34 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= +synapsenumber=$YNH_APP_ARG_SYNAPSENUMBER botname=$YNH_APP_ARG_BOTNAME bot_synapse_adm=true -#encryption=$YNH_APP_ARG_ENCRYPTION encryption=false botadmin=$YNH_APP_ARG_BOTADMIN botusers=$YNH_APP_ARG_BOTUSERS + +app=$YNH_APP_INSTANCE_NAME + if [ "$botusers" == "admin" ] then botusers=$botadmin fi -synapsenumber=$YNH_APP_ARG_SYNAPSENUMBER + # ToDo check (in manifest?) if the selected synapse instance is not already connected to a mautrix_bridge bridge if [ $synapsenumber -eq "1" ] then -synapse_instance="synapse" + synapse_instance="synapse" else -synapse_instance="synapse__$synapsenumber" + synapse_instance="synapse__$synapsenumber" fi server_name=$(ynh_app_setting_get --app $synapse_instance --key server_name) domain=$(ynh_app_setting_get --app $synapse_instance --key domain) - mautrix_version=$(ynh_app_upstream_version) -app=$YNH_APP_INSTANCE_NAME +enable_relaybot=true +bot_synapse_db_user="@$botname:$server_name" +synapse_db_name="matrix_$synapse_instance" +signald_user="signald" # This is actually chosen by the signald dependency #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS @@ -55,31 +59,20 @@ ynh_script_progression --message="Validating installation parameters..." --weigh final_path=/opt/yunohost/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" -ynh_app_setting_set --app=$app --key=final_path --value=$final_path - -#================================================= -# SET CONSTANTS -#================================================= - -enable_relaybot=true -bot_synapse_db_user="@$botname:$server_name" -synapse_db_name="matrix_$synapse_instance" - -signald_user="signald" # This is actually chosen by the signald dependency #================================================= # STORE SETTINGS FROM MANIFEST #================================================= ynh_script_progression --message="Storing installation settings..." --weight=7 -ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=server_name --value=$server_name ynh_app_setting_set --app=$app --key=botname --value=$botname -ynh_app_setting_set --app=$app --key=synapse_instance --value=$synapse_instance ynh_app_setting_set --app=$app --key=bot_synapse_adm --value=$bot_synapse_adm ynh_app_setting_set --app=$app --key=encryption --value=$encryption ynh_app_setting_set --app=$app --key=botadmin --value=$botadmin ynh_app_setting_set --app=$app --key=botusers --value=$botusers +ynh_app_setting_set --app=$app --key=synapse_instance --value=$synapse_instance +ynh_app_setting_set --app=$app --key=server_name --value=$server_name +ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=mautrix_version --value=$mautrix_version #================================================= @@ -113,7 +106,7 @@ ynh_script_progression --message="Configuring system user..." --weight=1 # Add the user to the signald group. The signald group was created when the signald # package was installed from the extra repository # resolved by https://gitlab.com/signald/signald/-/commit/278240f3f1cc40a3b444c958b68ca3d6908e98a8 -ynh_system_user_create --username=$app --groups="$signald_user" +ynh_system_user_create --username=$app --home_dir="$final_path" --groups="$signald_user" #================================================= # CREATE A POSTGRESQL DATABASE @@ -121,41 +114,36 @@ ynh_system_user_create --username=$app --groups="$signald_user" ynh_script_progression --message="Creating a PostgreSQL database..." --weight=3 db_name=$(ynh_sanitize_dbid --db_name=$app) +db_user=$db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name -db_pwd=$(ynh_string_random --length=30) -ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd +ynh_psql_setup_db --db_user=$db_user --db_name=$db_name +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=3 +ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path/src" + chmod 750 "$final_path" -chown $app:$app "$final_path" - -#================================================= -# ADD A CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring Mautrix Bridge..." --weight=2 - -# https://docs.python.org/3.6/library/logging.html#logging-levels -log_level="INFO" - -ynh_add_config --template="../conf/config.yaml" --destination="$final_path/config.yaml" -chmod -R 750 "$final_path" +chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" #================================================= -# SETUP SYSTEMD +# SPECIFIC SETUP #================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=3 +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." --weight=2 -# Create a dedicated systemd config -ynh_add_systemd_config +ynh_add_config --template="../conf/config.yaml" --destination="$final_path/config.yaml" + +chmod 400 "$final_path/config.yaml" +chown $app:$app "$final_path/config.yaml" #================================================= # INSTALL MAUTRIX-BRIDGE PYTHON MODULE @@ -178,20 +166,24 @@ $final_path/bin/pip3 install $final_path/src/mautrix-signal.tar.gz[metrics,e2be, #================================================= # REGISTER SYNAPSE APP-SERVICE #================================================= +ynh_script_progression --message="Registering Synapse app-service" --weight=1 $final_path/bin/python3 -m mautrix_signal -g -c $final_path/config.yaml -r /etc/matrix-$synapse_instance/app-service/$app.yaml -/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \ - || ynh_die "Synapse can't restart with the appservice configuration" +/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die "Synapse can't restart with the appservice configuration" -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= - -# Calculate and store the config file checksum into the app settings +chown -R $app:$app "$final_path" ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml" ynh_store_file_checksum --file="$final_path/config.yaml" +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Configuring a systemd service..." --weight=3 + +# Create a dedicated systemd config +ynh_add_systemd_config + #================================================= # GENERIC FINALIZATION #================================================= @@ -206,9 +198,10 @@ chmod 700 "/var/log/$app" chown -R $app:$app /var/log/$app #================================================= -# ADVERTISE SERVICE IN ADMIN PANEL +# INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 + yunohost service add $app --description="Bridging Signal and Matrix messages" --log=/var/log/$app/$app.log #================================================= @@ -217,18 +210,7 @@ yunohost service add $app --description="Bridging Signal and Matrix messages" -- ynh_script_progression --message="Starting a systemd service..." --weight=2 # Start a systemd service -sleep 2 -chown -R $app:$app "$final_path" ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" -## Wait until the synapse user is created -#sleep 30 -# # (Note that, by default, non-admins might not have your homeserver's permission to create communities.) -# if [ "$bot_synapse_adm" = true ] -# then -# ynh_psql_execute_as_root --database=$synapse_db_name --sql="UPDATE users SET admin = 1 WHERE name = ""$botname"";" -# #yunohost app action run $synapse_instance set_admin_user -a username=$botname -# fi -#ynh_systemd_action --service_name=$app --action="restart" #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index b09b96a..8a499ed 100755 --- a/scripts/remove +++ b/scripts/remove @@ -16,19 +16,15 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -server_name=$(ynh_app_setting_get --app=$app --key=server_name) -synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance) botname=$(ynh_app_setting_get --app=$app --key=botname) botadmin=$(ynh_app_setting_get --app=$app --key=botadmin) port=$(ynh_app_setting_get --app=$app --key=port) +synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance) +server_name=$(ynh_app_setting_get --app=$app --key=server_name) +domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name final_path=$(ynh_app_setting_get --app=$app --key=final_path) - -#================================================= -# SET CONSTANTS -#================================================= - synapse_db_name="matrix_$synapse_instance" bot_synapse_db_user="@$botname:$server_name" signald_data="/var/lib/signald" @@ -38,13 +34,13 @@ signald_user="signald" #================================================= # STANDARD REMOVE #================================================= -# REMOVE SERVICE FROM ADMIN PANEL +# REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -# Remove a service from the admin panel, added by `yunohost service add` +# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) if ynh_exec_warn_less yunohost service status $app >/dev/null then - ynh_script_progression --message="Removing $app service..." --weight=3 + ynh_script_progression --message="Removing $app service integration..." --weight=3 yunohost service remove $app fi @@ -56,22 +52,29 @@ ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_systemd_config +#================================================= +# REMOVE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Removing logrotate configuration..." --weight=1 + +# Remove the app-specific logrotate config +ynh_remove_logrotate + #================================================= # REMOVE THE POSTGRESQL DATABASE #================================================= ynh_script_progression --message="Removing the PostgreSQL database..." --weight=4 # Remove a database if it exists, along with the associated user -ynh_psql_remove_db --db_user=$db_name --db_name=$db_name -ynh_psql_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 OWNED BY ""$bot_synapse_db_user"";" -ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP USER ""$bot_synapse_db_user"";" -ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP OWNED BY ""$botname"";" -ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP USER ""$botname"";" -ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP OWNED BY ""$signald_user"";" -ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP USER ""$signald_user"";" -#yunohost app action run $synapse_instance drop_user -a username=$botname +ynh_psql_remove_db --db_user=$db_user --db_name=$db_name + +#================================================= +# 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 @@ -81,34 +84,19 @@ ynh_script_progression --message="Removing dependencies..." --weight=8 # Remove metapackage and its dependencies ynh_remove_app_dependencies -#================================================= -# REMOVE APP MAIN DIR -#================================================= -ynh_script_progression --message="Removing app main directory..." --weight=1 - -# Remove the app directory securely -ynh_secure_remove --file="$signald_data" -ynh_secure_remove --file="$signald_exe" -ynh_secure_remove --file="$final_path" - -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." --weight=1 - -# Remove the app-specific logrotate config -ynh_remove_logrotate - #================================================= # SPECIFIC REMOVE #================================================= -ynh_script_progression --message="Removing synapse app service..." --weight=6 +# REMOVE VARIOUS FILES +#================================================= +ynh_script_progression --message="Removing various files..." --weight=6 + +ynh_secure_remove --file="$signald_data" +ynh_secure_remove --file="$signald_exe" # Remove a directory securely ynh_secure_remove --file="/etc/matrix-$synapse_instance/app-service/$app.yaml" - -/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \ - || ynh_die "Synapse can't restart with the appservice configuration" +/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die "Synapse can't restart with the appservice configuration" # Remove the log files ynh_secure_remove --file="/var/log/$app" diff --git a/scripts/restore b/scripts/restore index 0ea2fb1..c679d2f 100755 --- a/scripts/restore +++ b/scripts/restore @@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - #### Remove this function if there's nothing to clean before calling the remove script. true } # Exit if an error occurs during the execution of the script @@ -29,7 +28,8 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) -domain=$(ynh_app_setting_get --app=$app --key=domain) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name server_name=$(ynh_app_setting_get --app=$app --key=server_name) botname=$(ynh_app_setting_get --app=$app --key=botname) synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance) @@ -39,31 +39,46 @@ botusers=$(ynh_app_setting_get --app=$app --key=botusers) botadmin=$(ynh_app_setting_get --app=$app --key=botadmin) previous_mautrix_version=$(ynh_app_setting_get --app=$app --key=mautrix_version) port=$(ynh_app_setting_get --app=$app --key=port) - -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) - mautrix_version=$(ynh_app_upstream_version) - -#================================================= -# SET CONSTANTS -#================================================= - synapse_db_name="matrix_$synapse_instance" bot_synapse_db_user="@$botname:$server_name" signald_data="/var/lib/signald" #signald_exe="/usr/bin/signald" +signald_user="signald" # This is actually chosen by the signald dependency #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= ynh_script_progression --message="Validating restoration parameters..." --weight=1 -test ! -d $final_path || ynh_die --message="There is already a directory: $final_path " +test ! -d $final_path \ + || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS #================================================= +# 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" --groups="$signald_user" + +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= +ynh_script_progression --message="Restoring the app main directory..." --weight=1 + +ynh_restore_file --origin_path="$final_path" + +chmod 750 "$final_path" +chown $app:$app "$final_path" +chmod -R 750 "$final_path" +chown -R $app:$app "$final_path" + +#================================================= +# SPECIFIC RESTORATION +#================================================= # REINSTALL DEPENDENCIES #================================================= ynh_script_progression --message="Reinstalling dependencies..." --weight=1 @@ -73,43 +88,16 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_install_extra_app_dependencies --repo="https://updates.signald.org unstable main" --package="$extra_dependencies" --key="https://updates.signald.org/apt-signing-key.asc" -#================================================= -# 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 - -#================================================= -# RESTORE THE APP MAIN DIR -#================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=1 - -ynh_restore_file --origin_path="$final_path" - -#================================================= -# RESTORE USER RIGHTS -#================================================= - -# Restore permissions on app files -chmod 750 "$final_path" -chown $app:$app "$final_path" -chmod -R 750 "$final_path" -chown -R $app:$app "$final_path" - #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=8 ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name -#ynh_psql_execute_as_root --sql="CREATE DATABASE ""$db_name"" ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER ""$dbname"";" -#================================================= -# SPECIFIC RESTORATION #================================================= # RESTORE MAUTRIX-BRIDGE PYTHON MODULE #================================================= @@ -129,8 +117,15 @@ $final_path/bin/pip3 install --upgrade pip setuptools wheel #================================================= $final_path/bin/python3 -m mautrix_signal -g -c $final_path/config.yaml -r /etc/matrix-$synapse_instance/app-service/$app.yaml -/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \ - || ynh_die "Synapse can't restart with the appservice configuration" +/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die "Synapse can't restart with the appservice configuration" + +#================================================= +# RESTORE VARIOUS FILES +#================================================= + +ynh_systemd_action --service_name=signald --action="stop" +ynh_restore_file --origin_path="$signald_data" +ynh_systemd_action --service_name=signald --action="start" #================================================= # RESTORE SYSTEMD @@ -143,6 +138,7 @@ systemctl enable $app.service --quiet #================================================= # RESTORE THE LOGROTATE CONFIGURATION #================================================= +ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 ynh_use_logrotate chmod -R 600 "/var/log/$app" @@ -156,20 +152,11 @@ ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add $app --description="Bridging Signal and Matrix messages" --log="/var/log/$app/$app.log" -#================================================= -# RESTORE VARIOUS FILES -#================================================= - -ynh_systemd_action --service_name=signald --action="stop" -ynh_restore_file --origin_path="$signald_data" -ynh_systemd_action --service_name=signald --action="start" - #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -# Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" # Wait until the synapse user is created sleep 30 diff --git a/scripts/upgrade b/scripts/upgrade index 9e6d225..f143a25 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -16,38 +16,28 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -server_name=$(ynh_app_setting_get --app=$app --key=server_name) -port=$(ynh_app_setting_get --app=$app --key=port) botname=$(ynh_app_setting_get --app=$app --key=botname) -synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance) encryption=$(ynh_app_setting_get --app=$app --key=encryption) -botusers=$(ynh_app_setting_get --app=$app --key=botusers) botadmin=$(ynh_app_setting_get --app=$app --key=botadmin) +botusers=$(ynh_app_setting_get --app=$app --key=botusers) +domain=$(ynh_app_setting_get --app=$app --key=domain) final_path=$(ynh_app_setting_get --app=$app --key=final_path) previous_mautrix_version=$(ynh_app_setting_get --app=$app --key=mautrix_version) - db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) - +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) mautrix_version=$(ynh_app_upstream_version) -signald_user="signald" # This is actually chosen by the signald dependency - -#================================================= -# SET CONSTANTS -#================================================= - -enable_relaybot=true -# https://docs.python.org/3.6/library/logging.html#logging-levels -log_level="INFO" -#log_format="$app.log" - synapse_db_name="matrix_$synapse_instance" -bot_synapse_db_user="@$botname:$server_name" +signald_user="signald" # This is actually chosen by the signald dependency +enable_relaybot=true #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." --weight=1 upgrade_type=$(ynh_check_app_version_changed) @@ -72,16 +62,7 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="stop" - -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=5 - -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - -ynh_install_extra_app_dependencies --repo="https://updates.signald.org unstable main" --package="$extra_dependencies" --key="https://updates.signald.org/apt-signing-key.asc" +ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -115,7 +96,7 @@ chmod -R g+rwX /var/lib/signald/{avatars,attachments,stickers} ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 # Create a dedicated user (if not existing) -ynh_system_user_create --username=$app +ynh_system_user_create --username=$app --home_dir="$final_path" --groups="$signald_user" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -127,34 +108,31 @@ then # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path/src" - chmod 750 $final_path - chown $app:$app $final_path fi -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= -### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. -### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. -ynh_backup_if_checksum_is_different --file="$final_path/config.yaml" -ynh_backup_if_checksum_is_different --file="/etc/matrix-$synapse_instance/app-service/$app.yaml" - -#================================================= -# UPDATE CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring Mautrix Bridge..." --weight=2 - -ynh_add_config --template="../conf/config.yaml" --destination="$final_path/config.yaml" -chmod -R 750 "$final_path" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" -#================================================ -# SETUP SYSTEMD #================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --weight=4 +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --weight=5 -# Create a dedicated systemd config -ynh_add_systemd_config +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +ynh_install_extra_app_dependencies --repo="https://updates.signald.org unstable main" --package="$extra_dependencies" --key="https://updates.signald.org/apt-signing-key.asc" + +#================================================= +# SPECIFIC UPGRADE +#================================================= +# UPDATE A CONFIG FILE +#================================================= +ynh_script_progression --message="Updating a configuration file..." --weight=2 + +ynh_add_config --template="../conf/config.yaml" --destination="$final_path/config.yaml" + +chmod 400 "$final_path/config.yaml" +chown $app:$app "$final_path/config.yaml" #================================================= # UPGRADE MAUTRIX-BRIDGE PYTHON MODULE @@ -179,17 +157,22 @@ $final_path/bin/pip3 install --upgrade $final_path/src/mautrix-signal.tar.gz[met #================================================= $final_path/bin/python3 -m mautrix_signal -g -c $final_path/config.yaml -r /etc/matrix-$synapse_instance/app-service/$app.yaml -/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \ - || ynh_die "Synapse can't restart with the appservice configuration" - -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= +/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die "Synapse can't restart with the appservice configuration" # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum --file="$final_path/config.yaml" ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml" +chown -R $app:$app "$final_path" + +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Upgrading systemd configuration..." --weight=4 + +# Create a dedicated systemd config +ynh_add_systemd_config + #================================================= # GENERIC FINALIZATION #================================================= @@ -197,7 +180,7 @@ ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.y #================================================= ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 -# Use logrotate to manage application logfile(s) +# Use logrotate to manage app-specific logfile(s) ynh_use_logrotate chmod -R 600 "/var/log/$app" chmod 700 "/var/log/$app" @@ -215,8 +198,7 @@ yunohost service add $app --description="Bridging Signal and Matrix messages" -- #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -sleep 2 -chown -R $app:$app "$final_path" +# Start a systemd service ynh_systemd_action --service_name=$app --action="start" #================================================= diff --git a/sources/extra_files/app/.gitignore b/sources/extra_files/app/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/sources/extra_files/app/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op] diff --git a/sources/patches/.gitignore b/sources/patches/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/sources/patches/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op] From a470282799d7473b6cada1732560f379c1f84791 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 4 Sep 2022 23:58:20 +0200 Subject: [PATCH 09/13] More example_ynh --- .github/workflows/updater.sh | 2 +- doc/DESCRIPTION_fr.md | 6 +++--- manifest.json | 2 +- scripts/backup | 2 +- scripts/install | 17 ++++------------- scripts/remove | 5 +---- scripts/restore | 26 +++++++++----------------- scripts/upgrade | 22 +++++++--------------- 8 files changed, 27 insertions(+), 55 deletions(-) diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh index f3c6759..f1b3108 100644 --- a/.github/workflows/updater.sh +++ b/.github/workflows/updater.sh @@ -18,7 +18,7 @@ current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') # Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) -assets="https://github.com/mautrix/signal/archive/refs/tags/$version.tar.gz" +assets="https://github.com/$repo/archive/refs/tags/$version.tar.gz" # Later down the script, we assume the version has only digits and dots # Sometimes the release name starts with a "v", so let's filter it out. diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md index 55baa9e..b338f91 100644 --- a/doc/DESCRIPTION_fr.md +++ b/doc/DESCRIPTION_fr.md @@ -1,4 +1,4 @@ -Une passerelle entre Matrix et Signal empaquetée comme un service YunoHost. Les messages, médias et notifications sont relayées entre un compte Signal et un compte Matrix. -La passerelle ["Mautrix-Signal"](https://docs.mau.fi/bridges/python/signal/index.html) consiste en un Service d'Application Matrix-Synapse et repose sur une base-de-données postgresql. C'est pourquoi [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh) doit être préalablemnet installé. +Une passerelle entre Matrix et Signal empaquetée comme un service YunoHost. Les messages, médias et notifications sont relayées entre un compte Signal et un compte Matrix. +La passerelle ["Mautrix-Signal"](https://docs.mau.fi/bridges/python/signal/index.html) consiste en un Service d'Application Matrix-Synapse et repose sur une base-de-données postgresql. C'est pourquoi [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh) doit être préalablemnet installé. -** Attention : sauvegardez et restaurez toujours les deux applications Yunohost matrix-synapse et mautrix_signal en même temps!** +** Attention : sauvegardez et restaurez toujours les deux applications Yunohost matrix-synapse et mautrix_signal en même temps!** diff --git a/manifest.json b/manifest.json index 75dde7e..c77198b 100644 --- a/manifest.json +++ b/manifest.json @@ -10,7 +10,7 @@ "url": "https://github.com/mautrix/signal", "upstream": { "license": "AGPL-3.0-or-later", - "userdoc": "https://docs.mau.fi/bridges/python/signal/index.html ", + "userdoc": "https://docs.mau.fi/bridges/python/signal/index.html", "code": "https://github.com/mautrix/signal" }, "license": "AGPL-3.0-or-later", diff --git a/scripts/backup b/scripts/backup index 29e1846..15cfb27 100755 --- a/scripts/backup +++ b/scripts/backup @@ -49,7 +49,7 @@ ynh_backup --src_path="$final_path" # BACKUP LOGROTATE #================================================= -ynh_backup --src_path="/var/log/$app" +ynh_backup --src_path="/etc/logrotate.d/$app" #================================================= # BACKUP SYSTEMD diff --git a/scripts/install b/scripts/install index 556c412..2a79b5c 100755 --- a/scripts/install +++ b/scripts/install @@ -92,8 +92,6 @@ ynh_app_setting_set --app=$app --key=port --value=$port ynh_script_progression --message="Installing dependencies..." --weight=10 ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - -ynh_script_progression --message="Installing dependencies..." --weight=10 ynh_install_extra_app_dependencies --repo="https://updates.signald.org unstable main" --package="$extra_dependencies" --key="https://updates.signald.org/apt-signing-key.asc" sleep 3 @@ -148,20 +146,14 @@ chown $app:$app "$final_path/config.yaml" #================================================= # INSTALL MAUTRIX-BRIDGE PYTHON MODULE #================================================= -ynh_script_progression --message="Configuring python3 virtual environment" --weight=6 +ynh_script_progression --message="Installing Mautrix-Bridge Python Module..." --weight=6 mkdir -p /var/log/$app # Configure Mautrix-Bridge python3 -m venv $final_path export HOME=$final_path $final_path/bin/pip3 install --upgrade pip setuptools wheel - -ynh_script_progression --message="Installing Bridge with pip" --weight=6 - -# Pre-compiled python-olm to avoid libolm-dev, python3-dev -> does not work for arm -#$final_path/bin/pip3 install --upgrade python-olm --extra-index-url https://gitlab.matrix.org/api/v4/projects/27/packages/pypi/simple -# Build with libolm3 end-to-bridge encryption -$final_path/bin/pip3 install $final_path/src/mautrix-signal.tar.gz[metrics,e2be,formattednumbers,qrlink,stickers] +$final_path/bin/pip3 install --upgrade $final_path/src/mautrix-signal.tar.gz[metrics,e2be,formattednumbers,qrlink,stickers] #================================================= # REGISTER SYNAPSE APP-SERVICE @@ -169,8 +161,7 @@ $final_path/bin/pip3 install $final_path/src/mautrix-signal.tar.gz[metrics,e2be, ynh_script_progression --message="Registering Synapse app-service" --weight=1 $final_path/bin/python3 -m mautrix_signal -g -c $final_path/config.yaml -r /etc/matrix-$synapse_instance/app-service/$app.yaml - -/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die "Synapse can't restart with the appservice configuration" +/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die --message="Synapse can't restart with the appservice configuration" chown -R $app:$app "$final_path" ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml" @@ -202,7 +193,7 @@ chown -R $app:$app /var/log/$app #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="Bridging Signal and Matrix messages" --log=/var/log/$app/$app.log +yunohost service add $app --description="$app daemon for bridging Signal and Matrix messages" --log=/var/log/$app/$app.log #================================================= # START SYSTEMD SERVICE diff --git a/scripts/remove b/scripts/remove index 8a499ed..5c91fdd 100755 --- a/scripts/remove +++ b/scripts/remove @@ -17,11 +17,8 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME botname=$(ynh_app_setting_get --app=$app --key=botname) -botadmin=$(ynh_app_setting_get --app=$app --key=botadmin) -port=$(ynh_app_setting_get --app=$app --key=port) synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance) server_name=$(ynh_app_setting_get --app=$app --key=server_name) -domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name final_path=$(ynh_app_setting_get --app=$app --key=final_path) @@ -96,7 +93,7 @@ ynh_secure_remove --file="$signald_exe" # Remove a directory securely ynh_secure_remove --file="/etc/matrix-$synapse_instance/app-service/$app.yaml" -/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die "Synapse can't restart with the appservice configuration" +/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die --message="Synapse can't restart with the appservice configuration" # Remove the log files ynh_secure_remove --file="/var/log/$app" diff --git a/scripts/restore b/scripts/restore index c679d2f..a99f35b 100755 --- a/scripts/restore +++ b/scripts/restore @@ -72,8 +72,7 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$final_path" chmod 750 "$final_path" -chown $app:$app "$final_path" -chmod -R 750 "$final_path" +chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" #================================================= @@ -83,10 +82,9 @@ chown -R $app:$app "$final_path" #================================================= ynh_script_progression --message="Reinstalling dependencies..." --weight=1 +# Define and install dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies -# libolm-dev avoided by pre-compiled python-olm - -ynh_install_extra_app_dependencies --repo="https://updates.signald.org unstable main" --package="$extra_dependencies" --key="https://updates.signald.org/apt-signing-key.asc" +ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="https://updates.signald.org unstable main" --package="$extra_dependencies" --key="https://updates.signald.org/apt-signing-key.asc" #================================================= # RESTORE THE POSTGRESQL DATABASE @@ -99,22 +97,18 @@ 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 #================================================= -# RESTORE MAUTRIX-BRIDGE PYTHON MODULE +# INSTALL MAUTRIX-BRIDGE PYTHON MODULE #================================================= +ynh_script_progression --message="Installing Mautrix-Bridge Python Module..." --weight=6 -ynh_restore_file --origin_path="/var/log/$app" -#mkdir -p /var/log/$app -# Configure Mautrix-Bridge python3 -m venv $final_path export HOME=$final_path $final_path/bin/pip3 install --upgrade pip setuptools wheel -# Pre-compiled python-olm to avoid libolm-dev, python3-dev -#$final_path/bin/pip3 install --upgrade python-olm --extra-index-url https://gitlab.matrix.org/api/v4/projects/27/packages/pypi/simple - #================================================= # REGISTER SYNAPSE APP-SERVICE #================================================= +ynh_script_progression --message="Registering Synapse app-service" --weight=1 $final_path/bin/python3 -m mautrix_signal -g -c $final_path/config.yaml -r /etc/matrix-$synapse_instance/app-service/$app.yaml /opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die "Synapse can't restart with the appservice configuration" @@ -140,23 +134,21 @@ systemctl enable $app.service --quiet #================================================= ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 -ynh_use_logrotate -chmod -R 600 "/var/log/$app" -chmod 700 "/var/log/$app" -chown -R $app:$app /var/log/$app +ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="Bridging Signal and Matrix messages" --log="/var/log/$app/$app.log" +yunohost service add $app --description="$app daemon for bridging Signal and Matrix messages" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 +# Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" # Wait until the synapse user is created sleep 30 diff --git a/scripts/upgrade b/scripts/upgrade index f143a25..cfdba78 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -137,33 +137,25 @@ chown $app:$app "$final_path/config.yaml" #================================================= # UPGRADE MAUTRIX-BRIDGE PYTHON MODULE #================================================= -ynh_script_progression --message="Upgrading python3 virtual environment" --weight=6 +ynh_script_progression --message="Upgrading Mautrix-Bridge Python Module..." --weight=2 -mkdir -p /var/log/$app -# Configure Mautrix-Bridge python3 -m venv $final_path export HOME=$final_path $final_path/bin/pip3 install --upgrade pip setuptools wheel - -ynh_script_progression --message="Installing with pip" --weight=6 - -# Pre-compiled python-olm to avoid libolm-dev, python3-dev -> does not work for arm -#$final_path/bin/pip3 install --upgrade python-olm --extra-index-url https://gitlab.matrix.org/api/v4/projects/27/packages/pypi/simple -# Build with libolm3 end-to-bridge encryption $final_path/bin/pip3 install --upgrade $final_path/src/mautrix-signal.tar.gz[metrics,e2be,formattednumbers,qrlink,stickers] #================================================= # REGISTER SYNAPSE APP-SERVICE #================================================= -$final_path/bin/python3 -m mautrix_signal -g -c $final_path/config.yaml -r /etc/matrix-$synapse_instance/app-service/$app.yaml +ynh_script_progression --message="Registering Synapse app-service" --weight=1 +$final_path/bin/python3 -m mautrix_signal -g -c $final_path/config.yaml -r /etc/matrix-$synapse_instance/app-service/$app.yaml /opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh || ynh_die "Synapse can't restart with the appservice configuration" -# Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum --file="$final_path/config.yaml" -ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml" - +# Set permissions on app files chown -R $app:$app "$final_path" +ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml" +ynh_store_file_checksum --file="$final_path/config.yaml" #================================================= # SETUP SYSTEMD @@ -191,7 +183,7 @@ chown -R $app:$app /var/log/$app #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="Bridging Signal and Matrix messages" --log="/var/log/$app/$app.log" +yunohost service add $app --description="$app daemon for bridging Signal and Matrix messages" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE From 7446078c98d4394b63a7362ff08f7c8a4774be10 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sun, 4 Sep 2022 21:58:25 +0000 Subject: [PATCH 10/13] Auto-update README --- README.md | 6 +++++- README_fr.md | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4749813..abac49a 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview -Matrix / Synapse puppeting bridge for Signal +A puppeting bridge between Matrix and Signal packaged as a YunoHost service. Messages, notifications (and sometimes media) are bridged between a Signal user and a Matrix user. Currently the Matrix user can NOT invite other Matrix user in a bridged Signal room, so only someone with a Signal account can participate to Signal group conversations. The ["Mautrix-Signal"](https://docs.mau.fi/bridges/python/signal/index.html) bridge consists in a Synapse App Service and relies on postgresql (mysql also possible). Therefore, [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh) should be installed beforehand. + **Shipped version:** 0.3.0~ynh1 @@ -95,8 +96,11 @@ In case you need to upload your logs somewhere, be aware that they contain your * It looks like media are not bridged. * Signal chats are not grouped in a Matrix community (as opposed to the Mautrix-WhatsApp or Mautrix-Facebook bridges) + ## Documentation and resources +* Official user documentation: +* Upstream app code repository: * YunoHost documentation for this app: * Report a bug: diff --git a/README_fr.md b/README_fr.md index f07fd7a..8dd3e26 100644 --- a/README_fr.md +++ b/README_fr.md @@ -15,13 +15,16 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour ## Vue d'ensemble -Passerelle Matrix / Synapse pour Signal +Une passerelle entre Matrix et Signal empaquetée comme un service YunoHost. Les messages, médias et notifications sont relayées entre un compte Signal et un compte Matrix. +La passerelle ["Mautrix-Signal"](https://docs.mau.fi/bridges/python/signal/index.html) consiste en un Service d'Application Matrix-Synapse et repose sur une base-de-données postgresql. C'est pourquoi [Synapse for YunoHost](https://github.com/YunoHost-Apps/synapse_ynh) doit être préalablemnet installé. + +** Attention : sauvegardez et restaurez toujours les deux applications Yunohost matrix-synapse et mautrix_signal en même temps!** + **Version incluse :** 0.3.0~ynh1 ## Avertissements / informations importantes - ## Liste de passerelles publiques * Demandez sur un des salons suivants: #mautrix_yunohost:matrix.fdn.fr or #signal:maunium.net @@ -88,6 +91,8 @@ Si vous devez téléverser vos fichiers log quelque-part, soyez avertis qu'ils c ## Documentations et ressources +* Documentation officielle utilisateur : +* Dépôt de code officiel de l'app : * Documentation YunoHost pour cette app : * Signaler un bug : From ed3a0edfd194eb1abad116fbf874b3f4506bfa6e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 5 Sep 2022 00:02:24 +0200 Subject: [PATCH 11/13] Update restore --- scripts/restore | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index a99f35b..0f74811 100755 --- a/scripts/restore +++ b/scripts/restore @@ -62,7 +62,7 @@ test ! -d $final_path \ 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" --groups="$signald_user" +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # RESTORE THE APP MAIN DIR @@ -86,6 +86,14 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=1 ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="https://updates.signald.org unstable main" --package="$extra_dependencies" --key="https://updates.signald.org/apt-signing-key.asc" +#================================================= +# 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" --groups="$signald_user" + #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= From d435af501d955525f267257fd8e1f9297a33d011 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 5 Sep 2022 01:54:15 +0200 Subject: [PATCH 12/13] Update restore --- scripts/restore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/restore b/scripts/restore index 0f74811..43f942a 100755 --- a/scripts/restore +++ b/scripts/restore @@ -109,6 +109,8 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name #================================================= ynh_script_progression --message="Installing Mautrix-Bridge Python Module..." --weight=6 +mkdir -p /var/log/$app +# Configure Mautrix-Bridge python3 -m venv $final_path export HOME=$final_path $final_path/bin/pip3 install --upgrade pip setuptools wheel From b2c96f360b3c0cca9ea24b40e614a2bdb1ffeb39 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 5 Sep 2022 21:14:42 +0200 Subject: [PATCH 13/13] better removal --- scripts/remove | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/remove b/scripts/remove index 5c91fdd..d54e9c7 100755 --- a/scripts/remove +++ b/scripts/remove @@ -64,6 +64,14 @@ ynh_script_progression --message="Removing the PostgreSQL database..." --weight= # Remove a database if it exists, along with the associated user ynh_psql_remove_db --db_user=$db_user --db_name=$db_name +ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP OWNED BY ""$app"";" +ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP USER ""$app"";" +ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP OWNED BY ""$bot_synapse_db_user"";" +ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP USER ""$bot_synapse_db_user"";" +ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP OWNED BY ""$botname"";" +ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP USER ""$botname"";" +ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP OWNED BY ""$signald_user"";" +ynh_psql_execute_as_root --database=$synapse_db_name --sql="DROP USER ""$signald_user"";" #================================================= # REMOVE APP MAIN DIR