1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/dendrite_ynh.git synced 2024-09-03 18:25:58 +02:00

Implement user registration in config panel and fix service status detection

This commit is contained in:
tituspijean 2022-08-25 23:09:18 +02:00
parent acddee9591
commit daaf3e8e6f
No known key found for this signature in database
GPG key ID: EF3B0D7CC0A94720
8 changed files with 43 additions and 29 deletions

View file

@ -152,7 +152,7 @@ client_api:
# Prevents new users from being able to register on this homeserver, except when
# using the registration shared secret below.
registration_disabled: __REGISTRATION__
registration_disabled: __REGISTRATION_DISABLED__
# Prevents new guest accounts from being created. Guest registration is also
# disabled implicitly by setting 'registration_disabled' above.

View file

@ -7,7 +7,7 @@ Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__/
ExecStart=__FINALPATH__/bin/dendrite-monolith-server --tls-cert=/etc/yunohost/certs/__DOMAIN__/crt.pem --tls-key=/etc/yunohost/certs/__DOMAIN__/key.pem --config=dendrite.yaml --http-bind-address=:__PORT__ --https-bind-address=:__TLS_PORT__
ExecStart=__FINALPATH__/bin/dendrite-monolith-server --tls-cert=/etc/yunohost/certs/__DOMAIN__/crt.pem --tls-key=/etc/yunohost/certs/__DOMAIN__/key.pem --config=dendrite.yaml --http-bind-address=:__PORT__ --https-bind-address=:__TLS_PORT__ __REALLY_ENABLE_OPEN_REGISTRATION__
StandardOutput=append:/var/log/__APP__/__APP__.log
StandardError=inherit

View file

@ -1,5 +1,9 @@
:warning: The upstream app is still in beta. Tread carefully.
## Features
* Registration can be opened in the app config panel.
## Limitations
* Upstream app still in beta.
* Dendrite does not implement secondary user registration schemes yet, so YunoHost users cannot be integrated at the moment.

View file

@ -53,9 +53,13 @@
}
},
{
"name": "is_public",
"name": "registration",
"type": "boolean",
"default": false
"default": false,
"help": {
"en": "Should the server allow any visitor to register as a user?",
"fr": "Le serveur doit-il permettre à quiconque de s'enregistrer comme utilisateur?"
}
}
]
}

View file

@ -127,7 +127,7 @@ ynh_add_systemd_config
ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --line_match="Starting external Monolith listener" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=$app --action="start" --line_match="Starting external Monolith listener" --log_path="/var/log/$app/Monolith.log"
#=================================================
# RELOAD NGINX

View file

@ -27,10 +27,20 @@ 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
registration=$YNH_APP_ARG_REGISTRATION
app=$YNH_APP_INSTANCE_NAME
# Allow or deny registration based on is_public
if [ $registration -eq 1 ]
then
registration_disabled="false"
really_enable_open_registration="--really-enable-open-registration"
else
registration_disabled="true"
really_enable_open_registration=""
fi
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
@ -50,6 +60,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
ynh_app_setting_set --app=$app --key=registration --value=$registration
#=================================================
# STANDARD MODIFICATIONS
@ -169,13 +180,6 @@ chown -R $app:root "$final_path"
#=================================================
ynh_script_progression --message="Adding a configuration file..."
# Allow or deny registration based of is_public
registration=false
if [ $is_public -eq 1 ]
then
registration=true
fi
# Copy and modify the config file
ynh_add_config --template="../conf/dendrite.yaml" --destination="$final_path/dendrite.yaml"
@ -197,7 +201,7 @@ ynh_add_systemd_config
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
ynh_permission_update --permission=main --show_tile=false --protected=true
ynh_permission_update --permission=main --show_tile=false
ynh_permission_create --permission=server_api --url=$domain/_matrix \
--label="Server access for client apps." --show_tile=false --allowed=visitors \
@ -235,7 +239,7 @@ yunohost service add $app --description="Dendrite Matrix homeserver" --log="/var
ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --line_match="Starting external Monolith listener" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=$app --action="start" --line_match="Starting external Monolith listener" --log_path="/var/log/$app/Monolith.log"
#=================================================
# RELOAD NGINX

View file

@ -112,7 +112,7 @@ yunohost service add $app --description="Dendrite Matrix homeserver" --log="/var
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --line_match="Starting external Monolith listener" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=$app --action="start" --line_match="Starting external Monolith listener" --log_path="/var/log/$app/Monolith.log"
#=================================================
# GENERIC FINALIZATION

View file

@ -26,6 +26,7 @@ tls_port=$(ynh_app_setting_get --app=$app --key=tls_port)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
registration=$(ynh_app_setting_get --app=$app --key=registration)
#=================================================
# CHECK VERSION
@ -56,7 +57,7 @@ ynh_abort_if_errors
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped Dendrite Matrix homeserver" --log_path="systemd"
ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped external Monolith listener" --log_path="systemd"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
@ -67,13 +68,23 @@ 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
# Load up registration variables
if [[ $registration -eq 1 ]]
then
registration_disabled="false"
really_enable_open_registration="--really-enable-open-registration"
else
registration_disabled="true"
really_enable_open_registration=""
ynh_app_setting_set --app=$app --key=registration --value=0
fi
#=================================================
# CREATE DEDICATED USER
#=================================================
@ -152,13 +163,6 @@ chown -R $app:root "$final_path"
#=================================================
ynh_script_progression --message="Updating a configuration file..."
if ynh_permission_has_user --permission=main --user=visitors
then
registration="true"
else
registration="false"
fi
ynh_add_config --template="../conf/dendrite.yaml" --destination="$final_path/dendrite.yaml"
chmod 400 "$final_path/dendrite.yaml"
@ -179,8 +183,6 @@ ynh_add_systemd_config
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
ynh_permission_update --permission=main --show_tile=false --protected=true
if ! ynh_permission_exists --permission=server_api; then
ynh_permission_create --permission=server_api --url=$domain/_matrix \
--label="Server access for client apps." --show_tile=false --allowed=visitors \
@ -226,7 +228,7 @@ yunohost service add $app --description="Dendrite Matrix homeserver" --log="/var
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --line_match="Starting external Monolith listener" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=$app --action="start" --line_match="Starting external Monolith listener" --log_path="/var/log/$app/Monolith.log"
#=================================================
# RELOAD NGINX