diff --git a/.github/workflows/automated-tests.yml b/.github/workflows/automated-tests.yml index 40bcb08e3b..96301b9fe3 100644 --- a/.github/workflows/automated-tests.yml +++ b/.github/workflows/automated-tests.yml @@ -73,7 +73,7 @@ jobs: build-list: bbb-webrtc-sfu bbb-webrtc-recorder cache-files-list: bbb-webrtc-sfu.placeholder.sh bbb-webrtc-recorder.placeholder.sh - package: others - build-list: bbb-mkclean bbb-pads bbb-libreoffice-docker bbb-transcription-controller bigbluebutton + build-list: bbb-mkclean bbb-pads bbb-libreoffice-docker bbb-transcription-controller bigbluebutton bbb-livekit steps: - uses: actions/checkout@v3 - name: Merge branches diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e90daec7f5..6a8b70a7f8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -182,6 +182,11 @@ bbb-webrtc-recorder-build: script: - build/setup-inside-docker.sh bbb-webrtc-recorder +bbb-livekit: + extends: .build_job + script: + - build/setup-inside-docker.sh bbb-livekit + bbb-transcription-controller-build: extends: .build_job script: diff --git a/bbb-livekit/.gitkeep b/bbb-livekit/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/build/packages-template/bbb-livekit/after-install.sh b/build/packages-template/bbb-livekit/after-install.sh new file mode 100755 index 0000000000..c12766bb67 --- /dev/null +++ b/build/packages-template/bbb-livekit/after-install.sh @@ -0,0 +1,24 @@ +#!/bin/bash -e + +if [ ! -f /etc/bigbluebutton/livekit.yaml ]; then + keys="$(livekit-server generate-keys|awk 'BEGIN { ORS=": "} { print $3 }')" + (umask 007; cat << EOT +# This file will be merged with /usr/share/livekit-server/livekit.yaml +# on startup. Settings specified here will take precedence. + +logging: + level: debug +keys: + $keys +cat << EOT > /etc/bigbluebutton/livekit.yaml + chown bigbluebutton:bigbluebutton /etc/bigbluebutton/livekit.yaml + fi + + if [ ! -f /.dockerenv ]; then + systemctl enable livekit-server.service + systemctl daemon-reload + startService livekit-server.service || echo "livekit-server service could not be registered or started" + fi +EOT + ) +fi diff --git a/build/packages-template/bbb-livekit/after-remove.sh b/build/packages-template/bbb-livekit/after-remove.sh new file mode 100755 index 0000000000..5bbf650c74 --- /dev/null +++ b/build/packages-template/bbb-livekit/after-remove.sh @@ -0,0 +1,12 @@ +#!/bin/bash -e + +case "$1" in + remove|purge) + systemctl daemon-reload + ;; + failed-upgrade|abort-upgrade|abort-install|disappear) + ;; + *) + echo "postinst called with unknown argument \`\$1'" >&2 + ;; +esac diff --git a/build/packages-template/bbb-livekit/before-install.sh b/build/packages-template/bbb-livekit/before-install.sh new file mode 100644 index 0000000000..9436d9fd04 --- /dev/null +++ b/build/packages-template/bbb-livekit/before-install.sh @@ -0,0 +1,14 @@ +#!/bin/bash -e + +case "$1" in + install|upgrade|1|2) + ;; + + abort-upgrade) + ;; + + *) + echo "## preinst called with unknown argument \`$1'" >&2 + ;; +esac + diff --git a/build/packages-template/bbb-livekit/before-remove.sh b/build/packages-template/bbb-livekit/before-remove.sh new file mode 100755 index 0000000000..a09735ffaf --- /dev/null +++ b/build/packages-template/bbb-livekit/before-remove.sh @@ -0,0 +1,4 @@ +#!/bin/bash -e + +stopService livekit-server || echo "livekit-server could not be unregistered or stopped" + diff --git a/build/packages-template/bbb-livekit/build.sh b/build/packages-template/bbb-livekit/build.sh new file mode 100755 index 0000000000..6045cb0bdb --- /dev/null +++ b/build/packages-template/bbb-livekit/build.sh @@ -0,0 +1,45 @@ +#!/bin/bash -ex + +TARGET=`basename $(pwd)` + +SERVER_VERSION=1.5.1 +CLI_VERSION=1.3.0 + +PACKAGE=$(echo $TARGET | cut -d'_' -f1) +VERSION=$(echo $TARGET | cut -d'_' -f2) +DISTRO=$(echo $TARGET | cut -d'_' -f3) + +BUILDDIR=$PWD +DESTDIR=$BUILDDIR/staging + +# +# Clear staging directory for build + +rm -rf $DESTDIR +mkdir -p $DESTDIR + +. ./opts-$DISTRO.sh + +mkdir -p $DESTDIR/usr/share/bigbluebutton/nginx +cp livekit.nginx $DESTDIR/usr/share/bigbluebutton/nginx + +mkdir -p $DESTDIR/lib/systemd/system/ +cp livekit-server.service $DESTDIR/lib/systemd/system + +mkdir -p $DESTDIR/usr/share/livekit-server +cp livekit.yaml $DESTDIR/usr/share/livekit-server + +mkdir -p $DESTDIR/usr/bin + +curl https://github.com/livekit/livekit/releases/download/v${SERVER_VERSION}/livekit_${SERVER_VERSION}_linux_amd64.tar.gz -Lo - | tar -C $DESTDIR/usr/bin -xzf - livekit-server +curl https://github.com/livekit/livekit-cli/releases/download/v${CLI_VERSION}/livekit-cli_${CLI_VERSION}_linux_amd64.tar.gz -Lo - | tar -C $DESTDIR/usr/bin -xzf - livekit-cli + +fpm -s dir -C $DESTDIR -n $PACKAGE \ + --version $VERSION --epoch 2 \ + --before-install before-install.sh \ + --after-install after-install.sh \ + --before-remove before-remove.sh \ + --after-remove after-remove.sh \ + --description "BigBlueButton build of LiveKit Server" \ + $DIRECTORIES \ + $OPTS diff --git a/build/packages-template/bbb-livekit/livekit-server.service b/build/packages-template/bbb-livekit/livekit-server.service new file mode 100644 index 0000000000..29f44ddd0d --- /dev/null +++ b/build/packages-template/bbb-livekit/livekit-server.service @@ -0,0 +1,20 @@ +[Unit] +Description=LiveKit Server +Wants=redis-server.service +After=syslog.target network.target freeswitch.service redis-server.service +PartOf=bigbluebutton.target + +[Service] +Type=exec +ExecStartPre=-bash -c "umask 077; yq eval-all '. as $item ireduce ({}; . * $item )' /usr/share/livekit-server/livekit.yaml /etc/bigbluebutton/livekit.yaml > ${RUNTIME_DIRECTORY}/livekit.yaml" +ExecStart=/usr/bin/livekit-server --config "${RUNTIME_DIRECTORY}/livekit.yaml" +ExecStopPost=rm ${RUNTIME_DIRECTORY}/livekit.yaml +RuntimeDirectory=livekit-server +Restart=always +User=bigbluebutton +Group=bigbluebutton +CPUSchedulingPolicy=fifo +Nice=19 + +[Install] +WantedBy=multi-user.target bigbluebutton.target diff --git a/build/packages-template/bbb-livekit/livekit.nginx b/build/packages-template/bbb-livekit/livekit.nginx new file mode 100644 index 0000000000..c29556250e --- /dev/null +++ b/build/packages-template/bbb-livekit/livekit.nginx @@ -0,0 +1,11 @@ +location /livekit/ { + proxy_pass http://127.0.0.1:7880/; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + + proxy_read_timeout 60s; + proxy_send_timeout 60s; + client_body_timeout 60s; + send_timeout 60s; +} diff --git a/build/packages-template/bbb-livekit/livekit.yaml b/build/packages-template/bbb-livekit/livekit.yaml new file mode 100644 index 0000000000..d0ca846755 --- /dev/null +++ b/build/packages-template/bbb-livekit/livekit.yaml @@ -0,0 +1,12 @@ +port: 7880 +log_level: debug +# when enabled, LiveKit will expose prometheus metrics on :6789/metrics +#prometheus_port: 6789 +rtc: + port_range_start: 16384 + port_range_end: 32768 + use_external_ip: false +redis: +# # redis is recommended for production deploys +# address: servername:6379 + diff --git a/build/packages-template/bbb-livekit/opts-jammy.sh b/build/packages-template/bbb-livekit/opts-jammy.sh new file mode 100755 index 0000000000..9d88d62164 --- /dev/null +++ b/build/packages-template/bbb-livekit/opts-jammy.sh @@ -0,0 +1,3 @@ +. ./opts-global.sh + +OPTS="$OPTS -t deb -d yq"