1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/synapse_ynh.git synced 2024-09-03 20:26:38 +02:00
synapse_ynh/scripts/install

99 lines
2.9 KiB
Text
Raw Normal View History

2017-02-13 20:43:41 +01:00
#!/bin/bash
# Source YunoHost helpers
source /usr/share/yunohost/helpers
source ./psql.sh
# Stop script if errors
ynh_abort_if_errors
2017-02-13 20:43:41 +01:00
# Import common cmd
source ./_common.sh
# Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN
is_public=$YNH_APP_ARG_IS_PUBLIC
path="/_matrix"
final_path="/opt/yunohost/matrix-synapse"
2017-02-13 20:43:41 +01:00
# Check domain/path availability
test $(ynh_webpath_available $domain $path) == 'True' || ynh_die "$domain$path is not available, please use an other domain."
# Check Final Path availability
test ! -e "$final_path" || ynh_die "This path already contains a folder"
2017-02-13 20:43:41 +01:00
# Ouvre le port dans le firewall
2017-03-07 15:46:05 +01:00
synapse_tls_port=$(ynh_find_port 8448)
synapse_port=$(ynh_find_port 8008)
turnserver_tls_port=$(ynh_find_port 5349)
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
# Make dh cert for synapse if it not exist
test ! -e /etc/yunohost/certs/$domain/dh.pem && openssl dhparam -out /etc/yunohost/certs/$domain/dh.pem 2048 > /dev/null
2017-02-13 20:43:41 +01:00
# Find password for turnserver and database
2017-02-13 20:43:41 +01:00
turnserver_pwd=$(ynh_string_random 30)
synapse_db_pwd=$(ynh_string_random 30)
2017-02-13 20:43:41 +01:00
# Enregistre les infos dans la config YunoHost
ynh_app_setting_set $app special_domain $domain
ynh_app_setting_set $app special_path $path
ynh_app_setting_set $app final_path $final_path
ynh_app_setting_set $app synapse_version $synapse_version
ynh_app_setting_set $app synapse_db_pwd $synapse_db_pwd
2017-02-13 20:43:41 +01:00
ynh_app_setting_set $app is_public $is_public
ynh_app_setting_set $app synapse_port $synapse_port
ynh_app_setting_set $app synapse_tls_port $synapse_tls_port
ynh_app_setting_set $app turnserver_tls_port $turnserver_tls_port
ynh_app_setting_set $app turnserver_pwd $turnserver_pwd
# Install all dependances
install_dependances
2017-02-13 20:43:41 +01:00
# Create user
ynh_system_user_create $synapse_user /var/lib/matrix-synapse
2017-02-13 20:43:41 +01:00
# Create 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;"
2017-02-13 20:43:41 +01:00
# Create directory and Install synapse in virtualenv
setup_dir
install_source
2017-02-13 20:43:41 +01:00
# Open access to server without a button the home
cp ../conf/add_sso_conf.py $final_path
cp ../conf/remove_sso_conf.py $final_path
python $final_path/add_sso_conf.py
# Create systemd service
cp ../conf/default_matrix-synapse /etc/default/matrix-synapse
cp ../conf/matrix-synapse.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable matrix-synapse.service
2017-02-13 20:43:41 +01:00
# Config nginx
config_nginx
2017-02-13 20:43:41 +01:00
# Configure Synapse
config_synapse
2017-02-13 20:43:41 +01:00
# Configure Coturn
config_coturn
2017-02-13 20:43:41 +01:00
# Configure access for certificates
set_certificat_access
2017-02-13 20:43:41 +01:00
# Configuration de logrotate
ynh_use_logrotate /var/log/matrix-synapse/
2017-02-13 20:43:41 +01:00
2017-05-26 15:29:12 +02:00
# register yunohost service
yunohost service add matrix-synapse
2017-05-26 15:29:12 +02:00
2017-02-13 20:43:41 +01:00
# Recharge la configuration Nginx
systemctl restart matrix-synapse.service
systemctl restart coturn.service