Periodically remove old recordings

This commit is contained in:
omidmaldar 2021-10-17 21:26:26 +03:00
parent 40db868ccd
commit 9a8825a73b
7 changed files with 98 additions and 16 deletions

View File

@ -115,7 +115,7 @@ services:
- ./conf/dialplan_public:/etc/freeswitch/dialplan/public_docker - ./conf/dialplan_public:/etc/freeswitch/dialplan/public_docker
- vol-freeswitch:/var/freeswitch/meetings - vol-freeswitch:/var/freeswitch/meetings
network_mode: host network_mode: host
nginx: nginx:
build: mod/nginx build: mod/nginx
restart: unless-stopped restart: unless-stopped
@ -156,7 +156,7 @@ services:
retries: 30 retries: 30
networks: networks:
bbb-net: bbb-net:
ipv4_address: 10.7.7.5 ipv4_address: 10.7.7.5
mongodb: mongodb:
image: mongo:4.4 image: mongo:4.4
@ -177,7 +177,7 @@ services:
kurento: kurento:
image: kurento/kurento-media-server:6.16 image: kurento/kurento-media-server:6.16
restart: unless-stopped restart: unless-stopped
environment: environment:
KMS_STUN_IP: ${STUN_IP} KMS_STUN_IP: ${STUN_IP}
KMS_STUN_PORT: ${STUN_PORT} KMS_STUN_PORT: ${STUN_PORT}
KMS_MIN_PORT: 24577 KMS_MIN_PORT: 24577
@ -188,7 +188,7 @@ services:
network_mode: host network_mode: host
volumes: volumes:
- vol-kurento:/var/kurento - vol-kurento:/var/kurento
webrtc-sfu: webrtc-sfu:
build: mod/webrtc-sfu build: mod/webrtc-sfu
restart: unless-stopped restart: unless-stopped
@ -249,7 +249,7 @@ services:
networks: networks:
bbb-net: bbb-net:
ipv4_address: 10.7.7.20 ipv4_address: 10.7.7.20
periodic: periodic:
build: mod/periodic build: mod/periodic
restart: unless-stopped restart: unless-stopped
@ -258,6 +258,12 @@ services:
volumes: volumes:
- /var/run/docker.sock:/var/run/docker.sock - /var/run/docker.sock:/var/run/docker.sock
- bigbluebutton:/var/bigbluebutton - bigbluebutton:/var/bigbluebutton
tmpfs:
- /var/log/bigbluebutton
environment:
ENABLE_RECORDING: ${ENABLE_RECORDING}
REMOVE_OLD_RECORDING: ${REMOVE_OLD_RECORDING}
RECORDING_MAX_AGE_DAYS: ${RECORDING_MAX_AGE_DAYS}
networks: networks:
bbb-net: bbb-net:
ipv4_address: 10.7.7.12 ipv4_address: 10.7.7.12
@ -385,7 +391,7 @@ services:
prometheus-exporter: prometheus-exporter:
image: greenstatic/bigbluebutton-exporter:v0.7.0-preview2 image: greenstatic/bigbluebutton-exporter:v0.7.0-preview2
restart: unless-stopped restart: unless-stopped
environment: environment:
API_BASE_URL: http://10.7.7.1:8080/bigbluebutton/api/ API_BASE_URL: http://10.7.7.1:8080/bigbluebutton/api/
API_SECRET: ${SHARED_SECRET} API_SECRET: ${SHARED_SECRET}
RECORDINGS_METRICS_READ_FROM_DISK: "false" RECORDINGS_METRICS_READ_FROM_DISK: "false"

View File

@ -10,6 +10,8 @@ RUN apt-get update \
# -- install docker cli # -- install docker cli
COPY --from=library/docker:latest /usr/local/bin/docker /usr/bin/docker COPY --from=library/docker:latest /usr/local/bin/docker /usr/bin/docker
COPY bbb-restart-kms bbb-resync-freeswitch entrypoint.sh / COPY bbb-remove-old-recordings bbb-restart-kms bbb-resync-freeswitch entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"] RUN chmod +x bbb-remove-old-recordings
ENTRYPOINT ["/entrypoint.sh"]

View File

@ -0,0 +1,41 @@
#!/bin/bash
# Source: https://docs.bigbluebutton.org/admin/customize.html#delete-recordings-older-than-n-days
set -e
LOGFILE=/var/log/bigbluebutton/bbb-recording-cleanup-$(date --iso-8601='seconds' -u).log
shopt -s nullglob
NOW=$(date +%s)
echo "$(date --rfc-3339=seconds) Deleting recordings older than ${RECORDING_MAX_AGE_DAYS} days" >"${LOGFILE}"
# Find the name of recordings container in order to access `bbb-record` utility
BBB_RECORDINGS_CONTAINER_NAME=$(docker ps --filter "name=recordings" --filter "status=running" --format "{{.Names}}")
if [ $BBB_RECORDINGS_CONTAINER_NAME == "" ]; then
echo "$(date --rfc-3339=seconds) ERROR: recordings container is not running" >>"${LOGFILE}"
exit 1
fi
for donefile in /var/bigbluebutton/recording/status/published/*-presentation.done ; do
MTIME=$(stat -c %Y "${donefile}")
# Check the age of the recording
if [ $(( ( $NOW - $MTIME ) / 86400 )) -gt $RECORDING_MAX_AGE_DAYS ]; then
MEETING_ID=$(basename "${donefile}")
MEETING_ID=${MEETING_ID%-presentation.done}
echo "${MEETING_ID}" >> "${LOGFILE}"
docker exec "$BBB_RECORDINGS_CONTAINER_NAME" bbb-record --delete "${MEETING_ID}" >>"${LOGFILE}"
fi
done
for eventsfile in /var/bigbluebutton/recording/raw/*/events.xml ; do
MTIME=$(stat -c %Y "${eventsfile}")
# Check the age of the recording
if [ $(( ( $NOW - $MTIME ) / 86400 )) -gt $RECORDING_MAX_AGE_DAYS ]; then
MEETING_ID="${eventsfile%/events.xml}"
MEETING_ID="${MEETING_ID##*/}"
echo "${MEETING_ID}" >> "${LOGFILE}"
docker exec "$BBB_RECORDINGS_CONTAINER_NAME" bbb-record --delete "${MEETING_ID}" >>"${LOGFILE}"
fi
done

View File

@ -9,12 +9,17 @@ while :
do do
# restart kurento after 24h # restart kurento after 24h
/bbb-restart-kms /bbb-restart-kms
# resync freeswitch # resync freeswitch
/bbb-resync-freeswitch /bbb-resync-freeswitch
# delete presentations older than N days # delete presentations older than N days
find /var/bigbluebutton/ -maxdepth 1 -type d -name "*-*" -mtime +$history -exec rm -rf '{}' + find /var/bigbluebutton/ -maxdepth 1 -type d -name "*-*" -mtime +$history -exec rm -rf '{}' +
# delete recordings older than $RECORDING_MAX_AGE_DAYS
if [ "$ENABLE_RECORDING" == true ] && [ "$REMOVE_OLD_RECORDING" == true ]; then
/bbb-remove-old-recordings
fi
sleep 30m sleep 30m
done done

View File

@ -8,7 +8,7 @@
ENABLE_HTTPS_PROXY=true ENABLE_HTTPS_PROXY=true
# coturn (a TURN Server) # coturn (a TURN Server)
# requires either the abhove HTTPS Proxy to be enabled # requires either the abhove HTTPS Proxy to be enabled
# or TLS certificates to be mounted to container # or TLS certificates to be mounted to container
ENABLE_COTURN=true ENABLE_COTURN=true
#COTURN_TLS_CERT_PATH= #COTURN_TLS_CERT_PATH=
@ -28,12 +28,14 @@ ENABLE_GREENLIGHT=true
#ENABLE_PROMETHEUS_EXPORTER=true #ENABLE_PROMETHEUS_EXPORTER=true
# Recording # Recording
# IMPORTANT: this is currently a big privacy issues, because it will # IMPORTANT: this is currently a big privacy issues, because it will
# record everything which happens in the conference, even when the button # record everything which happens in the conference, even when the button
# suggets, that it does not. # suggets, that it does not.
# https://github.com/bigbluebutton/bigbluebutton/issues/9202 # https://github.com/bigbluebutton/bigbluebutton/issues/9202
# make sure that you get peoples consent, before they join a room # make sure that you get peoples consent, before they join a room
#ENABLE_RECORDING=true #ENABLE_RECORDING=true
#REMOVE_OLD_RECORDING=false
#RECORDING_MAX_AGE_DAYS=14
# ==================================== # ====================================
# SECRETS # SECRETS
@ -132,7 +134,7 @@ CHAT_START_CLOSED=false
# set to true to disable announcements "You are now (un-)muted" # set to true to disable announcements "You are now (un-)muted"
DISABLE_SOUND_MUTED=false DISABLE_SOUND_MUTED=false
# set to true to disable announcement "You are the only person in this conference" # set to true to disable announcement "You are the only person in this conference"
DISABLE_SOUND_ALONE=false DISABLE_SOUND_ALONE=false
# maximum count of breakout rooms per meeting # maximum count of breakout rooms per meeting
@ -224,7 +226,7 @@ ALLOW_GREENLIGHT_ACCOUNTS=true
# SMTP_AUTH=plain # SMTP_AUTH=plain
# SMTP_STARTTLS_AUTO=true # SMTP_STARTTLS_AUTO=true
# #
# If your mail server has a self-signed certificate, you'll also need to include the line below. # If your mail server has a self-signed certificate, you'll also need to include the line below.
# Please note that enable this presents its own security risks and should not be done unless necessary. # Please note that enable this presents its own security risks and should not be done unless necessary.
# SMTP_OPENSSL_VERIFY_MODE=none # SMTP_OPENSSL_VERIFY_MODE=none
# #

View File

@ -38,6 +38,8 @@ docker run \
-v $(pwd)/docker-compose.tmpl.yml:/docker-compose.tmpl.yml \ -v $(pwd)/docker-compose.tmpl.yml:/docker-compose.tmpl.yml \
-e DEV_MODE=${DEV_MODE:-false} \ -e DEV_MODE=${DEV_MODE:-false} \
-e ENABLE_RECORDING=${ENABLE_RECORDING:-false} \ -e ENABLE_RECORDING=${ENABLE_RECORDING:-false} \
-e REMOVE_OLD_RECORDING=${REMOVE_OLD_RECORDING:-false} \
-e RECORDING_MAX_AGE_DAYS=${RECORDING_MAX_AGE_DAYS:-14} \
-e ENABLE_HTTPS_PROXY=${ENABLE_HTTPS_PROXY:-false} \ -e ENABLE_HTTPS_PROXY=${ENABLE_HTTPS_PROXY:-false} \
-e ENABLE_WEBHOOKS=${ENABLE_WEBHOOKS:-false} \ -e ENABLE_WEBHOOKS=${ENABLE_WEBHOOKS:-false} \
-e ENABLE_COTURN=${ENABLE_COTURN:-false} \ -e ENABLE_COTURN=${ENABLE_COTURN:-false} \

View File

@ -43,10 +43,10 @@ then
echo " you must provide a relative or absolute path" echo " you must provide a relative or absolute path"
echo " to your certificates." echo " to your certificates."
while [[ -z "$CERTPATH" ]]; do while [[ -z "$CERTPATH" ]]; do
read -p "Please enter path to cert.pem: " CERTPATH read -p "Please enter path to cert.pem: " CERTPATH
done done
while [[ -z "$KEYPATH" ]]; do while [[ -z "$KEYPATH" ]]; do
read -p "Please enter path to key.pem: " KEYPATH read -p "Please enter path to key.pem: " KEYPATH
done done
fi fi
@ -72,6 +72,24 @@ while [[ ! $recording =~ ^(y|n)$ ]]; do
read -p "Choice (y/n): " recording read -p "Choice (y/n): " recording
done done
if [ "$recording" == "y" ]
then
remove_old_recording=""
while [[ ! $remove_old_recording =~ ^(y|n)$ ]]; do
read -p "Should old recordings be removed? (y/n): " remove_old_recording
done
if [ "$remove_old_recording" == "y" ]
then
recording_max_age_days=""
while [[ ! $recording_max_age_days =~ ^[0-9]{1,4}$ ]]; do
read -p "Please enter max age(days) for keeping recordings: " recording_max_age_days
done
fi
fi
ip_correct="" ip_correct=""
while [[ ! $ip_correct =~ ^(y|n)$ ]]; do while [[ ! $ip_correct =~ ^(y|n)$ ]]; do
read -p "Is $EXTERNAL_IPv4 your external IPv4 address? (y/n): " ip_correct read -p "Is $EXTERNAL_IPv4 your external IPv4 address? (y/n): " ip_correct
@ -124,6 +142,12 @@ then
sed -i "s/#ENABLE_RECORDING.*/ENABLE_RECORDING=true/" .env sed -i "s/#ENABLE_RECORDING.*/ENABLE_RECORDING=true/" .env
fi fi
if [ "$remove_old_recording" == "y" ]
then
sed -i "s/#REMOVE_OLD_RECORDING=.*/REMOVE_OLD_RECORDING=true/" .env
sed -i "s/#RECORDING_MAX_AGE_DAYS=.*/RECORDING_MAX_AGE_DAYS=$recording_max_age_days/" .env
fi
if [ "$coturn" == "y" ] if [ "$coturn" == "y" ]
then then
sed -i "s/.*TURN_SERVER=.*/TURN_SERVER=turns:$DOMAIN:5349?transport=tcp/" .env sed -i "s/.*TURN_SERVER=.*/TURN_SERVER=turns:$DOMAIN:5349?transport=tcp/" .env