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

Create config panel

This commit is contained in:
Josué Tille 2018-08-03 16:06:29 +02:00
parent ca5bc8dba9
commit ae2b8366fa
No known key found for this signature in database
GPG key ID: D5E068C6DFA8681D
3 changed files with 119 additions and 0 deletions

20
actions.json Normal file
View file

@ -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."
}
}]

33
config_panel.json Normal file
View file

@ -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
}]
}]
}]
}

66
scripts/config Normal file
View file

@ -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