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

Fix some small issues and remove hardcoded version of PHP

This commit is contained in:
Josué Tille 2021-03-07 11:42:53 +01:00
parent cb7b4b87bd
commit 0f6c243f80
No known key found for this signature in database
GPG key ID: 716A6C99B04194EF
9 changed files with 52 additions and 46 deletions

View file

@ -184,7 +184,7 @@ listeners:
# will also need to give Synapse a TLS key and certificate: see the TLS section # will also need to give Synapse a TLS key and certificate: see the TLS section
# below.) # below.)
# #
- port: __TURNSERVER_TLS_PORT__ - port: __SYNAPSE_TLS_PORT__
type: http type: http
tls: true tls: true
resources: resources:

View file

@ -8,7 +8,7 @@ location __PATH__ {
location __PATH__/cas_server.php { location __PATH__/cas_server.php {
alias /var/www/__APP__/; alias /var/www/__APP__/;
fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/run/php7.0-fpm-__NAME__.sock; fastcgi_pass unix:/run/php__PHPVERSION__-fpm-__NAME__.sock;
include fastcgi_params; include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user; fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_INFO $fastcgi_path_info;

View file

@ -30,7 +30,7 @@ group = matrix-__USER__
; specific port; ; specific port;
; '/path/to/unix/socket' - to listen on a unix socket. ; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory. ; Note: This value is mandatory.
listen = /run/php7.0-fpm-__NAMETOCHANGE__.sock listen = /run/php__PHPVERSION__-fpm-__NAMETOCHANGE__.sock
; Set listen(2) backlog. A value of '-1' means unlimited. ; Set listen(2) backlog. A value of '-1' means unlimited.
; Default Value: 128 (-1 on FreeBSD and OpenBSD) ; Default Value: 128 (-1 on FreeBSD and OpenBSD)

View file

@ -120,7 +120,7 @@ ynh_add_config --template="log.yaml" --destination="/etc/matrix-$app/log.yaml"
ynh_script_progression --message="Configuring permissions..." --weight=1 ynh_script_progression --message="Configuring permissions..." --weight=1
ynh_permission_url --permission=server_api --clear_urls ynh_permission_url --permission=server_api --clear_urls
ynh_permission_url --permission=server_api --url=/_matrix --additional_urls=$server_name/.well-known/matrix \ ynh_permission_url --permission=server_api --url=$domain/_matrix --additional_urls=$server_name/.well-known/matrix \
#================================================= #=================================================
# RELOAD SERVICES # RELOAD SERVICES

View file

@ -341,10 +341,10 @@ ynh_add_config --template="../sources/update_synapse_for_appservice.sh" --destin
#================================================= #=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1 ynh_script_progression --message="Configuring permissions..." --weight=1
ynh_permission_url --permission=main --url=/_matrix/cas_server.php/login --auth_header=true ynh_permission_url --permission=main --url=$domain/_matrix/cas_server.php/login --auth_header=true
ynh_permission_update --permission=main --label="Synapse server SSO authentication" --show_tile=false --protected=true ynh_permission_update --permission=main --label="Synapse server SSO authentication" --show_tile=false --protected=true
ynh_permission_create --permission=server_api --url=/_matrix --additional_urls=$server_name/.well-known/matrix \ ynh_permission_create --permission=server_api --url=$domain/_matrix --additional_urls=$server_name/.well-known/matrix \
--label="Server access for client apps." --show_tile=false --allowed=visitors \ --label="Server access for client apps." --show_tile=false --allowed=visitors \
--auth_header=false --protected=true --auth_header=false --protected=true

View file

@ -76,13 +76,6 @@ ynh_script_progression --message="Removing dependencies" --weight=15
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_app_dependencies ynh_remove_app_dependencies
#=================================================
# SETUP SSOWAT
#=================================================
# Remove the skipped url
python3 ../conf/remove_sso_conf.py $domain $server_name
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================

View file

@ -1,21 +1,39 @@
import json import json
import sys import sys
domain = sys.argv[1]
server_name = sys.argv[2]
with open("/etc/ssowat/conf.json.persistent", "r", encoding='utf-8') as jsonFile: with open("/etc/ssowat/conf.json.persistent", "r", encoding='utf-8') as jsonFile:
data = json.load(jsonFile) data = json.load(jsonFile)
for domain in ("", sys.argv[1], sys.argv[2]): for domain in ("", sys.argv[1], sys.argv[2]):
for path in ("/_matrix", "/.well-known/matrix/", "/_matrix/cas_server.php/login"): for path in ("/_matrix", "/.well-known/matrix/", "/_matrix/cas_server.php/login"):
for l in (data["skipped_urls"],
data["protected_urls"],
data["permissions"]["custom_protected"]["uris"],
data["permissions"]["custom_skipped"]["uris"]):
url = domain + path url = domain + path
while url in l: try:
l.remove(url) uri_list = data["skipped_urls"]
while url in uri_list:
uri_list.remove(url)
except:
pass
try:
uri_list = data["protected_urls"]
while url in uri_list:
uri_list.remove(url)
except:
pass
try:
uri_list = data["permissions"]["custom_protected"]["uris"]
while url in uri_list:
uri_list.remove(url)
except:
pass
try:
uri_list = data["permissions"]["custom_skipped"]["uris"]
while url in uri_list:
uri_list.remove(url)
except:
pass
with open("/etc/ssowat/conf.json.persistent", "w", encoding='utf-8') as jsonFile: with open("/etc/ssowat/conf.json.persistent", "w", encoding='utf-8') as jsonFile:
jsonFile.write(json.dumps(data, indent=4, sort_keys=True)) jsonFile.write(json.dumps(data, indent=4, sort_keys=True))

View file

@ -73,6 +73,16 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=70
# For any update do it in all files # For any update do it in all files
ynh_install_app_dependencies $dependances ynh_install_app_dependencies $dependances
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=3
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$synapse_user --home_dir=$data_path
adduser $synapse_user ssl-cert
adduser turnserver ssl-cert
#================================================= #=================================================
# RESTORE ALL CONFIG AND DATA # RESTORE ALL CONFIG AND DATA
#================================================= #=================================================
@ -93,18 +103,6 @@ install_sources
ynh_script_progression --message="Reload fail2ban..." --weight=6 ynh_script_progression --message="Reload fail2ban..." --weight=6
ynh_systemd_action --action=restart --service_name=fail2ban ynh_systemd_action --action=restart --service_name=fail2ban
#=================================================
# SPECIFIC RESTORATION
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=3
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$synapse_user --home_dir=$data_path
adduser $synapse_user ssl-cert
adduser turnserver ssl-cert
#================================================= #=================================================
# RESTORE THE POSTGRESQL DATABASE # RESTORE THE POSTGRESQL DATABASE
#================================================= #=================================================
@ -181,14 +179,12 @@ public_ip6="$(curl ipv6.yunohost.org)" || true
turn_external_ip="" turn_external_ip=""
if [ -n "$public_ip4" ] && ynh_validate_ip4 --ip_address="$public_ip4" if [ -n "$public_ip4" ] && ynh_validate_ip4 --ip_address="$public_ip4"
then then
turn_external_ip+=" turn_external_ip+="\nexternal-ip=$public_ip4"
external-ip=$public_ip4"
fi fi
if [ -n "$public_ip6" ] && ynh_validate_ip6 --ip_address="$public_ip6" if [ -n "$public_ip6" ] && ynh_validate_ip6 --ip_address="$public_ip6"
then then
turn_external_ip+=" turn_external_ip+="\nexternal-ip=$public_ip6"
external-ip=$public_ip6"
fi fi
ynh_add_config --template="turnserver.conf" --destination="/etc/matrix-$app/coturn.conf" ynh_add_config --template="turnserver.conf" --destination="/etc/matrix-$app/coturn.conf"
@ -217,6 +213,7 @@ ynh_use_logrotate --logfile /var/log/matrix-$app
# WARNING : theses command are used in INSTALL, UPGRADE, RESTORE (3 times) # WARNING : theses command are used in INSTALL, UPGRADE, RESTORE (3 times)
# For any update do it in all files # For any update do it in all files
ynh_script_progression --message="Configuring file permission..."
chown $synapse_user:root -R $final_path chown $synapse_user:root -R $final_path
chmod 770 $final_path/Coturn_config_rotate.sh chmod 770 $final_path/Coturn_config_rotate.sh
chmod 700 $final_path/update_synapse_for_appservice.sh chmod 700 $final_path/update_synapse_for_appservice.sh
@ -264,7 +261,7 @@ ynh_send_readme_to_admin --app_message="mail_to_send" --type="restore"
#================================================= #=================================================
ynh_script_progression --message="Reloading nginx web server..." ynh_script_progression --message="Reloading nginx web server..."
systemctl reload php7.0-fpm ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================

View file

@ -338,14 +338,12 @@ public_ip6="$(curl ipv6.yunohost.org)" || true
turn_external_ip="" turn_external_ip=""
if [ -n "$public_ip4" ] && ynh_validate_ip4 --ip_address="$public_ip4" if [ -n "$public_ip4" ] && ynh_validate_ip4 --ip_address="$public_ip4"
then then
turn_external_ip+=" turn_external_ip+="\nexternal-ip=$public_ip4"
external-ip=$public_ip4"
fi fi
if [ -n "$public_ip6" ] && ynh_validate_ip6 --ip_address="$public_ip6" if [ -n "$public_ip6" ] && ynh_validate_ip6 --ip_address="$public_ip6"
then then
turn_external_ip+=" turn_external_ip+="\nexternal-ip=$public_ip6"
external-ip=$public_ip6"
fi fi
ynh_add_config --template="turnserver.conf" --destination="/etc/matrix-$app/coturn.conf" ynh_add_config --template="turnserver.conf" --destination="/etc/matrix-$app/coturn.conf"
@ -403,14 +401,14 @@ ynh_script_progression --message="Configuring permissions..." --weight=1
ynh_permission_url --permission=main --url=$domain/_matrix/cas_server.php/login --auth_header=true ynh_permission_url --permission=main --url=$domain/_matrix/cas_server.php/login --auth_header=true
ynh_permission_update --permission=main --label="Synapse server SSO authentication" --show_tile=false --protected=true ynh_permission_update --permission=main --label="Synapse server SSO authentication" --show_tile=false --protected=true
if !ynh_permission_exists --permission=server_api; then if ! ynh_permission_exists --permission=server_api; then
ynh_permission_create --permission=server_api --url=/_matrix --additional_urls=$server_name/.well-known/matrix \ ynh_permission_create --permission=server_api --url=$domain/_matrix --additional_urls=$server_name/.well-known/matrix \
--label="Server access for client apps." --show_tile=false --allowed=visitors \ --label="Server access for client apps." --show_tile=false --allowed=visitors \
--auth_header=false --protected=true --auth_header=false --protected=true
python3 remove_sso_conf_persistent.py $domain $server_name \ python3 remove_sso_conf_persistent.py $domain $server_name \
|| ynh_print_warn --message="Your file /etc/ssowat/conf.json.persistent doesn't respect the json syntax. The config file wasn't cleaned. Please clean it manually." || ynh_print_warn --message="Your file /etc/ssowat/conf.json.persistent doesn't respect the json syntax. The config file wasn't cleaned. Please clean it manually."
else else
ynh_permission_url --permission=server_api --url=/_matrix --additional_urls=$server_name/.well-known/matrix \ ynh_permission_url --permission=server_api --url=$domain/_matrix --add_url=$server_name/.well-known/matrix \
--auth_header=false --auth_header=false
ynh_permission_update --permission=server_api --label="Server access for client apps." --show_tile=false \ ynh_permission_update --permission=server_api --label="Server access for client apps." --show_tile=false \
--protected=true --protected=true