1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/coturn_ynh.git synced 2024-09-03 18:16:32 +02:00

Add metronome configuration snippet

This commit is contained in:
glougloumoute 2021-02-01 09:13:07 +01:00
parent 73aa0a707a
commit ad013d0e05
4 changed files with 94 additions and 0 deletions

50
conf/metronome.cfg.lua Normal file
View file

@ -0,0 +1,50 @@
external_services = {
["__DOMAIN__"] = {
[1] = {
port = "__STANDARD_PORT__",
transport = "udp",
type = "stun"
},
[2] = {
port = "__STANDARD_PORT__",
transport = "tcp",
type = "stun"
},
[3] = {
port = "__TLS_PORT__",
transport = "tcp",
type = "stuns"
},
[4] = {
port = "__STANDARD_PORT__",
transport = "tcp",
type = "turn",
turn_secret = "__TURNPWD__",
turn_ttl = 300
},
[5] = {
port = "__STANDARD_PORT__",
transport = "udp",
type = "turn",
turn_secret = "__TURNPWD__",
turn_ttl = 7200
},
[6] = {
port = "__TLS_PORT__",
transport = "tcp",
type = "turns",
turn_secret = "__TURNPWD__",
turn_ttl = 7200
}
}
};
jingle_nodes_turn_credentials = true;
jingle_nodes_turn_secret = "__TURNPWD__";
jingle_nodes_turn_credentials_ttl = 86400;
jingle_nodes_restricted = false;

View file

@ -7,6 +7,8 @@
# dependencies used by the app
pkg_dependencies="sqlite3 libsqlite3-dev coturn acl"
metronome_snippet_path="/etc/metronome/conf.d/coturn.cfg.lua"
#=================================================
# PERSONAL HELPERS
#=================================================

View file

@ -59,15 +59,20 @@ fi
ynh_script_progression --message="Finding an available port..." --weight=3
# Find an available port
turnserver_standard_port=$(ynh_find_port --port=3478)
turnserver_tls_port=$(ynh_find_port --port=5349)
turnserver_alt_tls_port=$(ynh_find_port --port=$((turnserver_tls_port+1)))
cli_port=$(ynh_find_port --port=5766)
# TODO also reserve UDP Port range 49152:65535
# Open the port
ynh_exec_warn_less yunohost firewall allow Both $turnserver_standard_port
ynh_exec_warn_less yunohost firewall allow Both $turnserver_tls_port
ynh_exec_warn_less yunohost firewall allow Both $turnserver_alt_tls_port
# Store opened ports
ynh_app_setting_set --app=$app --key=turnserver_standard_port --value=$turnserver_standard_port
ynh_app_setting_set --app=$app --key=turnserver_tls_port --value=$turnserver_tls_port
ynh_app_setting_set --app=$app --key=turnserver_alt_tls_port --value=$turnserver_alt_tls_port
ynh_app_setting_set --app=$app --key=cli_port --value=$cli_port
@ -164,6 +169,27 @@ ynh_script_progression --message="Configuring log rotation..." --weight=1
ynh_use_logrotate --logfile "/var/log/$app"
#=================================================
# ADD METRONOME CONFIGURATION
#=================================================
#ynh_add_config --template="metronome.cfg.lua" --destination="$metronome_snippet_path"
cp ../conf/metronome.cfg.lua "$metronome_snippet_path"
ynh_replace_string --target_file="$metronome_snippet_path" --match_string=__APP__ --replace_string=$app
ynh_replace_string --target_file="$metronome_snippet_path" --match_string=__DOMAIN__ --replace_string=$domain
ynh_replace_string --target_file="$metronome_snippet_path" --match_string=__STANDARD_PORT__ --replace_string=$turnserver_standard_port
ynh_replace_string --target_file="$metronome_snippet_path" --match_string=__TLS_PORT__ --replace_string=$turnserver_tls_port
ynh_print_OFF
ynh_replace_string --target_file="$metronome_snippet_path" --match_string=__TURNPWD__ --replace_string=$turnserver_pwd
ynh_print_ON
# TODO make sure the two following modules are enabled in metronome's main config
# "extdisco";
# "jingle_nodes";
ynh_systemd_action --action="reload" --service_name="metronome"
#=================================================
# GENERIC FINALIZATION
#=================================================

View file

@ -17,6 +17,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
turnserver_standard_port=$(ynh_app_setting_get --app=$app --key=turnserver_standard_port)
turnserver_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_tls_port)
turnserver_alt_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_alt_tls_port)
@ -65,6 +66,13 @@ ynh_script_progression --message="Removing logrotate configuration..." --weight=
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# REMOVE METRONOME CONFIGURATION
#=================================================
ynh_secure_remove --file="$metronome_snippet_path"
ynh_systemd_action --action="reload" --service_name="metronome"
#=================================================
# REMOVE SCRIPT
#=================================================
@ -89,6 +97,12 @@ ynh_secure_remove --file=/var/log/$app
# CLOSE PORTS
#=================================================
if yunohost firewall list | grep -q "\- $turnserver_standard_port$"
then
ynh_script_progression --message="Closing port $turnserver_standard_port..." --weight=1
ynh_exec_warn_less yunohost firewall disallow Both $turnserver_standard_port
fi
if yunohost firewall list | grep -q "\- $turnserver_tls_port$"
then
ynh_script_progression --message="Closing port $turnserver_tls_port..." --weight=1
@ -101,6 +115,8 @@ then
ynh_exec_warn_less yunohost firewall disallow Both $turnserver_alt_tls_port
fi
# TODO also release UDP port range 49152:65535
#=================================================
# GENERIC FINALIZATION
#=================================================