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

Merge pull request #163 from YunoHost-Apps/migrate_to_toml

Fix config panel and action
This commit is contained in:
Josue-T 2019-12-22 11:09:17 +01:00 committed by GitHub
commit cffd1e54ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 79 additions and 111 deletions

View file

@ -1,47 +0,0 @@
[{
"id": "update_turnserver_ip",
"name": "Update turnserver ip",
"command": "/opt/yunohost/matrix-$YNH_APP_INSTANCE_NAME/Coturn_config_rotate.sh",
"user": "root",
"accepted_return_codes": [0],
"description": {
"en": "Update the ip in the turnserver config"
}
},{
"id": "open_turnserver_firewall_ports",
"name": "Open ports for turnserver",
"command": "yunohost firewall allow Both 49153:49193",
"user": "root",
"accepted_return_codes": [0],
"description": {
"en": "Open the ports range 49153:49193 with TCP and UDP to be able to use correctly the turnserver."
}
},{
"id": "close_turnserver_firewall_ports",
"name": "Close ports for turnserver",
"command": "yunohost firewall disallow Both 49153:49193",
"user": "root",
"accepted_return_codes": [0],
"description": {
"en": "Close the ports range 49153:49193 with TCP and UDP. (Undo \"Open ports for turnserver\" action)"
}
},{
"id": "set_admin_user",
"name": "Set a user as admin",
"command": "[[ \"$(su --command=\"psql matrix_synapse\" postgres <<< \"UPDATE users SET admin = 1 WHERE name = '@$YNH_ACTION_USERNAME:$(yunohost app setting $YNH_APP_INSTANCE_NAME special_domain)'\")\" == 'UPDATE 1' ]]",
"user": "root",
"accepted_return_codes": [0],
"description": {
"en": "Set a synapse user as admin in the synapse server. It probably usefull only to manage the community function."
},
"arguments": [
{
"name": "username",
"type": "string",
"ask": {
"en": "username of the user to set as admin"
},
"example": "bob"
}
]
}]

33
actions.toml Normal file
View file

@ -0,0 +1,33 @@
[update_turnserver_ip]
name = "Update turnserver ip"
command = "/opt/yunohost/matrix-$YNH_APP_INSTANCE_NAME/Coturn_config_rotate.sh"
user = "root"
accepted_return_codes = [0]
description = "Update the ip in the turnserver config"
[open_turnserver_firewall_ports]
name = "Open ports for turnserver"
command = "yunohost firewall allow Both 49153:49193"
user = "root"
accepted_return_codes = [0]
description = "Open the ports range 49153:49193 with TCP and UDP to be able to use correctly the turnserver."
[close_turnserver_firewall_ports]
name = "Close ports for turnserver"
command = "yunohost firewall disallow Both 49153:49193"
user = "root"
accepted_return_codes = [0]
description = "Close the ports range 49153:49193 with TCP and UDP. (Undo \"Open ports for turnserver\" action)"
[set_admin_user]
name = "Set a user as admin"
command = "[[ \"$(su --command=\"psql matrix_synapse\" postgres <<< \"UPDATE users SET admin = 1 WHERE name = '@$YNH_ACTION_USERNAME:$(yunohost app setting $YNH_APP_INSTANCE_NAME special_domain)'\")\" == 'UPDATE 1' ]]"
user = "root"
accepted_return_codes = [0]
description = "Set a synapse user as admin in the synapse server. It probably usefull only to manage the community function."
[set_admin_user.arguments]
[set_admin_user.arguments.username]
type = "string"
ask = "username of the user to set as admin"
example = "bob"

View file

@ -1,45 +0,0 @@
{
"name": "Synapse configuration panel",
"version": "0.1",
"panel": [{
"name": "Synapse config",
"id": "synapse_config",
"sections": [{
"name": "Synapse server configuration",
"id": "server_config",
"options": [{
"name": "Server statistics",
"id": "server_statistics",
"type": "bool",
"help": "True to send anonymous statistics about synapse to improve the performances",
"default": false
},{
"name": "Server public",
"id": "is_public",
"type": "bool",
"help": "Is it a public server",
"default": false
},{
"name": "Server public",
"id": "allow_public_rooms",
"type": "bool",
"help": "If set to 'false', requires authentication to access the server's public rooms directory through the client API and forbids any other homeserver to fetch the server's public rooms directory via federation.",
"default": false
}]
}]
},{
"name": "Package config",
"id": "package_config",
"sections": [{
"name": "Synapse server configuration",
"id": "package_config",
"options": [{
"name": "Backup before upgrade",
"id": "backup_before_upgrade",
"type": "bool",
"help": "True to do a backup before every upgrade",
"default": true
}]
}]
}]
}

39
config_panel.toml Normal file
View file

@ -0,0 +1,39 @@
version = "0.1"
name = "Synapse configuration panel"
[synapse_config]
name = "Synapse configuration"
[synapse_config.server_config]
name = "Synapse server configuration"
[synapse_config.server_config.server_statistics]
ask = "Server statistics"
type = "boolean"
default = false
help = "True to send anonymous statistics about synapse to improve the performances"
[synapse_config.server_config.is_public]
ask = "Server public"
type = "boolean"
default = false
help = "Is it a public server"
[synapse_config.server_config.allow_public_rooms]
ask = "Server public"
type = "boolean"
default = false
help = "If set to 'false', requires authentication to access the server's public rooms directory through the client API and forbids any other homeserver to fetch the server's public rooms directory via federation."
[package_config]
name = "Package configuration"
[package_config.package_config]
name = "Synapse server configuration"
[package_config.package_config.backup_before_upgrade]
ask = "Backup before upgrade"
type = "boolean"
default = true
help = "True to do a backup before every upgrade"

View file

@ -57,29 +57,17 @@ show_config() {
apply_config() { apply_config() {
report_stats=${YNH_CONFIG_SYNAPSE_CONFIG_SERVER_CONFIG_SERVER_STATISTICS:-$report_stats} report_stats=${YNH_CONFIG_SYNAPSE_CONFIG_SERVER_CONFIG_SERVER_STATISTICS:-$report_stats}
allow_public_rooms=${YNH_CONFIG_SYNAPSE_CONFIG_SERVER_CONFIG_ALLOW_PUBLIC_ROOMS:-$allow_public_rooms} allow_public_rooms=${YNH_CONFIG_SYNAPSE_CONFIG_SERVER_CONFIG_ALLOW_PUBLIC_ROOMS:-$allow_public_rooms}
backup_before_upgrade=${YNH_CONFIG_PACKAGE_CONFIG_PACKAGE_CONFIG_BACKUP_BEFORE_UPGRADE:-$backup_before_upgrade}
is_public=${YNH_CONFIG_SYNAPSE_CONFIG_SERVER_CONFIG_IS_PUBLIC:-$is_public}
ynh_app_setting_set --app $app --key report_stats --value $report_stats ynh_app_setting_set --app $app --key report_stats --value $report_stats
ynh_app_setting_set --app $app --key allow_public_rooms --value $allow_public_rooms ynh_app_setting_set --app $app --key allow_public_rooms --value $allow_public_rooms
ynh_app_setting_set --app $app --key is_public --value $is_public
if [ -n "${YNH_CONFIG_PACKAGE_CONFIG_PACKAGE_CONFIG_BACKUP_BEFORE_UPGRADE:-}" ]; then if [ $backup_before_upgrade == 1 ]; then
if ${YNH_CONFIG_PACKAGE_CONFIG_PACKAGE_CONFIG_BACKUP_BEFORE_UPGRADE,,}; then ynh_app_setting_set --app $app --key disable_backup_before_upgrade --value 0
ynh_app_setting_set --app $app --key disable_backup_before_upgrade --value 0 else
backup_before_upgrade=0 ynh_app_setting_set --app $app --key disable_backup_before_upgrade --value 1
else
ynh_app_setting_set --app $app --key disable_backup_before_upgrade --value 1
backup_before_upgrade=1
fi
fi
if [ -n "${YNH_CONFIG_SYNAPSE_CONFIG_SERVER_CONFIG_IS_PUBLIC:-}" ]; then
if ${YNH_CONFIG_SYNAPSE_CONFIG_SERVER_CONFIG_IS_PUBLIC,,}
then
ynh_app_setting_set --app $app --key is_public --value 1
is_public=1
else
ynh_app_setting_set --app $app --key is_public --value 0
is_public=0
fi
fi fi
domain=$(ynh_app_setting_get --app $app --key special_domain) domain=$(ynh_app_setting_get --app $app --key special_domain)