Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalization from example_ynh #118

Merged
merged 16 commits into from
Oct 31, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
55 changes: 23 additions & 32 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:** 0.99.2

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

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

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%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/synapse/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/synapse%20%28Official%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%28Official%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,23 @@ 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/
- 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
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;
}
}
10 changes: 5 additions & 5 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
"name": "Synapse",
"id": "synapse",
"packaging_format": 1,
"requirements": {
"yunohost": ">= 2.7.14"
},
"description": {
"en": "Instant messaging server who use matrix",
"fr": "Un serveur de messagerie instantané basé sur matrix"
},
"version": "0.99.2~ynh1",
"version": "0.99.2~ynh2",
"url": "http://matrix.org",
"license": "Apache-2.0",
"maintainer": {
"name": "Josué Tille",
"email": "josue@tille.ch"
},
"requirements": {
"yunohost": ">= 3.5"
},
"multi_instance": true,
"services": [
"nginx"
Expand All @@ -38,7 +38,7 @@
"en": "Is it a public server ?",
"fr": "Est-ce un serveur public ?"
},
"default": 0
"default": false
}
]
}
Expand Down
79 changes: 49 additions & 30 deletions scripts/backup
Original file line number Diff line number Diff line change
Expand Up @@ -6,83 +6,102 @@
# 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" --is_big

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

ynh_backup "/var/log/matrix-$app"
ynh_backup --src_path="/var/log/matrix-$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