diff --git a/manifest.json b/manifest.json index efffde0..0159b2f 100644 --- a/manifest.json +++ b/manifest.json @@ -38,7 +38,19 @@ }, { "name": "domain", - "type": "domain" + "type": "domain", + "ask": { + "en": "Select the domain onto which Dendrite will be exclusively installed. It may be different than the displayed server name.", + "fr": "Sélectionnez le domaine exclusivement dédié à Dendrite. Il peut être différent du nom d'affichage du serveur." + } + }, + { + "name": "server_name", + "type": "domain", + "ask": { + "en": "If your Dendrite domain selected above is a subdomain, you can choose a different display name for your Dendrite server to have your Matrix user-ids looking like @user:domain.org instead of @user:dendrite.domain.org", + "fr": "Si votre domaine pour Dendrite sélectionné précedemment est un sous-domaine, vous pouvez choisir un nom d'affichage pour votre serveur Dendrite afin que vos identifiants Matrix soient @utilisateur:domain.org plutôt que @utilisateur:dendrite.domain.org" + } }, { "name": "is_public", diff --git a/scripts/backup b/scripts/backup index 7db41e5..da7f321 100644 --- a/scripts/backup +++ b/scripts/backup @@ -29,6 +29,7 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) +server_name=$(ynh_app_setting_get --app=$app --key=server_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= @@ -62,6 +63,11 @@ ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/etc/systemd/system/$app.service" +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 VARIOUS FILES #================================================= diff --git a/scripts/install b/scripts/install index 4809a8e..b06a6c1 100644 --- a/scripts/install +++ b/scripts/install @@ -26,6 +26,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url="/" +server_name=$YNH_APP_ARG_SERVER_NAME is_public=$YNH_APP_ARG_IS_PUBLIC app=$YNH_APP_INSTANCE_NAME @@ -48,6 +49,7 @@ ynh_script_progression --message="Storing installation settings..." --weight=1 ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url +ynh_app_setting_set --app=$app --key=server_name --value=$server_name #================================================= # STANDARD MODIFICATIONS @@ -122,6 +124,12 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated NGINX config 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 + #================================================= # SPECIFIC SETUP #================================================= diff --git a/scripts/restore b/scripts/restore index 86c1883..fdee7bc 100644 --- a/scripts/restore +++ b/scripts/restore @@ -29,6 +29,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) +server_name=$(ynh_app_setting_get --app=$app --key=server_name) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) @@ -47,11 +48,14 @@ test ! -d $final_path \ #================================================= # STANDARD RESTORATION STEPS #================================================= -# RESTORE THE NGINX CONFIGURATION +# RESTORE ALL CONFIG AND DATA #================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." +ynh_script_progression --message="Restoring directory and configuration..." --weight=10 -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +mkdir -p /var/log/$app +chown -R $app:root /var/log/$app + +ynh_restore #================================================= # RECREATE THE DEDICATED USER @@ -64,9 +68,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" --groups="ssl-ce #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=1 - -ynh_restore_file --origin_path="$final_path" +ynh_script_progression --message="Restoring the app main directory permissions..." --weight=1 chmod 750 "$final_path" chmod -R o-rwx "$final_path" @@ -95,27 +97,15 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name #================================================= # RESTORE SYSTEMD #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 +ynh_script_progression --message="Enabling the systemd service..." --weight=1 -ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." - -mkdir -p /var/log/$app -chown -R $app:root /var/log/$app - -ynh_restore_file --origin_path="/etc/logrotate.d/$app" - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -ynh_use_go yunohost service add $app --description="Dendrite Matrix homeserver" --log="/var/log/$app/Monolith.log" --needs_exposed_ports "$tls_port" #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index a793ac1..e498d0e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -18,6 +18,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) +server_name=$(ynh_app_setting_get --app=$app --key=server_name) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) @@ -66,6 +67,13 @@ if ! groups $app | grep -q 'ssl-cert'; then adduser $app ssl-cert fi + +# Define $server_name if not already defined +if [ -z $server_name ]; then + server_name=$domain + ynh_app_setting_set --app=$app --key=server_name --value=$domain +fi + #================================================= # CREATE DEDICATED USER #================================================= @@ -98,6 +106,12 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config 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 DEDICATED USER #=================================================