2021-01-13 21:58:03 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2021-01-25 18:06:42 +01:00
|
|
|
external_IP_line="external-ip=__IPV4__/__IPV6__"
|
2021-01-13 21:58:03 +01:00
|
|
|
|
|
|
|
public_ip4="$(curl ip.yunohost.org)" || true
|
|
|
|
public_ip6="$(curl ipv6.yunohost.org)" || true
|
|
|
|
|
|
|
|
if [ -n "$public_ip4" ] && ynh_validate_ip4 --ip_address="$public_ip4"
|
|
|
|
then
|
2021-01-25 18:06:42 +01:00
|
|
|
external_IP_line="${external_IP_line/'__IPV4__'/$public_ip4}"
|
|
|
|
else
|
|
|
|
external_IP_line="${external_IP_line/'__IPV4__/'/}"
|
2021-01-13 21:58:03 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$public_ip6" ] && ynh_validate_ip6 --ip_address="$public_ip6"
|
|
|
|
then
|
2021-01-25 18:06:42 +01:00
|
|
|
external_IP_line="${external_IP_line/'__IPV6__'/$public_ip6}"
|
|
|
|
else
|
|
|
|
external_IP_line="${external_IP_line/'/__IPV6__'/}"
|
2021-01-13 21:58:03 +01:00
|
|
|
fi
|
|
|
|
|
2021-01-17 13:33:23 +01:00
|
|
|
old_config_line=$(egrep "^external-ip=.*\$" "/etc/$app/coturn.conf")
|
|
|
|
ynh_replace_string "^external-ip=.*\$" "$external_IP_line" "/etc/$app/coturn.conf"
|
|
|
|
new_config_line=$(egrep "^external-ip=.*\$" "/etc/$app/coturn.conf")
|
2021-01-13 21:58:03 +01:00
|
|
|
|
2021-02-25 10:12:39 +01:00
|
|
|
setfacl -R -m user:turnserver:rX /etc/__APP__
|
2021-01-13 21:58:03 +01:00
|
|
|
|
|
|
|
if [ "$old_config_line" != "$new_config_line" ]
|
|
|
|
then
|
2021-01-25 18:06:42 +01:00
|
|
|
systemctl restart coturn-__APP__.service
|
2021-01-13 21:58:03 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|