From 7ba0e3baaf4675df3c0018ae96fc6ae620348423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Fri, 6 Jul 2018 09:25:47 +0200 Subject: [PATCH] User official helper in coturn_config_rotate --- sources/Coturn_config_rotate.sh | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/sources/Coturn_config_rotate.sh b/sources/Coturn_config_rotate.sh index 453011d..186e6bc 100644 --- a/sources/Coturn_config_rotate.sh +++ b/sources/Coturn_config_rotate.sh @@ -2,31 +2,7 @@ app_instance=__APP__ -# Validate an IP address syntax -# -# usage: ynh_validate_ip ip_address_family ip_address -# | arg: ip_address_family - either 4 (for IPv4) or 6 (for IPv6) -# | arg: ip_address - IP address to validate -ynh_validate_ip() -{ - # http://stackoverflow.com/questions/319279/how-to-validate-ip-address-in-python#319298 - - local ip_address_family=$1 - local ip_address=$2 - - [ "$ip_address_family" == "4" ] || [ "$ip_address_family" == "6" ] || return 1 - - python /dev/stdin << EOF -import socket -import sys -family = { "4" : socket.AF_INET, "6" : socket.AF_INET6 } -try: - socket.inet_pton(family["$ip_address_family"], "$ip_address") -except socket.error: - sys.exit(1) -sys.exit(0) -EOF -} +source /usr/share/yunohost/helpers external_IP_line="external-ip=__IPV4__,__IPV6__" @@ -47,6 +23,6 @@ else external_IP_line="${external_IP_line/',__IPV6__'/}" fi -sed --in-place "s@^external-ip=.*\$@$external_IP_line@g" "/etc/matrix-$app_instance/coturn.conf" +ynh_replace_string "^external-ip=.*\$" "$external_IP_line" "/etc/matrix-$app_instance/coturn.conf" -exit 0 +exit 0 \ No newline at end of file