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:
parent
acddee9591
commit
daaf3e8e6f
8 changed files with 43 additions and 29 deletions
|
@ -152,7 +152,7 @@ client_api:
|
||||||
|
|
||||||
# Prevents new users from being able to register on this homeserver, except when
|
# Prevents new users from being able to register on this homeserver, except when
|
||||||
# using the registration shared secret below.
|
# using the registration shared secret below.
|
||||||
registration_disabled: __REGISTRATION__
|
registration_disabled: __REGISTRATION_DISABLED__
|
||||||
|
|
||||||
# Prevents new guest accounts from being created. Guest registration is also
|
# Prevents new guest accounts from being created. Guest registration is also
|
||||||
# disabled implicitly by setting 'registration_disabled' above.
|
# disabled implicitly by setting 'registration_disabled' above.
|
||||||
|
|
|
@ -7,7 +7,7 @@ Type=simple
|
||||||
User=__APP__
|
User=__APP__
|
||||||
Group=__APP__
|
Group=__APP__
|
||||||
WorkingDirectory=__FINALPATH__/
|
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
|
StandardOutput=append:/var/log/__APP__/__APP__.log
|
||||||
StandardError=inherit
|
StandardError=inherit
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
:warning: The upstream app is still in beta. Tread carefully.
|
:warning: The upstream app is still in beta. Tread carefully.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
* Registration can be opened in the app config panel.
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|
||||||
* Upstream app still in beta.
|
* Dendrite does not implement secondary user registration schemes yet, so YunoHost users cannot be integrated at the moment.
|
||||||
|
|
|
@ -53,9 +53,13 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "is_public",
|
"name": "registration",
|
||||||
"type": "boolean",
|
"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?"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ ynh_add_systemd_config
|
||||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||||
|
|
||||||
# Start a systemd service
|
# 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
|
# RELOAD NGINX
|
||||||
|
|
|
@ -27,10 +27,20 @@ ynh_abort_if_errors
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
path_url="/"
|
path_url="/"
|
||||||
server_name=$YNH_APP_ARG_SERVER_NAME
|
server_name=$YNH_APP_ARG_SERVER_NAME
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
registration=$YNH_APP_ARG_REGISTRATION
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
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
|
# 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=domain --value=$domain
|
||||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
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=server_name --value=$server_name
|
||||||
|
ynh_app_setting_set --app=$app --key=registration --value=$registration
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
|
@ -169,13 +180,6 @@ chown -R $app:root "$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Adding a configuration file..."
|
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
|
# Copy and modify the config file
|
||||||
ynh_add_config --template="../conf/dendrite.yaml" --destination="$final_path/dendrite.yaml"
|
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_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 \
|
ynh_permission_create --permission=server_api --url=$domain/_matrix \
|
||||||
--label="Server access for client apps." --show_tile=false --allowed=visitors \
|
--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
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||||
|
|
||||||
# Start a systemd service
|
# 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
|
# RELOAD NGINX
|
||||||
|
|
|
@ -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_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
|
# GENERIC FINALIZATION
|
||||||
|
|
|
@ -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_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
db_user=$db_name
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||||
|
registration=$(ynh_app_setting_get --app=$app --key=registration)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
|
@ -56,7 +57,7 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
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
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
|
@ -67,13 +68,23 @@ if ! groups $app | grep -q 'ssl-cert'; then
|
||||||
adduser $app ssl-cert
|
adduser $app ssl-cert
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Define $server_name if not already defined
|
# Define $server_name if not already defined
|
||||||
if [ -z $server_name ]; then
|
if [ -z $server_name ]; then
|
||||||
server_name=$domain
|
server_name=$domain
|
||||||
ynh_app_setting_set --app=$app --key=server_name --value=$domain
|
ynh_app_setting_set --app=$app --key=server_name --value=$domain
|
||||||
fi
|
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
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -152,13 +163,6 @@ chown -R $app:root "$final_path"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating a configuration file..."
|
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"
|
ynh_add_config --template="../conf/dendrite.yaml" --destination="$final_path/dendrite.yaml"
|
||||||
|
|
||||||
chmod 400 "$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_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
|
if ! ynh_permission_exists --permission=server_api; then
|
||||||
ynh_permission_create --permission=server_api --url=$domain/_matrix \
|
ynh_permission_create --permission=server_api --url=$domain/_matrix \
|
||||||
--label="Server access for client apps." --show_tile=false --allowed=visitors \
|
--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_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
|
# RELOAD NGINX
|
||||||
|
|
Loading…
Add table
Reference in a new issue