#!/bin/bash

yq w -i /usr/share/meteor/bundle/programs/server/assets/app/config/settings.yml public.media.sipjsHackViaWs true
sed -i 's/https/http/g'  /etc/bigbluebutton/nginx/sip.nginx 
sed -i 's/7443/5066/g'  /etc/bigbluebutton/nginx/sip.nginx 

IP=$1 # <-- put in your own external IP address
TARGET=/usr/local/bigbluebutton/bbb-webrtc-sfu/config/default.yml

xmlstarlet edit --inplace --update '//param[@name="ws-binding"]/@value' --value "$IP:5066" /opt/freeswitch/conf/sip_profiles/external.xml
yq w -i $TARGET freeswitch.sip_ip "$IP"

xmlstarlet edit --inplace --update '//X-PRE-PROCESS[@cmd="set" and starts-with(@data, "external_rtp_ip=")]/@data' --value "external_rtp_ip=$IP" /opt/freeswitch/conf/vars.xml