mirror of
https://github.com/YunoHost-Apps/dendrite_ynh.git
synced 2024-09-03 18:25:58 +02:00
handle init and upgrade
This commit is contained in:
parent
0230a72b19
commit
2f44c0c38f
4 changed files with 72 additions and 15 deletions
|
@ -6,13 +6,13 @@ name = "Dendrite configuration"
|
|||
[main.registration]
|
||||
name = "User registration"
|
||||
|
||||
[main.registration.registration]
|
||||
ask = "Should registration be enabled?"
|
||||
[main.registration.registration_disabled]
|
||||
ask = "Should registration be disabled?"
|
||||
type = "boolean"
|
||||
yes = true
|
||||
no = false
|
||||
help = "Allows registration of standard accounts. If your server is federated, reCAPTCHA verification should be activated to avoid spamming the whole Matrix network."
|
||||
default = false
|
||||
help = "Disallows registration of standard accounts. If your server is federated, reCAPTCHA verification should be activated to avoid spamming the whole Matrix network."
|
||||
default = true
|
||||
|
||||
[main.registration.disable_federation]
|
||||
ask = "Disable Federation."
|
||||
|
@ -21,7 +21,7 @@ name = "Dendrite configuration"
|
|||
no = false
|
||||
help = "Do not communicate with other homeservers of the Matrix Federation."
|
||||
bind = ":/opt/yunohost/__APP__/dendrite.yaml"
|
||||
default = true
|
||||
default = false
|
||||
|
||||
[main.registration.guests_disabled]
|
||||
ask = "Disable guests registration."
|
||||
|
@ -39,10 +39,10 @@ name = "Dendrite configuration"
|
|||
bind = ":/opt/yunohost/__APP__/dendrite.yaml"
|
||||
|
||||
[main.registration.enable_registration_captcha]
|
||||
ask = "Disable Federation."
|
||||
ask = "Enable CAPTCHA for registration."
|
||||
type = "boolean"
|
||||
yes = true
|
||||
no = false
|
||||
help = "ReCaptcha API should be configured. See instructions https://matrix-org.github.io/dendrite/administration/registration#recaptcha-verification"
|
||||
help = "ReCAPTCHA API should be configured. See instructions https://matrix-org.github.io/dendrite/administration/registration#recaptcha-verification"
|
||||
bind = ":/opt/yunohost/__APP__/dendrite.yaml"
|
||||
default = true
|
||||
|
|
|
@ -11,7 +11,6 @@ source /usr/share/yunohost/helpers
|
|||
|
||||
# Stop script if errors
|
||||
ynh_abort_if_errors
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
get_registration_disabled() {
|
||||
registration_disabled=$(ynh_app_setting_get --app $app --key registration_disabled)
|
||||
|
@ -26,7 +25,7 @@ set__registration_disabled() {
|
|||
really_enable_open_registration="--really-enable-open-registration"
|
||||
fi
|
||||
|
||||
ynh_write_var_in_file --file=$final_path/dendrite.yaml --key=registration_disabled --value="${registration_disabled}"
|
||||
ynh_write_var_in_file --file=$install_dir/dendrite.yaml --key=registration_disabled --value="${registration_disabled}"
|
||||
ynh_add_systemd_config
|
||||
ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled
|
||||
}
|
||||
|
|
|
@ -19,9 +19,11 @@ if [ $registration -eq 1 ]
|
|||
then
|
||||
registration_disabled="false"
|
||||
really_enable_open_registration="--really-enable-open-registration"
|
||||
enable_registration_captcha="true"
|
||||
else
|
||||
registration_disabled="true"
|
||||
really_enable_open_registration=""
|
||||
enable_registration_captcha="false"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -29,7 +31,6 @@ fi
|
|||
#=================================================
|
||||
|
||||
ynh_app_setting_set --app=$app --key=server_name --value=$server_name
|
||||
ynh_app_setting_set --app=$app --key=registration --value=$registration
|
||||
|
||||
#=================================================
|
||||
# ADD USER TO THE SSL-CERT GROUP
|
||||
|
@ -103,6 +104,18 @@ popd
|
|||
# Set permissions to app files
|
||||
chown -R $app:root "$install_dir"
|
||||
|
||||
#=================================================
|
||||
## SET STANDARD SETTINGS FROM DEFAULT CONFIG
|
||||
#=================================================
|
||||
disable_federation="false"
|
||||
guests_disabled="true"
|
||||
registration_shared_secret=""
|
||||
ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled
|
||||
ynh_app_setting_set --app=$app --key=disable_federation --value=$disable_federation
|
||||
ynh_app_setting_set --app=$app --key=guests_disabled --value=$guests_disabled
|
||||
ynh_app_setting_set --app=$app --key=registration_shared_secret --value=$registration_shared_secret
|
||||
ynh_app_setting_set --app=$app --key=enable_registration_captcha --value=$enable_registration_captcha
|
||||
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
|
|
|
@ -34,21 +34,66 @@ if ! groups $app | grep -q 'ssl-cert'; then
|
|||
adduser $app ssl-cert
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# GET CONFIG PANEL SETTINGS
|
||||
#=================================================
|
||||
|
||||
server_name=$(ynh_app_setting_get --app=$app --key=server_name)
|
||||
registration_disabled=$(ynh_app_setting_get --app=$app --key=registration_disabled)
|
||||
disable_federation=$(ynh_app_setting_get --app=$app --key=disable_federation)
|
||||
guests_disabled=$(ynh_app_setting_get --app=$app --key=guests_disabled)
|
||||
registration_shared_secret=$(ynh_app_setting_get --app=$app --key=registration_shared_secret)
|
||||
enable_registration_captcha=$(ynh_app_setting_get --app=$app --key=enable_registration_captcha)
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# MIGRATION : Manage old settings
|
||||
#=================================================
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
ynh_app_setting_delete --app=$app --key=domain
|
||||
|
||||
# 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
|
||||
|
||||
# Define $disable_federation if not already defined
|
||||
if [ -z $disable_federation ]; then
|
||||
disable_federation="false"
|
||||
ynh_app_setting_set --app=$app --key=disable_federation --value=$disable_federation
|
||||
fi
|
||||
|
||||
# Define $guests_disabled if not already defined
|
||||
if [ -z $guests_disabled ]; then
|
||||
guests_disabled="true"
|
||||
ynh_app_setting_set --app=$app --key=guests_disabled --value=$guests_disabled
|
||||
fi
|
||||
|
||||
# Define $registration_shared_secret if not already defined
|
||||
if [ -z $registration_shared_secret ]; then
|
||||
registration_shared_secret=""
|
||||
ynh_app_setting_set --app=$app --key=registration_shared_secret --value=$registration_shared_secret
|
||||
fi
|
||||
|
||||
# Load up registration variables
|
||||
if [[ $registration -eq 1 ]]
|
||||
then
|
||||
registration_disabled="false"
|
||||
really_enable_open_registration="--really-enable-open-registration"
|
||||
registration_disabled="false"
|
||||
really_enable_open_registration="--really-enable-open-registration"
|
||||
enable_registration_captcha="true"
|
||||
ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled
|
||||
ynh_app_setting_set --app=$app --key=enable_registration_captcha --value=$enable_registration_captcha
|
||||
ynh_app_setting_delete --app=$app --key=registration
|
||||
else
|
||||
registration_disabled="true"
|
||||
really_enable_open_registration=""
|
||||
ynh_app_setting_set --app=$app --key=registration --value=0
|
||||
registration_disabled="true"
|
||||
really_enable_open_registration=""
|
||||
enable_registration_captcha="false"
|
||||
ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled
|
||||
ynh_app_setting_set --app=$app --key=enable_registration_captcha --value=$enable_registration_captcha
|
||||
ynh_app_setting_delete --app=$app --key=registration
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue