mirror of
https://github.com/YunoHost-Apps/synapse_ynh.git
synced 2024-09-03 20:26:38 +02:00
2473f90c5c
- Add multi instance support - Remove offical helper in common.sh - Improve turnserver config - Update checkprocess - Check synapse is fully started before the end script - Use helper nginx ynh_add_nginx_config
75 lines
2.3 KiB
Bash
75 lines
2.3 KiB
Bash
#!/bin/bash
|
|
|
|
# Source YunoHost helpers
|
|
source /usr/share/yunohost/helpers
|
|
|
|
# Stop script if errors
|
|
ynh_abort_if_errors
|
|
|
|
# Import common cmd
|
|
source ../settings/scripts/_common.sh
|
|
source ../settings/scripts/psql.sh
|
|
|
|
# Retrieve arguments
|
|
domain=$(ynh_app_setting_get $app special_domain)
|
|
path_url=$(ynh_app_setting_get $app special_path)
|
|
final_path=$(ynh_app_setting_get $app final_path)
|
|
synapse_db_pwd=$(ynh_app_setting_get $app synapse_db_pwd)
|
|
is_public=$(ynh_app_setting_get $app is_public)
|
|
port=$(ynh_app_setting_get $app synapse_port)
|
|
synapse_tls_port=$(ynh_app_setting_get $app synapse_tls_port)
|
|
turnserver_tls_port=$(ynh_app_setting_get $app turnserver_tls_port)
|
|
turnserver_alt_tls_port=$(ynh_app_setting_get $app turnserver_alt_tls_port)
|
|
turnserver_pwd=$(ynh_app_setting_get $app turnserver_pwd)
|
|
|
|
# Check domain/path availability
|
|
ynh_webpath_available $domain $path_url || ynh_die "$domain/$path_url is not available, please use an other domain."
|
|
|
|
# Ouvre le port dans le firewall
|
|
yunohost firewall allow --no-upnp TCP $synapse_tls_port > /dev/null 2>&1
|
|
yunohost firewall allow --no-upnp Both $turnserver_tls_port > /dev/null 2>&1
|
|
yunohost firewall allow --no-upnp Both $turnserver_alt_tls_port > /dev/null 2>&1
|
|
|
|
# Install all dependances
|
|
install_dependances
|
|
|
|
# Create user
|
|
ynh_system_user_create $synapse_user /var/lib/matrix-$app
|
|
adduser $synapse_user ssl-cert
|
|
adduser turnserver ssl-cert
|
|
|
|
# Restore all config and data
|
|
ynh_restore
|
|
|
|
# Open access to server without a button the home
|
|
python $final_path/add_sso_conf.py
|
|
|
|
# Restore postgresql database
|
|
ynh_psql_test_if_first_run
|
|
ynh_psql_create_user $synapse_db_user $synapse_db_pwd
|
|
ynh_psql_execute_as_root \
|
|
"CREATE DATABASE $synapse_db_name
|
|
ENCODING 'UTF8'
|
|
LC_COLLATE='C'
|
|
LC_CTYPE='C'
|
|
template=template0
|
|
OWNER $synapse_db_user;"
|
|
su -c "psql $synapse_db_name" postgres < ${YNH_CWD}/dump.sql
|
|
|
|
# Enable systemd service
|
|
systemctl daemon-reload
|
|
systemctl enable matrix-$app.service
|
|
|
|
# Configuration de logrotate
|
|
ynh_use_logrotate /var/log/matrix-$app
|
|
|
|
# Set the permission
|
|
set_permission
|
|
|
|
# register yunohost service
|
|
yunohost service add matrix-$app
|
|
|
|
# Restart service
|
|
systemctl reload nginx.service
|
|
systemctl restart coturn-$app.service
|
|
ynh_check_starting "Synapse now listening on port 8448" "matrix-$app" "/var/log/matrix-$app/homeserver.log" 60
|