Skip to content

Commit

Permalink
Merge branch 'testing' into v1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Josue-T committed Nov 8, 2019
2 parents 07fc074 + dbfe7d3 commit 913bfea
Show file tree
Hide file tree
Showing 16 changed files with 771 additions and 1,062 deletions.
60 changes: 26 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
Synapse for YunoHost
====================
# Synapse for YunoHost

![](https://matrix.org/blog/wp-content/uploads/2015/01/logo1.png)

[![Integration level](https://dash.yunohost.org/integration/synapse.svg)](https://ci-apps.yunohost.org/jenkins/job/synapse%20%28Community%29/lastBuild/consoleFull)
[![Integration level](https://dash.yunohost.org/integration/synapse.svg)](https://dash.yunohost.org/appci/app/synapse)
[![Install Synapse with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=synapse)

> *This package allows you to install synapse quickly and simply on a YunoHost server.
> *This package allows you to install Synapse quickly and simply on a YunoHost server.
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*

Overview
--------
## Overview

Instant messaging server matrix network.

Yunohost chatroom with matrix : [https://riot.im/app/#/room/#yunohost:matrix.org](https://riot.im/app/#/room/#yunohost:matrix.org)

**Shipped version:** 1.5.1

Configuration
-------------
## Configuration

### Install for ARM arch (or slow arch)

Expand All @@ -41,11 +38,11 @@ If your server name is identical to the domain on which synapse is installed, an
If not, you may need to put the following line in the dns configuration:

```
_matrix._tcp.<yourdomain.com> <ttl> IN SRV 10 0 <port> <server.name>
_matrix._tcp.<server_name.tld> <ttl> IN SRV 10 0 <port> <domain-or-subdomain-of-synapse.tld>
```
for example
```
_matrix._tcp.example.com. 3600 IN SRV 10 0 SYNAPSE_PORT example.com.
_matrix._tcp.example.com. 3600 IN SRV 10 0 SYNAPSE_PORT synapse.example.com.
```
You need to replace SYNAPSE_PORT by the real port. This port can be obtained by the command: `yunohost app setting SYNAPSE_INSTANCE_NAME synapse_tls_port`

Expand Down Expand Up @@ -93,45 +90,33 @@ We have put some coarse mitigations into place to try to protect against this
situation, but it's still not a good practice to do it in the first place. See
https://github.com/vector-im/riot-web/issues/1977 for more details.

Documentation
-------------
## Documentation

- Official documentation: https://github.com/matrix-org/synapse
- YunoHost documentation: to be created; feel free to help!

YunoHost specific features
--------------------------
## YunoHost specific features

### Multi-users support

Supported with LDAP.

### Supported architectures

- Tested on x86_64
- Tested on ARM (with specific build)

Limitations
-----------
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/synapse%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/synapse/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/synapse%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/synapse/)
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/synapse%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/synapse/)

## Limitations

Synapse uses a lot of ressource. So on slow architecture (like small ARM board), this app could take a lot of CPU and RAM.

This app doesn't provide any real good web interface. So it's recommended to use Riot client to connect to this app. This app is available [here](https://github.com/YunoHost-Apps/riot_ynh)

Links
-----

- Report a bug: https://github.com/YunoHost-Apps/synapse_ynh/issues
- Matrix website: https://matrix.org/
- YunoHost website: https://yunohost.org/

Additional information
-----

## Additional information


Administation
-------------
## Administation

**All documentation of this section is not warranted. A bad use of command could break the app and all the data. So use these commands at your own risk.**

Expand Down Expand Up @@ -182,17 +167,24 @@ If anything fails while you are doing the upgrade please create an issue here: h

Synapse is published under the Apache License: https://github.com/matrix-org/synapse/blob/master/LICENSE

## Links

- Report a bug: https://github.com/YunoHost-Apps/synapse_ynh/issues
- Matrix website: https://matrix.org/
- Synapse repository: https://github.com/matrix-org/synapse
- YunoHost website: https://yunohost.org/

---

Developers infos
----------------

Please do your pull request to the testing branch.
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/synapse_ynh/tree/testing).

To try the testing branch, please proceed like that:

```bash
sudo yunohost app install https://github.com/YunoHost-Apps/synapse_ynh/tree/testing --verbose
sudo yunohost app install https://github.com/YunoHost-Apps/synapse_ynh/tree/testing --debug
or
sudo yunohost app upgrade synapse -u https://github.com/YunoHost-Apps/synapse_ynh/tree/testing --verbose
sudo yunohost app upgrade synapse -u https://github.com/YunoHost-Apps/synapse_ynh/tree/testing --debug
```
10 changes: 0 additions & 10 deletions check_process
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,7 @@
port_already_use=1 (8448)
change_url=0
;;; Levels
Level 1=auto
Level 2=auto
Level 3=auto
# https://github.com/YunoHost-Apps/synapse_ynh/blob/master/conf/homeserver.yaml#L443-L454
Level 4=1
Level 5=auto
Level 6=auto
Level 7=auto
Level 8=0
Level 9=0
Level 10=0
;;; Upgrade options
; commit=db374d2bff981d2660ebdac52ee77c684383c00d
name=Fix postgresql helper from old_version_for_CI_2 branch
Expand Down
11 changes: 0 additions & 11 deletions conf/armv7_jessie.src

This file was deleted.

2 changes: 1 addition & 1 deletion conf/homeserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ tls_fingerprints: []
# This is used by remote servers to connect to this server,
# e.g. matrix.org, localhost:8080, etc.
# This is also the last part of your UserID.
server_name: "__DOMAIN__"
server_name: "__SERVER_NAME__"

# When running as a daemon, the file to store the pid in
pid_file: "/var/run/matrix-__APP__.pid"
Expand Down
2 changes: 0 additions & 2 deletions conf/log.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ handlers:
class: logging.handlers.RotatingFileHandler
formatter: precise
filename: /var/log/matrix-__APP__/homeserver.log
maxBytes: 104857600
backupCount: 10
filters: [context]
level: INFO
console:
Expand Down
4 changes: 2 additions & 2 deletions conf/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
location __PATH__ {
proxy_pass http://localhost:__PORT__;
proxy_set_header X-Forwarded-For $remote_addr;

client_max_body_size 100M;
}
}
5 changes: 5 additions & 0 deletions hooks/post_cert_update
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

if [ $1 == __DOMAIN__ ]; then
systemctl restart matrix-__APP__
fi
22 changes: 16 additions & 6 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
"name": "Synapse",
"id": "synapse",
"packaging_format": 1,
"requirements": {
"yunohost": ">= 3.5.0"
},
"description": {
"en": "Instant messaging server who use matrix",
"fr": "Un serveur de messagerie instantané basé sur matrix"
Expand All @@ -16,6 +13,9 @@
"name": "Josué Tille",
"email": "josue@tille.ch"
},
"requirements": {
"yunohost": ">= 3.5"
},
"multi_instance": true,
"services": [
"nginx"
Expand All @@ -29,7 +29,17 @@
"en": "Choose a domain for Synapse",
"fr": "Choisissez un domaine pour Synapse"
},
"example": "domain.org"
"example": "synapse.domain.org"
},
{
"name": "server_name",
"type": "string",
"ask": {
"en": "If your synapse domain is a subdomain, you can choose a name for your Synapse server to have your matrix user-ids looking like @user:domain.org instead of @user:synapse.domain.org",
"fr": "Si votre domaine pour synapse est un sous-domaine, vous pouvez choisir un nom pour votre serveur Synapse afin que vos identifiants matrix soient @utilisateur:domain.org plutôt que @utilisateur:synapse.domain.org"
},
"example": "domain.org",
"default": "Same than the domain"
},
{
"name": "is_public",
Expand All @@ -38,11 +48,11 @@
"en": "Is it a public server ?",
"fr": "Est-ce un serveur public ?"
},
"default": false,
"help": {
"en": "A public server means that anybody will be able to register on this server.",
"fr": "Un serveur public signifie que n'importe qui pourra s'enregistrer sur ce serveur."
},
"default": 0
}
}
]
}
Expand Down
87 changes: 57 additions & 30 deletions scripts/backup
Original file line number Diff line number Diff line change
Expand Up @@ -6,83 +6,110 @@
# IMPORT GENERIC HELPERS
#=================================================

source ../settings/scripts/_common.sh
source ../settings/scripts/experimental_helper.sh
source /usr/share/yunohost/helpers

# Stop script if errors
ynh_abort_if_errors
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================

# Import common cmd
source ../settings/scripts/psql.sh
source ../settings/scripts/experimental_helper.sh
source ../settings/scripts/_common.sh
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors

#=================================================
# SET ALL CONSTANT
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=2

app=$YNH_APP_INSTANCE_NAME

domain=$(ynh_app_setting_get --app=$app --key=special_domain)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)

#=================================================
# SET CONSTANTS
#=================================================

synapse_user="matrix-$app"
synapse_db_name="matrix_$app"
synapse_db_user="matrix_$app"
upstream_version=$(ynh_app_upstream_version)

#=================================================
# LOAD SETTINGS
# STANDARD BACKUP STEPS
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Backing up the main app directory..." --weight=1

domain=$(ynh_app_setting_get $app special_domain)
final_path=$(ynh_app_setting_get $app final_path)
ynh_backup --src_path="$final_path"

#=================================================
# STANDARD BACKUP STEPS
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Backing up nginx web server configuration..." --weight=1

ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf"
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"

#=================================================
# BACKUP SYNAPSE CONFIG
# BACKUP THE POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Backing up the PostgreSQL database..." --weight=2

ynh_backup "/etc/matrix-$app"
ynh_psql_dump_db --database="$synapse_db_name" > ${YNH_CWD}/dump.sql

#=================================================
# BACKUP SYSTEMD
# BACKUP FAIL2BAN CONFIGURATION
#=================================================
ynh_script_progression --message="Backing up fail2ban configuration" --weight=1

ynh_backup "/etc/default/matrix-$app"
ynh_backup "/etc/systemd/system/matrix-$app.service"
ynh_backup "/etc/default/coturn-$app"
ynh_backup "/etc/systemd/system/coturn-$app.service"
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"

#=================================================
# BACKUP THE APP MAIN DIR
# SPECIFIC BACKUP
#=================================================
# BACKUP SYNAPSE CONFIG
#=================================================
ynh_script_progression --message="Backing up synapse configuration..." --weight=2

ynh_backup "$final_path" "bin"
ynh_backup --src_path="/etc/matrix-$app"

#=================================================
# BACKUP SYNAPSE DATA
# BACKUP SYSTEMD
#=================================================
ynh_script_progression --message="Backing up systemd configuration..." --weight=1

ynh_backup "/var/lib/matrix-$app" "data" 1
ynh_backup --src_path="/etc/default/matrix-$app"
ynh_backup --src_path="/etc/systemd/system/matrix-$app.service"
ynh_backup --src_path="/etc/default/coturn-$app"
ynh_backup --src_path="/etc/systemd/system/coturn-$app.service"

#=================================================
# BACKUP THE POSTGRESQL DATABASE
# BACKUP SYNAPSE DATA
#=================================================
ynh_script_progression --message="Backing up synapse data..." --weight=1

ynh_psql_dump_db "$synapse_db_name" > ${YNH_CWD}/dump.sql
ynh_backup --src_path="/var/lib/matrix-$app"

#=================================================
# BACKUP SYNAPSE LOG
#=================================================
ynh_script_progression --message="Backing up synapse log..." --weight=1

ynh_backup --src_path="/var/log/matrix-$app"

#=================================================
# BACKUP HOOKS
#=================================================
ynh_script_progression --message="Backing up synapse hook..." --weight=1

ynh_backup "/var/log/matrix-$app"
# Copy hook
ynh_backup --src_path "/etc/yunohost/hooks.d/post_cert_update/50-$app"

#=================================================
# BACKUP FAIL2BAN CONFIG
# END OF SCRIPT
#=================================================

ynh_backup "/etc/fail2ban/jail.d/$app.conf"
ynh_backup "/etc/fail2ban/filter.d/$app.conf"
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last

0 comments on commit 913bfea

Please sign in to comment.