2017-02-13 20:43:41 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-07-21 22:28:49 +02:00
|
|
|
# Source YunoHost helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
2017-02-13 20:43:41 +01:00
|
|
|
|
2017-07-21 22:28:49 +02:00
|
|
|
# Stop script if errors
|
|
|
|
ynh_abort_if_errors
|
2017-02-13 20:43:41 +01:00
|
|
|
|
2017-07-21 22:28:49 +02:00
|
|
|
# Import common cmd
|
|
|
|
source ../settings/scripts/_common.sh
|
|
|
|
source ../settings/scripts/psql.sh
|
2017-02-13 20:43:41 +01:00
|
|
|
|
|
|
|
# Retrieve arguments
|
2017-07-21 22:28:49 +02:00
|
|
|
domain=$(ynh_app_setting_get $app special_domain)
|
|
|
|
path=$(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)
|
2017-02-13 20:43:41 +01:00
|
|
|
synapse_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)
|
2017-07-21 22:28:49 +02:00
|
|
|
turnserver_pwd=$(ynh_app_setting_get $app turnserver_pwd)
|
2017-02-13 20:43:41 +01:00
|
|
|
|
2017-07-21 22:28:49 +02:00
|
|
|
# Check domain/path availability
|
|
|
|
ynh_webpath_available $domain $path || ynh_die "$domain/$path is not available, please use an other domain."
|
2017-02-13 20:43:41 +01:00
|
|
|
|
|
|
|
# Make dh cert for synapse if it not exist
|
2017-07-21 22:28:49 +02:00
|
|
|
test ! -e /etc/yunohost/certs/$domain/dh.pem && openssl dhparam -out /etc/yunohost/certs/$domain/dh.pem 2048 > /dev/null
|
2017-02-16 22:54:57 +01:00
|
|
|
|
2017-07-21 22:28:49 +02:00
|
|
|
# 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
|
2017-02-13 20:43:41 +01:00
|
|
|
|
2017-07-21 22:28:49 +02:00
|
|
|
# Install all dependances
|
|
|
|
install_dependances
|
2017-02-13 20:43:41 +01:00
|
|
|
|
2017-07-21 22:28:49 +02:00
|
|
|
# Create user
|
|
|
|
ynh_system_user_create $synapse_user /var/lib/matrix-synapse
|
2017-02-13 20:43:41 +01:00
|
|
|
|
2017-07-21 22:28:49 +02:00
|
|
|
# Restore all config and data
|
|
|
|
ynh_restore
|
2017-02-13 20:43:41 +01:00
|
|
|
|
2017-10-21 01:31:04 +02:00
|
|
|
# Open access to server without a button the home
|
|
|
|
python $final_path/add_sso_conf.py
|
|
|
|
|
2017-02-13 20:43:41 +01:00
|
|
|
# Configure access for certificates
|
2017-07-21 22:28:49 +02:00
|
|
|
set_certificat_access
|
|
|
|
|
|
|
|
# Restore postgresql database
|
|
|
|
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-synapse.service
|
|
|
|
|
|
|
|
# register yunohost service
|
|
|
|
yunohost service add matrix-synapse
|
2017-02-13 20:43:41 +01:00
|
|
|
|
|
|
|
# Reload webserver
|
2017-07-21 22:28:49 +02:00
|
|
|
systemctl reload nginx.service
|
|
|
|
systemctl restart matrix-synapse.service
|
|
|
|
systemctl restart coturn.service
|