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]
|
[main.registration]
|
||||||
name = "User registration"
|
name = "User registration"
|
||||||
|
|
||||||
[main.registration.registration]
|
[main.registration.registration_disabled]
|
||||||
ask = "Should registration be enabled?"
|
ask = "Should registration be disabled?"
|
||||||
type = "boolean"
|
type = "boolean"
|
||||||
yes = true
|
yes = true
|
||||||
no = false
|
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."
|
help = "Disallows registration of standard accounts. If your server is federated, reCAPTCHA verification should be activated to avoid spamming the whole Matrix network."
|
||||||
default = false
|
default = true
|
||||||
|
|
||||||
[main.registration.disable_federation]
|
[main.registration.disable_federation]
|
||||||
ask = "Disable Federation."
|
ask = "Disable Federation."
|
||||||
|
@ -21,7 +21,7 @@ name = "Dendrite configuration"
|
||||||
no = false
|
no = false
|
||||||
help = "Do not communicate with other homeservers of the Matrix Federation."
|
help = "Do not communicate with other homeservers of the Matrix Federation."
|
||||||
bind = ":/opt/yunohost/__APP__/dendrite.yaml"
|
bind = ":/opt/yunohost/__APP__/dendrite.yaml"
|
||||||
default = true
|
default = false
|
||||||
|
|
||||||
[main.registration.guests_disabled]
|
[main.registration.guests_disabled]
|
||||||
ask = "Disable guests registration."
|
ask = "Disable guests registration."
|
||||||
|
@ -39,10 +39,10 @@ name = "Dendrite configuration"
|
||||||
bind = ":/opt/yunohost/__APP__/dendrite.yaml"
|
bind = ":/opt/yunohost/__APP__/dendrite.yaml"
|
||||||
|
|
||||||
[main.registration.enable_registration_captcha]
|
[main.registration.enable_registration_captcha]
|
||||||
ask = "Disable Federation."
|
ask = "Enable CAPTCHA for registration."
|
||||||
type = "boolean"
|
type = "boolean"
|
||||||
yes = true
|
yes = true
|
||||||
no = false
|
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"
|
bind = ":/opt/yunohost/__APP__/dendrite.yaml"
|
||||||
default = true
|
default = true
|
||||||
|
|
|
@ -11,7 +11,6 @@ source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Stop script if errors
|
# Stop script if errors
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|
||||||
|
|
||||||
get_registration_disabled() {
|
get_registration_disabled() {
|
||||||
registration_disabled=$(ynh_app_setting_get --app $app --key 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"
|
really_enable_open_registration="--really-enable-open-registration"
|
||||||
fi
|
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_add_systemd_config
|
||||||
ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled
|
ynh_app_setting_set --app=$app --key=registration_disabled --value=$registration_disabled
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,11 @@ if [ $registration -eq 1 ]
|
||||||
then
|
then
|
||||||
registration_disabled="false"
|
registration_disabled="false"
|
||||||
really_enable_open_registration="--really-enable-open-registration"
|
really_enable_open_registration="--really-enable-open-registration"
|
||||||
|
enable_registration_captcha="true"
|
||||||
else
|
else
|
||||||
registration_disabled="true"
|
registration_disabled="true"
|
||||||
really_enable_open_registration=""
|
really_enable_open_registration=""
|
||||||
|
enable_registration_captcha="false"
|
||||||
fi
|
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=server_name --value=$server_name
|
||||||
ynh_app_setting_set --app=$app --key=registration --value=$registration
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADD USER TO THE SSL-CERT GROUP
|
# ADD USER TO THE SSL-CERT GROUP
|
||||||
|
@ -103,6 +104,18 @@ popd
|
||||||
# Set permissions to app files
|
# Set permissions to app files
|
||||||
chown -R $app:root "$install_dir"
|
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
|
# ADD A CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -34,21 +34,66 @@ if ! groups $app | grep -q 'ssl-cert'; then
|
||||||
adduser $app ssl-cert
|
adduser $app ssl-cert
|
||||||
fi
|
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
|
# 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
|
||||||
|
|
||||||
|
# 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
|
# Load up registration variables
|
||||||
if [[ $registration -eq 1 ]]
|
if [[ $registration -eq 1 ]]
|
||||||
then
|
then
|
||||||
registration_disabled="false"
|
registration_disabled="false"
|
||||||
really_enable_open_registration="--really-enable-open-registration"
|
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
|
else
|
||||||
registration_disabled="true"
|
registration_disabled="true"
|
||||||
really_enable_open_registration=""
|
really_enable_open_registration=""
|
||||||
ynh_app_setting_set --app=$app --key=registration --value=0
|
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
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Add table
Reference in a new issue