jvb: try to use the correct IP as the default server ID

This hopefully fixes WS issues on environment with multiple networks
such as Docker Swarm.
This commit is contained in:
Saúl Ibarra Corretgé
2021-10-12 22:14:26 +02:00
parent 9e982fe9e2
commit 487bcca46d
3 changed files with 14 additions and 8 deletions

View File

@@ -1,8 +1,5 @@
#!/usr/bin/with-contenv bash
export LOCAL_ADDRESS=$(ip addr show dev "$(ip route|awk '/^default/ { print $5 }')" | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
export SENTRY_RELEASE="${SENTRY_RELEASE:-$(apt-cache policy jitsi-videobridge2 | sed -n '/Installed/p' | sed -e 's/[^:]*: //')}"
if [[ -z $JVB_AUTH_PASSWORD ]]; then
echo 'FATAL ERROR: JVB auth password must be set'
exit 1
@@ -14,6 +11,16 @@ if [[ "$JVB_AUTH_PASSWORD" == "$OLD_JVB_AUTH_PASSWORD" ]]; then
exit 1
fi
# On environments like Swarm the IP address used by the default gateway need not be
# the one used for inter-container traffic. Use that one for our fallback ID.
XMPP_SERVER_IP=$(dig +short ${XMPP_SERVER})
export JVB_WS_SERVER_ID_FALLBACK=$(ip route get ${XMPP_SERVER_IP} | grep -oP '(?<=src ).*' | awk '{ print $1 '})
# Local IP for the ice4j mapping harvester.
export LOCAL_ADDRESS=$(ip route get 1 | grep -oP '(?<=src ).*' | awk '{ print $1 '})
export SENTRY_RELEASE="${SENTRY_RELEASE:-$(apt-cache policy jitsi-videobridge2 | sed -n '/Installed/p' | sed -e 's/[^:]*: //')}"
if [[ -f /config/custom-sip-communicator.properties ]]; then
cat /config/custom-sip-communicator.properties > /config/sip-communicator.properties
fi