1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/synapse_ynh.git synced 2024-09-03 20:26:38 +02:00

clean config init

This commit is contained in:
gredin67 2023-01-11 17:11:43 +01:00
parent 2cabc70378
commit 3ced5e2a7c
5 changed files with 56 additions and 51 deletions

View file

@ -1200,7 +1200,7 @@ turn_user_lifetime: 1h
# connect to arbitrary endpoints without having first signed up for a
# valid account (e.g. by passing a CAPTCHA).
#
turn_allow_guests: __ALLOWED_ACCESS__
turn_allow_guests: __TURN_ALLOW_GUESTS__
## Registration ##
@ -1212,7 +1212,7 @@ turn_allow_guests: __ALLOWED_ACCESS__
# you use either captcha, email, or token-based verification to verify that new users are not bots. In order to enable registration
# without any verification, you must also set `enable_registration_without_verification`, found below.
#
enable_registration: __ALLOWED_ACCESS__
enable_registration: __ENABLE_REGISTRATION__
# Enable registration without email or captcha verification. Note: this option is *not* recommended,
# as registration without verification is a known vector for spam and abuse. Defaults to false. Has no effect

View file

@ -12,7 +12,7 @@ services = ["__APP__"]
type = "boolean"
yes = true
no = false
help = "Set to 'true' to back up before each upgrade."
help = "Set to 'true' to backup the Synapse YunoHost App before each upgrade."
[homeserver.config.server_statistics]
ask = "Server statistics"

View file

@ -134,11 +134,11 @@ Then, to log in the API with your credentials, you need to set your user as admi
### Upgrade
By default a backup is made before the upgrade. To avoid this you have theses following possibilites:
By default a backup is made before the upgrade. If for some reason you want to upgrade without backup:
- Call the command with the `-b` flag: `yunohost app upgrade synapse -b`
- Set the settings `disable_backup_before_upgrade` to `1`. You can set this with this command:
- Disable the setting `Backup before upgrade` in the Config Panel. Or with command line:
`yunohost app setting synapse disable_backup_before_upgrade -v 1`
`yunohost app setting synapse backup_before_upgrade -v 0`
After this settings will be applied for **all** next upgrade.

View file

@ -85,6 +85,24 @@ ynh_app_setting_set --app=$app --key=report_stats --value=$report_stats
ynh_app_setting_set --app=$app --key=e2e_enabled_by_default --value=$e2e_enabled_by_default
ynh_app_setting_set --app=$app --key=synapse_user_app_pwd --value=$synapse_user_app_pwd
if [ $is_free_registration -eq 0 ]
then
enable_registration="false"
turn_allow_guests="false"
sso_enabled="true"
password_enabled="false"
else
enable_registration="true"
turn_allow_guests="true"
sso_enabled="false"
password_enabled="true"
fi
ynh_app_setting_set --app=$app --key=enable_registration --value=$enable_registration
ynh_app_setting_set --app=$app --key=turn_allow_guests --value=$turn_allow_guests
ynh_app_setting_set --app=$app --key=sso_enabled --value=$sso_enabled
ynh_app_setting_set --app=$app --key=password_enabled --value=$password_enabled
#=================================================
## SET STANDARD SETTINGS FROM DEFAULT CONFIG
#=================================================
@ -104,6 +122,8 @@ web_client_location=$element_ynh_url
client_base_url=$element_ynh_url
invite_client_location=$element_ynh_url
backup_before_upgrade="true"
server_statistics="false"
allow_public_rooms_without_auth="false"
allow_public_rooms_over_federation="false"
disable_msisdn_registration="true"
@ -120,6 +140,8 @@ enable_notifs="true"
notif_for_new_users="true"
enable_group_creation="true"
ynh_app_setting_set --app=$app --key=backup_before_upgrade --value=$backup_before_upgrade
ynh_app_setting_set --app=$app --key=server_statistics --value=$server_statistics
ynh_app_setting_set --app=$app --key=web_client_location --value=$web_client_location
ynh_app_setting_set --app=$app --key=client_base_url --value=$client_base_url
ynh_app_setting_set --app=$app --key=invite_client_location --value=$invite_client_location
@ -317,24 +339,6 @@ ynh_app_setting_set --app=$app --key=turnserver_pwd --value=$turnserver_pwd
macaroon_secret_key_param='macaroon_secret_key: "'$macaroon_secret_key'"'
if [ $is_free_registration -eq 0 ]
then
allow_registration=False
turn_allow_guests=False
sso_enabled=True
password_enabled=False
else
allow_registration=True
turn_allow_guests=True
sso_enabled=False
password_enabled=True
fi
ynh_app_setting_set --app=$app --key=allow_registration --value=$allow_registration
ynh_app_setting_set --app=$app --key=turn_allow_guests --value=$turn_allow_guests
ynh_app_setting_set --app=$app --key=sso_enabled --value=$sso_enabled
ynh_app_setting_set --app=$app --key=password_enabled --value=$password_enabled
ynh_add_config --template="homeserver.yaml" --destination="/etc/matrix-$app/homeserver.yaml"
ynh_add_config --template="log.yaml" --destination="/etc/matrix-$app/log.yaml"

View file

@ -60,6 +60,8 @@ data_path="/home/yunohost.app/matrix-$app"
#=================================================
# GET CONFIG PANEL SETTINGS
#=================================================
server_statistics=$(ynh_app_setting_get --app=$app --key=server_statistics)
web_client_location=$(ynh_app_setting_get --app=$app --key=web_client_location)
client_base_url=$(ynh_app_setting_get --app=$app --key=client_base_url)
invite_client_location=$(ynh_app_setting_get --app=$app --key=invite_client_location)
@ -73,12 +75,11 @@ default_identity_server=$(ynh_app_setting_get --app=$app --key=default_identity_
auto_join_rooms=$(ynh_app_setting_get --app=$app --key=auto_join_rooms)
autocreate_auto_join_rooms=$(ynh_app_setting_get --app=$app --key=autocreate_auto_join_rooms)
auto_join_rooms_for_guests=$(ynh_app_setting_get --app=$app --key=auto_join_rooms_for_guests)
password_enabled=$(ynh_app_setting_get --app=$app --key=password_enabled)
enable_notifs=$(ynh_app_setting_get --app=$app --key=enable_notifs)
notif_for_new_users=$(ynh_app_setting_get --app=$app --key=notif_for_new_users)
enable_group_creation=$(ynh_app_setting_get --app=$app --key=enable_group_creation)
allow_registration=$(ynh_app_setting_get --app=$app --key=allow_registration)
enable_registration=$(ynh_app_setting_get --app=$app --key=enable_registration)
turn_allow_guests=$(ynh_app_setting_get --app=$app --key=turn_allow_guests)
sso_enabled=$(ynh_app_setting_get --app=$app --key=sso_enabled)
password_enabled=$(ynh_app_setting_get --app=$app --key=password_enabled)
@ -94,6 +95,15 @@ then
ynh_die --message="Update from this synapse version is not available. You need to remove this package and reinstall the new package version."
fi
#=================================================
# MIGRATION 7 : Working config panel v1
#=================================================
backup_before_upgrade=$(ynh_app_setting_get --app=$app --key=backup_before_upgrade)
if [ -z "$backup_before_upgrade" ] ; then
if [ $(ynh_app_setting_get --app=$app --key=disable_backup_before_upgrade) ] ; then
backup_before_upgrade="false"
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
@ -103,7 +113,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
ynh_systemd_action --service_name=matrix-$app.service --action=stop
# Backup the current version of the app
if [ "0$(ynh_app_setting_get --app=$app --key=disable_backup_before_upgrade)" -ne 1 ]
if [ backup_before_upgrade ]
then
ynh_backup_before_upgrade
ynh_clean_setup () {
@ -223,6 +233,11 @@ ynh_app_setting_set --app=$app --key=web_client_location --value=$web_client_loc
ynh_app_setting_set --app=$app --key=client_base_url --value=$client_base_url
ynh_app_setting_set --app=$app --key=invite_client_location --value=$invite_client_location
if [ -z "$server_statistics" ]
then
server_statistics="false"
ynh_app_setting_set --app=$app --key=server_statistics --value=$server_statistics
fi
if [ -z "$allow_public_rooms_without_auth" ]
then
allow_public_rooms_without_auth=allow_public_rooms
@ -273,11 +288,6 @@ then
auto_join_rooms_for_guests="true"
ynh_app_setting_set --app=$app --key=auto_join_rooms_for_guests --value=$auto_join_rooms_for_guests
fi
if [ -z "$password_enabled" ]
then
password_enabled="true"
ynh_app_setting_set --app=$app --key=password_enabled --value=$password_enabled
fi
if [ -z "$enable_notifs" ]
then
enable_notifs="true"
@ -294,20 +304,20 @@ then
ynh_app_setting_set --app=$app --key=enable_group_creation --value=$enable_group_creation
fi
if [ -z "$allow_registration" ] ; then
if [ -z "$enable_registration" ] ; then
if [ $is_free_registration -eq 0 ]
then
allow_registration=False
turn_allow_guests=False
sso_enabled=True
password_enabled=False
enable_registration="false"
turn_allow_guests="false"
sso_enabled="true"
password_enabled="false"
else
allow_registration=True
turn_allow_guests=True
sso_enabled=False
password_enabled=True
enable_registration="true"
turn_allow_guests="true"
sso_enabled="false"
password_enabled="true"
fi
ynh_app_setting_set --app=$app --key=allow_registration --value=$allow_registration
ynh_app_setting_set --app=$app --key=enable_registration --value=$enable_registration
ynh_app_setting_set --app=$app --key=turn_allow_guests --value=$turn_allow_guests
ynh_app_setting_set --app=$app --key=sso_enabled --value=$sso_enabled
ynh_app_setting_set --app=$app --key=password_enabled --value=$password_enabled
@ -391,15 +401,6 @@ else
macaroon_secret_key_param='macaroon_secret_key: "'$macaroon_secret_key'"'
fi
if [ $is_free_registration -eq 0 ]
then
allowed_access=False
sso_enabled=True
else
allowed_access=True
sso_enabled=False
fi
ynh_add_config --template="homeserver.yaml" --destination="/etc/matrix-$app/homeserver.yaml"
ynh_add_config --template="log.yaml" --destination="/etc/matrix-$app/log.yaml"