2020-01-26 02:54:12 +08:00
|
|
|
# This is a library of functions for
|
|
|
|
#
|
|
|
|
# /etc/bigbluebutton/bbb-conf/apply-config.sh
|
2019-02-11 01:48:50 +08:00
|
|
|
#
|
2020-01-26 02:54:12 +08:00
|
|
|
# which (if exists) will be run by `bbb-conf --setip` and `bbb-conf --restart` before restarting
|
|
|
|
# BigBlueButton.
|
2019-02-11 01:48:50 +08:00
|
|
|
#
|
2020-09-13 23:47:28 +08:00
|
|
|
# The purpose of apply-config.sh is to make it easy to apply your configuration changes to a BigBlueButton server
|
2019-03-08 01:50:54 +08:00
|
|
|
# before BigBlueButton starts
|
2019-02-11 01:48:50 +08:00
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
if LANG=c ifconfig | grep -q 'venet0:0'; then
|
|
|
|
# IP detection for OpenVZ environment
|
|
|
|
IP=$(ifconfig | grep -v '127.0.0.1' | grep -E "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | tail -1 | cut -d: -f2 | awk '{ print $1}')
|
|
|
|
else
|
|
|
|
IP=$(hostname -I | sed 's/ .*//g')
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f /usr/share/bbb-web/WEB-INF/classes/bigbluebutton.properties ]; then
|
|
|
|
SERVLET_DIR=/usr/share/bbb-web
|
|
|
|
else
|
|
|
|
SERVLET_DIR=/var/lib/tomcat7/webapps/bigbluebutton
|
|
|
|
fi
|
|
|
|
|
2021-03-12 10:32:00 +08:00
|
|
|
BBB_WEB_ETC_CONFIG=/etc/bigbluebutton/bbb-web.properties
|
|
|
|
|
2019-02-11 01:48:50 +08:00
|
|
|
PROTOCOL=http
|
|
|
|
if [ -f $SERVLET_DIR/WEB-INF/classes/bigbluebutton.properties ]; then
|
2021-03-12 10:32:00 +08:00
|
|
|
SERVER_URL=$(cat $SERVLET_DIR/WEB-INF/classes/bigbluebutton.properties $BBB_WEB_ETC_CONFIG | grep -v '#' | sed -n '/^bigbluebutton.web.serverURL/{s/.*\///;p}' | tail -n 1)
|
2021-03-16 23:01:04 +08:00
|
|
|
if cat $SERVLET_DIR/WEB-INF/classes/bigbluebutton.properties $BBB_WEB_ETC_CONFIG | grep -v '#' | grep ^bigbluebutton.web.serverURL | tail -n 1 | grep -q https; then
|
2019-02-11 01:48:50 +08:00
|
|
|
PROTOCOL=https
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2021-03-12 10:32:00 +08:00
|
|
|
HOST=$(cat $SERVLET_DIR/WEB-INF/classes/bigbluebutton.properties $BBB_WEB_ETC_CONFIG | grep -v '#' | sed -n '/^bigbluebutton.web.serverURL/{s/.*\///;p}' | tail -n 1)
|
2020-01-26 02:54:12 +08:00
|
|
|
|
2019-03-08 01:50:54 +08:00
|
|
|
HTML5_CONFIG=/usr/share/meteor/bundle/programs/server/assets/app/config/settings.yml
|
2020-01-26 02:54:12 +08:00
|
|
|
BBB_WEB_CONFIG=$SERVLET_DIR/WEB-INF/classes/bigbluebutton.properties
|
2019-02-11 01:48:50 +08:00
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Enable Looging of the HTML5 client for debugging
|
|
|
|
#
|
|
|
|
enableHTML5ClientLog() {
|
2019-02-12 15:58:47 +08:00
|
|
|
echo " - Enable HTML5 client log to /var/log/nginx/html5-client.log"
|
2019-02-11 01:48:50 +08:00
|
|
|
|
|
|
|
yq w -i $HTML5_CONFIG public.clientLog.external.enabled true
|
|
|
|
yq w -i $HTML5_CONFIG public.clientLog.external.url "$PROTOCOL://$HOST/html5log"
|
2019-03-08 01:50:54 +08:00
|
|
|
yq w -i $HTML5_CONFIG public.app.askForFeedbackOnLogout true
|
|
|
|
chown meteor:meteor $HTML5_CONFIG
|
2019-02-11 01:48:50 +08:00
|
|
|
|
|
|
|
cat > /etc/bigbluebutton/nginx/html5-client-log.nginx << HERE
|
|
|
|
location /html5log {
|
2019-03-08 01:50:54 +08:00
|
|
|
access_log /var/log/nginx/html5-client.log postdata;
|
|
|
|
echo_read_request_body;
|
2019-02-11 01:48:50 +08:00
|
|
|
}
|
|
|
|
HERE
|
|
|
|
|
|
|
|
cat > /etc/nginx/conf.d/html5-client-log.conf << HERE
|
|
|
|
log_format postdata '\$remote_addr [\$time_iso8601] \$request_body';
|
|
|
|
HERE
|
2019-03-08 01:50:54 +08:00
|
|
|
|
|
|
|
# We need nginx-full to enable postdata log_format
|
2019-02-11 01:48:50 +08:00
|
|
|
if ! dpkg -l | grep -q nginx-full; then
|
|
|
|
apt-get install -y nginx-full
|
|
|
|
fi
|
|
|
|
|
2019-02-12 15:58:47 +08:00
|
|
|
touch /var/log/nginx/html5-client.log
|
|
|
|
chown bigbluebutton:bigbluebutton /var/log/nginx/html5-client.log
|
|
|
|
|
2019-02-11 01:48:50 +08:00
|
|
|
#
|
|
|
|
# You can monitor the live HTML5 client logs with the command
|
|
|
|
#
|
2019-03-08 01:50:54 +08:00
|
|
|
# tail -f /var/log/nginx/html5-client.log | sed -u 's/\\x22/"/g' | sed -u 's/\\x5C//g'
|
2019-02-11 01:48:50 +08:00
|
|
|
}
|
|
|
|
|
2019-04-04 10:26:10 +08:00
|
|
|
|
2020-09-16 02:45:25 +08:00
|
|
|
enableHTML5CameraQualityThresholds() {
|
|
|
|
echo " - Enable HTML5 cameraQualityThresholds"
|
|
|
|
yq w -i $HTML5_CONFIG public.kurento.cameraQualityThresholds.enabled true
|
|
|
|
}
|
|
|
|
|
|
|
|
enableHTML5WebcamPagination() {
|
|
|
|
echo " - Enable HTML5 webcam pagination"
|
|
|
|
yq w -i $HTML5_CONFIG public.kurento.pagination.enabled true
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-04 10:26:10 +08:00
|
|
|
#
|
|
|
|
# Enable firewall rules to open only
|
|
|
|
#
|
|
|
|
enableUFWRules() {
|
|
|
|
echo " - Enable Firewall and opening 22/tcp, 80/tcp, 443/tcp and 16384:32768/udp"
|
|
|
|
|
|
|
|
if ! which ufw > /dev/null; then
|
|
|
|
apt-get install -y ufw
|
|
|
|
fi
|
|
|
|
|
|
|
|
ufw allow OpenSSH
|
|
|
|
ufw allow "Nginx Full"
|
|
|
|
ufw allow 16384:32768/udp
|
|
|
|
ufw --force enable
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-13 23:47:28 +08:00
|
|
|
enableMultipleKurentos() {
|
2020-10-19 03:30:13 +08:00
|
|
|
echo " - Configuring three Kurento Media Servers (listen only, webcam, and screeshare)"
|
2020-09-13 23:47:28 +08:00
|
|
|
|
|
|
|
# Step 1. Setup shared certificate between FreeSWITCH and Kurento
|
|
|
|
|
2020-09-16 22:17:31 +08:00
|
|
|
HOSTNAME=$(cat /etc/nginx/sites-available/bigbluebutton | grep -v '#' | sed -n '/server_name/{s/.*server_name[ ]*//;s/;//;p}' | cut -d' ' -f1 | head -n 1)
|
2020-11-13 03:59:45 +08:00
|
|
|
openssl req -x509 -new -nodes -newkey rsa:4096 -sha256 -days 3650 -subj "/C=BR/ST=Ottawa/O=BigBlueButton Inc./OU=Live/CN=$HOSTNAME" -keyout /tmp/dtls-srtp-key.pem -out /tmp/dtls-srtp-cert.pem
|
2020-09-16 22:17:31 +08:00
|
|
|
cat /tmp/dtls-srtp-key.pem /tmp/dtls-srtp-cert.pem > /etc/kurento/dtls-srtp.pem
|
|
|
|
cat /tmp/dtls-srtp-key.pem /tmp/dtls-srtp-cert.pem > /opt/freeswitch/etc/freeswitch/tls/dtls-srtp.pem
|
2020-09-16 21:23:53 +08:00
|
|
|
|
2020-09-16 22:17:31 +08:00
|
|
|
sed -i 's/;pemCertificateRSA=.*/pemCertificateRSA=\/etc\/kurento\/dtls-srtp.pem/g' /etc/kurento/modules/kurento/WebRtcEndpoint.conf.ini
|
2020-09-13 23:47:28 +08:00
|
|
|
|
|
|
|
# Step 2. Setup systemd unit files to launch three separate instances of Kurento
|
|
|
|
|
2020-09-14 00:36:07 +08:00
|
|
|
for i in `seq 8888 8890`; do
|
2020-09-13 23:47:28 +08:00
|
|
|
|
|
|
|
cat > /usr/lib/systemd/system/kurento-media-server-${i}.service << HERE
|
2020-10-19 03:30:13 +08:00
|
|
|
# /usr/lib/systemd/system/kurento-media-server-#{i}.service
|
|
|
|
[Unit]
|
|
|
|
Description=Kurento Media Server daemon (${i})
|
|
|
|
After=network.target
|
|
|
|
PartOf=kurento-media-server.service
|
|
|
|
After=kurento-media-server.service
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
UMask=0002
|
|
|
|
Environment=KURENTO_LOGS_PATH=/var/log/kurento-media-server
|
|
|
|
Environment=KURENTO_CONF_FILE=/etc/kurento/kurento-${i}.conf.json
|
|
|
|
User=kurento
|
|
|
|
Group=kurento
|
|
|
|
LimitNOFILE=1000000
|
|
|
|
ExecStartPre=-/bin/rm -f /var/kurento/.cache/gstreamer-1.5/registry.x86_64.bin
|
|
|
|
ExecStart=/usr/bin/kurento-media-server --gst-debug-level=3 --gst-debug="3,Kurento*:4,kms*:4,KurentoWebSocketTransport:5"
|
|
|
|
Type=simple
|
|
|
|
PIDFile=/var/run/kurento-media-server-${i}.pid
|
2021-04-26 22:03:21 +08:00
|
|
|
TasksMax=infinity
|
2020-10-19 03:30:13 +08:00
|
|
|
Restart=always
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=kurento-media-server.service
|
2020-09-13 23:47:28 +08:00
|
|
|
HERE
|
|
|
|
|
|
|
|
# Make a new configuration file each instance of Kurento that binds to a different port
|
|
|
|
cp /etc/kurento/kurento.conf.json /etc/kurento/kurento-${i}.conf.json
|
|
|
|
sed -i "s/8888/${i}/g" /etc/kurento/kurento-${i}.conf.json
|
|
|
|
done
|
|
|
|
|
|
|
|
# Step 3. Override the main kurento-media-server unit to start/stop the three Kurento instances
|
|
|
|
|
|
|
|
cat > /etc/systemd/system/kurento-media-server.service << HERE
|
2020-10-19 03:30:13 +08:00
|
|
|
[Unit]
|
|
|
|
Description=Kurento Media Server
|
2020-09-13 23:47:28 +08:00
|
|
|
|
2020-10-19 03:30:13 +08:00
|
|
|
[Service]
|
|
|
|
Type=oneshot
|
|
|
|
ExecStart=/bin/true
|
|
|
|
RemainAfterExit=yes
|
2020-09-13 23:47:28 +08:00
|
|
|
|
2020-10-19 03:30:13 +08:00
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
HERE
|
|
|
|
|
|
|
|
# Step 4. Extend bbb-webrtc-sfu unit to wait for all three KMS servers to start
|
|
|
|
|
|
|
|
mkdir -p /etc/systemd/system/bbb-webrtc-sfu.service.d
|
|
|
|
cat > /etc/systemd/system/bbb-webrtc-sfu.service.d/override.conf << HERE
|
|
|
|
[Unit]
|
|
|
|
After=syslog.target network.target freeswitch.service kurento-media-server-8888.service kurento-media-server-8889.service kurento-media-server-8890.service
|
2020-09-13 23:47:28 +08:00
|
|
|
HERE
|
|
|
|
|
|
|
|
systemctl daemon-reload
|
|
|
|
|
2020-09-14 00:36:07 +08:00
|
|
|
for i in `seq 8888 8890`; do
|
2020-09-13 23:47:28 +08:00
|
|
|
systemctl enable kurento-media-server-${i}.service
|
|
|
|
done
|
|
|
|
|
|
|
|
|
2020-10-19 03:30:13 +08:00
|
|
|
# Step 5. Modify bbb-webrtc-sfu config to use the three Kurento servers
|
2020-09-13 23:47:28 +08:00
|
|
|
|
|
|
|
KURENTO_CONFIG=/usr/local/bigbluebutton/bbb-webrtc-sfu/config/default.yml
|
|
|
|
|
|
|
|
MEDIA_TYPE=(main audio content)
|
|
|
|
IP=$(yq r /usr/local/bigbluebutton/bbb-webrtc-sfu/config/default.yml kurento[0].ip)
|
|
|
|
|
|
|
|
for i in `seq 0 2`; do
|
|
|
|
yq w -i $KURENTO_CONFIG "kurento[$i].ip" $IP
|
2020-09-14 00:36:07 +08:00
|
|
|
yq w -i $KURENTO_CONFIG "kurento[$i].url" "ws://127.0.0.1:$(($i + 8888))/kurento"
|
2020-09-13 23:47:28 +08:00
|
|
|
yq w -i $KURENTO_CONFIG "kurento[$i].mediaType" "${MEDIA_TYPE[$i]}"
|
|
|
|
yq w -i $KURENTO_CONFIG "kurento[$i].ipClassMappings.local" ""
|
|
|
|
yq w -i $KURENTO_CONFIG "kurento[$i].ipClassMappings.private" ""
|
|
|
|
yq w -i $KURENTO_CONFIG "kurento[$i].ipClassMappings.public" ""
|
|
|
|
yq w -i $KURENTO_CONFIG "kurento[$i].options.failAfter" 5
|
|
|
|
yq w -i $KURENTO_CONFIG "kurento[$i].options.request_timeout" 30000
|
|
|
|
yq w -i $KURENTO_CONFIG "kurento[$i].options.response_timeout" 30000
|
|
|
|
done
|
|
|
|
|
|
|
|
yq w -i $KURENTO_CONFIG balancing-strategy MEDIA_TYPE
|
|
|
|
}
|
|
|
|
|
|
|
|
disableMultipleKurentos() {
|
2020-12-10 08:53:45 +08:00
|
|
|
echo " - Configuring a single Kurento Media Server for listen only, webcam, and screenshare"
|
2020-09-13 23:47:28 +08:00
|
|
|
systemctl stop kurento-media-server.service
|
|
|
|
|
2020-09-14 00:36:07 +08:00
|
|
|
for i in `seq 8888 8890`; do
|
2020-09-13 23:47:28 +08:00
|
|
|
systemctl disable kurento-media-server-${i}.service
|
|
|
|
done
|
|
|
|
|
|
|
|
# Remove the overrride (restoring the original kurento-media-server.service unit file)
|
|
|
|
rm -f /etc/systemd/system/kurento-media-server.service
|
2020-10-19 03:30:13 +08:00
|
|
|
rm -f /etc/systemd/system/bbb-webrtc-sfu.service.d/override.conf
|
|
|
|
|
2020-09-13 23:47:28 +08:00
|
|
|
systemctl daemon-reload
|
|
|
|
|
|
|
|
# Restore bbb-webrtc-sfu configuration to use a single instance of Kurento
|
|
|
|
KURENTO_CONFIG=/usr/local/bigbluebutton/bbb-webrtc-sfu/config/default.yml
|
|
|
|
yq d -i $KURENTO_CONFIG kurento[1]
|
|
|
|
yq d -i $KURENTO_CONFIG kurento[1]
|
|
|
|
|
|
|
|
yq w -i $KURENTO_CONFIG "kurento[0].url" "ws://127.0.0.1:8888/kurento"
|
|
|
|
yq w -i $KURENTO_CONFIG "kurento[0].mediaType" ""
|
|
|
|
|
|
|
|
yq w -i $KURENTO_CONFIG balancing-strategy ROUND_ROBIN
|
|
|
|
}
|
|
|
|
|
2019-03-08 01:50:54 +08:00
|
|
|
|
|
|
|
notCalled() {
|
|
|
|
#
|
|
|
|
# This function is not called.
|
|
|
|
|
|
|
|
# Instead, it gives you the ability to copy the following text and paste it into the shell to create a starting point for
|
|
|
|
# apply-config.sh.
|
|
|
|
#
|
|
|
|
# By creating apply-config.sh manually, it will not be overwritten by any package updates. You can call functions in this
|
|
|
|
# library for commong BigBlueButton configuration tasks.
|
|
|
|
|
|
|
|
## Start Copying HEre
|
|
|
|
cat > /etc/bigbluebutton/bbb-conf/apply-config.sh << HERE
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Pull in the helper functions for configuring BigBlueButton
|
2019-03-16 07:29:30 +08:00
|
|
|
source /etc/bigbluebutton/bbb-conf/apply-lib.sh
|
2019-02-11 01:48:50 +08:00
|
|
|
|
2019-04-04 10:26:10 +08:00
|
|
|
# Available configuration options
|
|
|
|
|
|
|
|
#enableHTML5ClientLog
|
|
|
|
#enableUFWRules
|
2019-03-08 01:50:54 +08:00
|
|
|
|
2020-09-16 02:45:25 +08:00
|
|
|
#enableHTML5CameraQualityThresholds
|
|
|
|
#enableHTML5WebcamPagination
|
|
|
|
|
2020-10-19 03:30:13 +08:00
|
|
|
#enableMultipleKurentos
|
|
|
|
|
2020-12-13 01:15:14 +08:00
|
|
|
# Shorten the FreeSWITCH "you have been muted" and "you have been unmuted" prompts
|
|
|
|
# cp -r /etc/bigbluebutton/bbb-conf/sounds /opt/freeswitch/share/freeswitch
|
2020-12-05 03:56:16 +08:00
|
|
|
|
2019-03-08 01:50:54 +08:00
|
|
|
HERE
|
|
|
|
chmod +x /etc/bigbluebutton/bbb-conf/apply-config.sh
|
|
|
|
## Stop Copying HERE
|
|
|
|
}
|
2019-02-11 01:48:50 +08:00
|
|
|
|