2018-06-20 19:16:01 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
app_instance=__APP__
|
|
|
|
|
2018-07-06 09:25:47 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
2018-06-20 19:16:01 +02:00
|
|
|
|
2021-02-18 09:16:37 +01:00
|
|
|
coturn_config_path="/etc/matrix-$app_instance/coturn.conf"
|
2018-06-20 19:16:01 +02:00
|
|
|
public_ip4="$(curl ip.yunohost.org)" || true
|
|
|
|
public_ip6="$(curl ipv6.yunohost.org)" || true
|
|
|
|
|
2021-02-18 09:16:37 +01:00
|
|
|
old_config_line=$(egrep "^external-ip=.*\$" $coturn_config_path)
|
|
|
|
perl -i -pe 's/(^external-ip=.*\n)*//g' $coturn_config_path
|
|
|
|
|
2020-05-20 23:41:04 +02:00
|
|
|
if [ -n "$public_ip4" ] && ynh_validate_ip4 --ip_address="$public_ip4"
|
2018-06-20 19:16:01 +02:00
|
|
|
then
|
2020-05-20 23:41:04 +02:00
|
|
|
echo "external-ip=$public_ip4" >> "$coturn_config_path"
|
2018-06-20 19:16:01 +02:00
|
|
|
fi
|
|
|
|
|
2020-05-20 23:41:04 +02:00
|
|
|
if [ -n "$public_ip6" ] && ynh_validate_ip6 --ip_address="$public_ip6"
|
2018-06-20 19:16:01 +02:00
|
|
|
then
|
2020-05-20 23:41:04 +02:00
|
|
|
echo "external-ip=$public_ip6" >> "$coturn_config_path"
|
2018-06-20 19:16:01 +02:00
|
|
|
fi
|
|
|
|
|
2020-05-07 11:06:35 +02:00
|
|
|
new_config_line=$(egrep "^external-ip=.*\$" "/etc/matrix-$app_instance/coturn.conf")
|
2018-06-20 19:16:01 +02:00
|
|
|
|
2018-08-20 14:12:42 +02:00
|
|
|
setfacl -R -m user:turnserver:rX /etc/matrix-$app_instance
|
|
|
|
|
2020-05-07 11:06:35 +02:00
|
|
|
if [ "$old_config_line" != "$new_config_line" ]
|
|
|
|
then
|
|
|
|
systemctl restart coturn-$app_instance.service
|
|
|
|
fi
|
2018-08-20 12:46:38 +02:00
|
|
|
|
|
|
|
exit 0
|