diff --git a/conf/server_name.conf b/conf/server_name.conf new file mode 100644 index 0000000..81c3548 --- /dev/null +++ b/conf/server_name.conf @@ -0,0 +1,5 @@ +location /.well-known/matrix/server { + return 200 '{"m.server": "__DOMAIN__:443"}'; + add_header Content-Type application/json; + add_header Access-Control-Allow-Origin '*'; +} diff --git a/manifest.toml b/manifest.toml index c10149e..c86a0ac 100644 --- a/manifest.toml +++ b/manifest.toml @@ -64,6 +64,13 @@ ram.runtime = "50M" server_api.allowed = "visitors" server_api.auth_header = false server_api.protected = true + + server_client_infos.url = "__SERVER_NAME__/.well-known/matrix" + server_client_infos.label = "Server info for federation. (well-known)" + server_client_infos.show_tile = false + server_client_infos.allowed = "visitors" + server_client_infos.auth_header = false + server_client_infos.protected = true [resources.ports] main.default = 6167 diff --git a/scripts/backup b/scripts/backup index f8e82aa..92bfdc5 100755 --- a/scripts/backup +++ b/scripts/backup @@ -27,6 +27,11 @@ ynh_backup --src_path="$install_dir" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +if yunohost --output-as plain domain list | grep -q "^$server_name$" +then + ynh_backup --src_path="/etc/nginx/conf.d/${server_name}.d/${app}_server_name.conf" +fi + #================================================= # BACKUP SYSTEMD #================================================= diff --git a/scripts/install b/scripts/install index 3f58958..171fccb 100755 --- a/scripts/install +++ b/scripts/install @@ -30,6 +30,12 @@ ynh_script_progression --message="Adding system configurations related to $app.. # Create a dedicated NGINX config using the conf/nginx.conf template ynh_add_nginx_config +# Create .well-known redirection for access by federation +if yunohost --output-as plain domain list | grep -q "^$server_name$" +then + ynh_add_config --template="server_name.conf" --destination="/etc/nginx/conf.d/${server_name}.d/${app}_server_name.conf" +fi + # Create a dedicated systemd config ynh_add_systemd_config diff --git a/scripts/remove b/scripts/remove index dda87b5..4a52fca 100755 --- a/scripts/remove +++ b/scripts/remove @@ -29,6 +29,9 @@ ynh_remove_systemd_config ynh_remove_nginx_config +# Remove the well-known location +ynh_secure_remove --file="/etc/nginx/conf.d/${server_name}.d/${app}_server_name.conf" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 6122364..6cda2ba 100755 --- a/scripts/restore +++ b/scripts/restore @@ -22,12 +22,15 @@ chown -R $app:root "$install_dir" #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= -# RESTORE THE PHP-FPM CONFIGURATION -#================================================= ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +if yunohost --output-as plain domain list | grep -q "^$server_name$" +then + ynh_restore_file --origin_path="/etc/nginx/conf.d/${server_name}.d/${app}_server_name.conf" +fi + ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet diff --git a/scripts/upgrade b/scripts/upgrade index a372401..d093cf4 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -42,6 +42,12 @@ ynh_script_progression --message="Upgrading system configurations related to $ap ynh_add_nginx_config +# Create .well-known redirection for access by federation +if yunohost --output-as plain domain list | grep -q "^$server_name$" +then + ynh_add_config --template="server_name.conf" --destination="/etc/nginx/conf.d/${server_name}.d/${app}_server_name.conf" +fi + ynh_add_systemd_config yunohost service add $app --description="Chat server powered by Matrix" --log="/var/log/$app/$app.log"