From 3a22373a70a427ab6b74dc8e97ebbaa199b642f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Sat, 14 Dec 2019 00:45:59 +0100 Subject: [PATCH 1/2] Migrate actions and config panel config file to toml --- actions.json | 47 ----------------------------------------------- actions.toml | 33 +++++++++++++++++++++++++++++++++ config_panel.json | 45 --------------------------------------------- config_panel.toml | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 92 deletions(-) delete mode 100644 actions.json create mode 100644 actions.toml delete mode 100644 config_panel.json create mode 100644 config_panel.toml diff --git a/actions.json b/actions.json deleted file mode 100644 index a7a05e7..0000000 --- a/actions.json +++ /dev/null @@ -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" - } - ] -}] diff --git a/actions.toml b/actions.toml new file mode 100644 index 0000000..343ca1c --- /dev/null +++ b/actions.toml @@ -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" diff --git a/config_panel.json b/config_panel.json deleted file mode 100644 index b6fda34..0000000 --- a/config_panel.json +++ /dev/null @@ -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 - }] - }] - }] -} diff --git a/config_panel.toml b/config_panel.toml new file mode 100644 index 0000000..c1043b1 --- /dev/null +++ b/config_panel.toml @@ -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" From e2939fbbbb6fa4fe670311c72eb0bba074ac94cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Sat, 14 Dec 2019 12:02:49 +0100 Subject: [PATCH 2/2] Fix config pannel script --- scripts/config | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/scripts/config b/scripts/config index 0021e73..e50f3a2 100644 --- a/scripts/config +++ b/scripts/config @@ -57,29 +57,17 @@ show_config() { apply_config() { 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} + 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 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 ${YNH_CONFIG_PACKAGE_CONFIG_PACKAGE_CONFIG_BACKUP_BEFORE_UPGRADE,,}; then - ynh_app_setting_set --app $app --key disable_backup_before_upgrade --value 0 - backup_before_upgrade=0 - 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 + if [ $backup_before_upgrade == 1 ]; then + ynh_app_setting_set --app $app --key disable_backup_before_upgrade --value 0 + else + ynh_app_setting_set --app $app --key disable_backup_before_upgrade --value 1 fi domain=$(ynh_app_setting_get --app $app --key special_domain)