This repository has been archived on 2023-09-13. You can view files and clone it, but cannot push or open issues or pull requests.
homeserver-ansible/roles/services/coturn/templates/coturn-ip-upd.sh.j2
2022-05-22 20:57:41 -04:00

45 lines
997 B
Django/Jinja

set -e
TMPF=$(mktemp)
cp /etc/turnserver/turnserver.conf $TMPF
IPADD=$(curl ip.me 2>/dev/null)
if [ ! -f "/etc/turnserver/turnserver.conf" ]
then
touch /etc/turnserver/error
if [ ! -f "/etc/turnserver/error" ]
then
touch /etc/turnserver/error
echo "/etc/turnserver/turnserver.conf does not exist."
echo "Please remove /etc/turnserver-error once the issue is resolved to unsilence errors."
exit 1
else
exit
fi
fi
if [ -z "$IPADD" ]
then
if [ ! -f "/etc/turnserver/error" ]
then
touch /etc/turnserver/error
echo "There was an issue getting the public IP address."
echo "Please remove /etc/turnserver/turnserver-error once the issue is resolved to unsilence errors."
exit 1
else
exit
fi
fi
sed -i "s/^external-ip=.*/external-ip=$IPADD/g" "$TMPF"
if [ -n "$(diff $TMPF /etc/turnserver/turnserver.conf)" ]
then
cp $TMPF /etc/turnserver/turnserver.conf
systemctl restart coturn
echo "IP address for Coturn changed to: $IPADD"
echo "Coturn has been restarted."
fi