From 08664bd85c5c909c0d5331b419bd0575096fea9c Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 19 Feb 2021 00:01:39 +0100 Subject: [PATCH] Simplify config --- conf/coturn/turnserver.conf | 6 ++--- conf/ice-servers.json | 14 +++++------ scripts/install | 22 +++++++++-------- scripts/restore | 22 +++++++++-------- scripts/upgrade | 48 +++++++++++++++++++++---------------- 5 files changed, 61 insertions(+), 51 deletions(-) diff --git a/conf/coturn/turnserver.conf b/conf/coturn/turnserver.conf index da267fb..96bebe9 100644 --- a/conf/coturn/turnserver.conf +++ b/conf/coturn/turnserver.conf @@ -1,10 +1,10 @@ lt-cred-mech use-auth-secret -static-auth-secret=__TURNPWD__ +static-auth-secret=__TURNSERVER_PWD__ realm=__DOMAIN__ -tls-listening-port=__TLS_PORT__ -alt-tls-listening-port=__TLS_ALT_PORT__ +tls-listening-port=__TURNSERVER_TLS_PORT__ +alt-tls-listening-port=__TURNSERVER_TLS_ALT_PORT__ min-port=49153 max-port=49193 cli-port=__CLI_PORT__ diff --git a/conf/ice-servers.json b/conf/ice-servers.json index 320489d..2830c5e 100644 --- a/conf/ice-servers.json +++ b/conf/ice-servers.json @@ -1,15 +1,15 @@ [ { "urls": [ - "turn:__DOMAIN__:__TLS_PORT__", - "turn:__DOMAIN__:__TLS_ALT_PORT__", - "turn:__DOMAIN__:__TLS_PORT__?transport=tcp", - "turn:__DOMAIN__:__TLS_ALT_PORT__?transport=tcp", - "turn:__DOMAIN__:__TLS_PORT__?transport=udp", - "turn:__DOMAIN__:__TLS_ALT_PORT__?transport=udp" + "turn:__DOMAIN__:__TURNSERVER_TLS_PORT__", + "turn:__DOMAIN__:__TURNSERVER_TLS_ALT_PORT__", + "turn:__DOMAIN__:__TURNSERVER_TLS_PORT__?transport=tcp", + "turn:__DOMAIN__:__TURNSERVER_TLS_ALT_PORT__?transport=tcp", + "turn:__DOMAIN__:__TURNSERVER_TLS_PORT__?transport=udp", + "turn:__DOMAIN__:__TURNSERVER_TLS_ALT_PORT__?transport=udp" ], "username": "__APP__", - "credential": "__TURNPWD__", + "credential": "__TURNSERVER_PWD__", "credentialType": "hmac-sha1" } ] diff --git a/scripts/install b/scripts/install index ca8d7b1..e5e5603 100755 --- a/scripts/install +++ b/scripts/install @@ -171,17 +171,19 @@ turnserver_pwd=$(ynh_string_random --length=30) ynh_app_setting_set --app=$app --key=turnserver_pwd --value=$turnserver_pwd ynh_print_ON -coturn_config_path="/etc/$app/coturn.conf" +# coturn_config_path="/etc/$app/coturn.conf" -cp ../conf/coturn/turnserver.conf "$coturn_config_path" -ynh_replace_string --match_string=__APP__ --replace_string=$app --target_file="$coturn_config_path" -ynh_replace_string --match_string=__DOMAIN__ --replace_string=$domain --target_file="$coturn_config_path" -ynh_replace_string --match_string=__TLS_PORT__ --replace_string=$turnserver_tls_port --target_file="$coturn_config_path" -ynh_replace_string --match_string=__TLS_ALT_PORT__ --replace_string=$turnserver_alt_tls_port --target_file="$coturn_config_path" -ynh_replace_string --match_string=__CLI_PORT__ --replace_string=$cli_port --target_file="$coturn_config_path" -ynh_print_OFF -ynh_replace_string --match_string=__TURNPWD__ --replace_string=$turnserver_pwd --target_file="$coturn_config_path" -ynh_print_ON +# cp ../conf/coturn/turnserver.conf "$coturn_config_path" +# ynh_replace_string --match_string=__APP__ --replace_string=$app --target_file="$coturn_config_path" +# ynh_replace_string --match_string=__DOMAIN__ --replace_string=$domain --target_file="$coturn_config_path" +# ynh_replace_string --match_string=__TURNSERVER_TLS_PORT__ --replace_string=$turnserver_tls_port --target_file="$coturn_config_path" +# ynh_replace_string --match_string=__TURNSERVER_TLS_ALT_PORT__ --replace_string=$turnserver_alt_tls_port --target_file="$coturn_config_path" +# ynh_replace_string --match_string=__CLI_PORT__ --replace_string=$cli_port --target_file="$coturn_config_path" +# ynh_print_OFF +# ynh_replace_string --match_string=__TURNSERVER_PWD__ --replace_string=$turnserver_pwd --target_file="$coturn_config_path" +# ynh_print_ON + +ynh_add_config --template="../conf/coturn/turnserver.conf" --destination="/etc/$app/coturn.conf" # Get public IP and set as external IP for coturn # note: '|| true' is used to ignore the errors if we can't get the public ipv4 or ipv6 diff --git a/scripts/restore b/scripts/restore index 07af19d..f205e14 100755 --- a/scripts/restore +++ b/scripts/restore @@ -140,18 +140,20 @@ ynh_print_ON # WARNING : these commands are used in INSTALL, UPGRADE # For any update do it in all files -coturn_config_path="/etc/$app/coturn.conf" +# coturn_config_path="/etc/$app/coturn.conf" -cp ../settings/conf/coturn/turnserver.conf "$coturn_config_path" +# cp ../settings/conf/coturn/turnserver.conf "$coturn_config_path" -ynh_replace_string --match_string=__APP__ --replace_string=$app --target_file="$coturn_config_path" -ynh_replace_string --match_string=__DOMAIN__ --replace_string=$domain --target_file="$coturn_config_path" -ynh_replace_string --match_string=__TLS_PORT__ --replace_string=$turnserver_tls_port --target_file="$coturn_config_path" -ynh_replace_string --match_string=__TLS_ALT_PORT__ --replace_string=$turnserver_alt_tls_port --target_file="$coturn_config_path" -ynh_replace_string --match_string=__CLI_PORT__ --replace_string=$cli_port --target_file="$coturn_config_path" -ynh_print_OFF -ynh_replace_string --match_string=__TURNPWD__ --replace_string=$turnserver_pwd --target_file="$coturn_config_path" -ynh_print_ON +# ynh_replace_string --match_string=__APP__ --replace_string=$app --target_file="$coturn_config_path" +# ynh_replace_string --match_string=__DOMAIN__ --replace_string=$domain --target_file="$coturn_config_path" +# ynh_replace_string --match_string=__TLS_PORT__ --replace_string=$turnserver_tls_port --target_file="$coturn_config_path" +# ynh_replace_string --match_string=__TLS_ALT_PORT__ --replace_string=$turnserver_alt_tls_port --target_file="$coturn_config_path" +# ynh_replace_string --match_string=__CLI_PORT__ --replace_string=$cli_port --target_file="$coturn_config_path" +# ynh_print_OFF +# ynh_replace_string --match_string=__TURNPWD__ --replace_string=$turnserver_pwd --target_file="$coturn_config_path" +# ynh_print_ON + +ynh_add_config --template="../settings/conf/coturn/turnserver.conf" --destination="/etc/$app/coturn.conf" # Get public IP and set as external IP for coturn # note : '|| true' is used to ignore the errors if we can't get the public ipv4 or ipv6 diff --git a/scripts/upgrade b/scripts/upgrade index a872b6e..aee8a5c 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -164,17 +164,19 @@ ynh_script_progression --message="Updating Coturn config..." --weight=1 # WARNING : theses command are used in INSTALL, UPGRADE # For any update do it in all files -coturn_config_path="/etc/$app/coturn.conf" +# coturn_config_path="/etc/$app/coturn.conf" -cp ../conf/coturn/turnserver.conf $coturn_config_path -ynh_replace_string --match_string=__APP__ --replace_string=$app --target_file="$coturn_config_path" -ynh_replace_string --match_string=__DOMAIN__ --replace_string=$domain --target_file="$coturn_config_path" -ynh_replace_string --match_string=__TLS_PORT__ --replace_string=$turnserver_tls_port --target_file="$coturn_config_path" -ynh_replace_string --match_string=__TLS_ALT_PORT__ --replace_string=$turnserver_alt_tls_port --target_file="$coturn_config_path" -ynh_replace_string --match_string=__CLI_PORT__ --replace_string=$cli_port --target_file="$coturn_config_path" -ynh_print_OFF -ynh_replace_string --match_string=__TURNPWD__ --replace_string=$turnserver_pwd --target_file="$coturn_config_path" -ynh_print_ON +# cp ../conf/coturn/turnserver.conf $coturn_config_path +# ynh_replace_string --match_string=__APP__ --replace_string=$app --target_file="$coturn_config_path" +# ynh_replace_string --match_string=__DOMAIN__ --replace_string=$domain --target_file="$coturn_config_path" +# ynh_replace_string --match_string=__TURNSERVER_TLS_PORT__ --replace_string=$turnserver_tls_port --target_file="$coturn_config_path" +# ynh_replace_string --match_string=__TURNSERVER_TLS_ALT_PORT__ --replace_string=$turnserver_alt_tls_port --target_file="$coturn_config_path" +# ynh_replace_string --match_string=__CLI_PORT__ --replace_string=$cli_port --target_file="$coturn_config_path" +# ynh_print_OFF +# ynh_replace_string --match_string=__TURNSERVER_PWD__ --replace_string=$turnserver_pwd --target_file="$coturn_config_path" +# ynh_print_ON + +ynh_add_config --template="../conf/coturn/turnserver.conf" --destination="/etc/$app/coturn.conf" # Get public IP and set as external IP for coturn # note : '|| true' is used to ignore the errors if we can't get the public ipv4 or ipv6 @@ -203,18 +205,22 @@ chmod +x $final_path/Coturn_config_rotate.sh # MODIFY A CONFIG FILE #================================================= -cp ../conf/passwd $final_path/data/passwd -ynh_replace_string --match_string=__ADMIN__ --replace_string=$admin --target_file="$final_path/data/passwd" -ynh_replace_string --match_string=__PASSWORD__ --replace_string=$password --target_file="$final_path/data/passwd" +# cp ../conf/passwd $final_path/data/passwd +# ynh_replace_string --match_string=__ADMIN__ --replace_string=$admin --target_file="$final_path/data/passwd" +# ynh_replace_string --match_string=__PASSWORD__ --replace_string=$password --target_file="$final_path/data/passwd" -cp ../conf/ice-servers.json $final_path/data/ice-servers.json -ynh_replace_string --match_string=__DOMAIN__ --replace_string=$domain --target_file="$final_path/data/ice-servers.json" -ynh_replace_string --match_string=__APP__ --replace_string=$app --target_file="$final_path/data/ice-servers.json" -ynh_replace_string --match_string=__TLS_PORT__ --replace_string=$turnserver_tls_port --target_file="$final_path/data/ice-servers.json" -ynh_replace_string --match_string=__TLS_ALT_PORT__ --replace_string=$turnserver_alt_tls_port --target_file="$final_path/data/ice-servers.json" -ynh_print_OFF -ynh_replace_string --match_string=__TURNPWD__ --replace_string=$turnserver_pwd --target_file="$final_path/data/ice-servers.json" -ynh_print_ON +ynh_add_config --template="../conf/passwd" --destination="$final_path/data/passwd" + +# cp ../conf/ice-servers.json $final_path/data/ice-servers.json +# ynh_replace_string --match_string=__DOMAIN__ --replace_string=$domain --target_file="$final_path/data/ice-servers.json" +# ynh_replace_string --match_string=__APP__ --replace_string=$app --target_file="$final_path/data/ice-servers.json" +# ynh_replace_string --match_string=__TURNSERVER_TLS_PORT__ --replace_string=$turnserver_tls_port --target_file="$final_path/data/ice-servers.json" +# ynh_replace_string --match_string=__TURNSERVER_TLS_ALT_PORT__ --replace_string=$turnserver_alt_tls_port --target_file="$final_path/data/ice-servers.json" +# ynh_print_OFF +# ynh_replace_string --match_string=__TURNSERVER_PWD__ --replace_string=$turnserver_pwd --target_file="$final_path/data/ice-servers.json" +# ynh_print_ON + +ynh_add_config --template="../conf/ice-servers.json" --destination="$final_path/data/ice-servers.json" #================================================= # NGINX CONFIGURATION