2023-07-20 08:31:02 +08:00
#!/bin/bash -ex
2021-08-13 18:53:18 +08:00
source /etc/lsb-release
case " $1 " in
configure| upgrade| 1| 2)
TARGET = /usr/local/bigbluebutton/bbb-webrtc-sfu/config/default.yml
cp /usr/local/bigbluebutton/bbb-webrtc-sfu/config/default.example.yml $TARGET
chown bigbluebutton:bigbluebutton $TARGET
2024-06-28 07:24:37 +08:00
# Set mediasoup IPs
2024-08-21 02:06:32 +08:00
# mediasoup.webrtc.listenIps[]: used for EXTERNAL comms (browser <-> ms)
2024-06-28 07:24:37 +08:00
yq e -i " .mediasoup.webrtc.listenIps[0].announcedIp = \" $IP \" " $TARGET
2024-08-21 02:06:32 +08:00
# mediasoup.plainRtp.listenIp: used for INTERNAL comms (FreeSWITCH <-> ms)
2024-06-28 07:24:37 +08:00
yq e -i " .mediasoup.plainRtp.listenIp.announcedIp = \" $IP \" " $TARGET
2024-08-01 04:36:12 +08:00
# mediasoup.workerBalancing: defines the strategy to distribute mediasoup
# elements (transports, producers, consumers) among workers.
yq e -i '.mediasoup.workerBalancing.strategy = "least-loaded"' $TARGET
# mediasoup.enableWorkerTransposing: whether to enable worker transposing
# (ie: the ability to move a media stream from one worker to another).
yq e -i '.mediasoup.enableWorkerTransposing = true' $TARGET
2024-08-21 02:06:32 +08:00
# mediasoup.dedicatedMediaTypeWorkers.audio: spin up #auto mediasoup workers
# dedicated to handling audio streams.
# auto = ceil((min(nproc,32) * 0.8) + (max(0, nproc - 32) / 2))
# The goal here is to try and preserve quality for audio streams via:
# - reducing noise from video streams in these single threaded workers
# - giving the possibility to specify different scheduling priorities for audio workers
yq e -i '.mediasoup.dedicatedMediaTypeWorkers.audio = "auto"' $TARGET
2021-10-13 21:38:27 +08:00
2024-06-28 07:24:37 +08:00
FREESWITCH_IP = $( xmlstarlet sel -t -v '//X-PRE-PROCESS[@cmd="set" and starts-with(@data, "local_ip_v4=")]/@data' /opt/freeswitch/conf/vars.xml | sed 's/local_ip_v4=//g' )
if [ " $FREESWITCH_IP " != "" ] ; then
yq e -i " .freeswitch.ip = \" $FREESWITCH_IP \" " $TARGET
yq e -i " .freeswitch.sip_ip = \" $IP \" " $TARGET
else
# Looks like the FreeSWITCH package is being installed, let's fall back to the default value
yq e -i " .freeswitch.ip = \" $IP \" " $TARGET
if [ " $DISTRIB_CODENAME " = = "focal" ] ; then
2023-07-19 22:24:52 +08:00
yq e -i " .freeswitch.sip_ip = \" $IP \" " $TARGET
2021-08-13 18:53:18 +08:00
fi
2024-06-28 07:24:37 +08:00
fi
2021-08-13 18:53:18 +08:00
cd /usr/local/bigbluebutton/bbb-webrtc-sfu
mkdir -p node_modules
mkdir -p /var/log/bbb-webrtc-sfu/
touch /var/log/bbb-webrtc-sfu/bbb-webrtc-sfu.log
2023-07-19 22:24:52 +08:00
yq e -i '.recordWebcams = true' $TARGET
2023-08-23 04:55:34 +08:00
# Set bbb-webrtc-recorder as the default recordingAdapter
yq e -i '.recordingAdapter = "bbb-webrtc-recorder"' $TARGET
# Do not configure any Kurento instances - BBB >= 2.8 doesn't provide Kurento by default
yq e -i '.kurento = []' $TARGET
2023-06-21 20:58:23 +08:00
2023-06-21 21:14:32 +08:00
echo "Resetting mcs-address from localhost to 127.0.0.1"
2023-07-20 20:18:58 +08:00
yq e -i '.mcs-address = "127.0.0.1"' $TARGET
2024-06-28 07:24:37 +08:00
if id bigbluebutton > /dev/null 2>& 1; then
2021-08-13 18:53:18 +08:00
chown -R bigbluebutton:bigbluebutton /usr/local/bigbluebutton/bbb-webrtc-sfu /var/log/bbb-webrtc-sfu/
else
echo "#"
2023-07-20 08:31:02 +08:00
echo "# Warning: Unable to assign ownership of bigbluebutton to sfu files"
2021-08-13 18:53:18 +08:00
echo "#"
fi
2021-10-05 03:13:46 +08:00
# Creates the mediasoup raw media file dir if needed
if [ ! -d /var/mediasoup ] ; then
mkdir -p /var/mediasoup
fi
2021-08-13 18:53:18 +08:00
chmod 644 $TARGET
chown bigbluebutton:bigbluebutton $TARGET
reloadService nginx
2024-06-28 07:24:37 +08:00
startService bbb-webrtc-sfu || echo "bbb-webrtc-sfu could not be registered or started"
; ;
2021-08-13 18:53:18 +08:00
abort-upgrade| abort-remove| abort-deconfigure)
2024-06-28 07:24:37 +08:00
; ;
2021-08-13 18:53:18 +08:00
*)
echo " postinst called with unknown argument \` $1 ' " >& 2
exit 1
2024-06-28 07:24:37 +08:00
; ;
2021-08-13 18:53:18 +08:00
esac