diff --git a/actions.json b/actions.json new file mode 100644 index 0000000..33eb397 --- /dev/null +++ b/actions.json @@ -0,0 +1,20 @@ +[{ + "id": "update_turnserver_ip", + "name": "Update turnserver ip", + "command": "/opt/yunohost/matrix-$YNH_APP_ID/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." + } +}] \ No newline at end of file diff --git a/config_panel.json b/config_panel.json new file mode 100644 index 0000000..b3e1665 --- /dev/null +++ b/config_panel.json @@ -0,0 +1,33 @@ +{ + "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": "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": false + }] + }] + }] +} \ No newline at end of file diff --git a/scripts/config b/scripts/config new file mode 100644 index 0000000..abcdd2f --- /dev/null +++ b/scripts/config @@ -0,0 +1,66 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source /usr/share/yunohost/helpers + +# Stop script if errors +ynh_abort_if_errors + +# Import common fonctions +source ./psql.sh +source ./experimental_helper.sh +source ./_common.sh + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +app=$YNH_APP_ID + +#================================================= +# SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND +#================================================= + +show_config() { + # here you are supposed to read some config file/database/other then print the values + # echo "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value" + echo "YNH_CONFIG_SYNAPSE_CONFIG_SERVER_CONFIG_SERVER_STATISTICS=$(ynh_app_setting_get $app report_stats)" + + backup_before_upgrade=$(ynh_app_setting_get $app disable_backup_before_upgrade) + if [[ ${backup_before_upgrade:-0} -eq 1 ]] + then + echo "YNH_CONFIG_PACKAGE_CONFIG_PACKAGE_CONFIG_BACKUP_BEFORE_UPGRADE=False" + else + echo "YNH_CONFIG_PACKAGE_CONFIG_PACKAGE_CONFIG_BACKUP_BEFORE_UPGRADE=True" + fi +} + +#================================================= +# MODIFY THE CONFIGURATION +#================================================= + +apply_config() { + ynh_app_setting_set $app report_stats $YNH_CONFIG_SYNAPSE_CONFIG_SERVER_CONFIG_SERVER_STATISTICS + + if ${YNH_CONFIG_PACKAGE_CONFIG_PACKAGE_CONFIG_BACKUP_BEFORE_UPGRADE,,} + then + ynh_app_setting_set $app disable_backup_before_upgrade 0 + else + ynh_app_setting_set $app disable_backup_before_upgrade 1 + fi +} + +#================================================= +# GENERIC FINALIZATION +#================================================= +# SELECT THE ACTION FOLLOWING THE GIVEN ARGUMENT +#================================================= +case $1 in + show) show_config;; + apply) apply_config;; +esac \ No newline at end of file