#!/bin/sh
# script for modding jistsi configuration samples to uncomment below
# privacy: disable gravatar as third-party request
#sed -i -e "s~// disableThirdPartyRequests.*~disableThirdPartyRequests: true,~" /var/packages/Jitsi-Meet/etc/web/config.js
#echo "disable gravatar.."
# privacy: disable video-background function as it uses storage.googleapis.com
#sed -i -e "s~DISABLE_VIDEO_BACKGROUND.*~DISABLE_VIDEO_BACKGROUND: true,~" /var/packages/Jitsi-Meet/etc/web/interface_config.js
#echo "disable video-background option.."
# privacy: enable do-not store room
#sed -i -e "s~// doNotStoreRoom.*~doNotStoreRoom: true,~" /var/packages/Jitsi-Meet/etc/web/config.js
#echo "enable do-not store room.."
# privacy: disable welcome page: guest will be redirected to random room which they cannot open
#sed -i -e "s~enableWelcomePage.*~enableWelcomePage: false,~" /var/packages/Jitsi-Meet/etc/web/config.js
#echo "disable welcome page.."
# security: add more headers to /var/packages/Jitsi-Meet/etc/web/nginx/ssl.conf as per advise at securityheaders.com
# ok: Strict-Transport-Security, X-Content-Type-Options, X-XSS-Protection, add X-Frame-Options, Content-Security-Policy
# for Referrer-Policy use same-origin instead of stricter no-referrer
# for Content-Security-Policy do not use default-src 'self' and script-src 'self' aka same origin as it breaks functionality
#if ! grep -q "X-Frame-Options" /var/packages/Jitsi-Meet/etc/web/nginx/ssl.conf ; then
# echo "add security headers (strict, no foreign iframe) to jitsi_web nginx.."
# sed -i -e "s~# headers~# headers\nadd_header Content-Security-Policy \"img-src 'self'; media-src 'self'; font-src 'self'; form-action 'self';\";~" /var/packages/Jitsi-Meet/etc/web/nginx/ssl.conf
# sed -i -e "s~# headers~# headers\nadd_header Referrer-Policy same-origin;~" /var/packages/Jitsi-Meet/etc/web/nginx/ssl.conf
# sed -i -e "s~# headers~# headers\nadd_header X-Frame-Options "SAMEORIGIN" always;~" /var/packages/Jitsi-Meet/etc/web/nginx/ssl.conf
#fi
# video resolution and size: uncomment and adjust below
#sed -i -e "s~^config.constraints.video.height.*~config.constraints.video.height = { min: 480, max: 720, ideal: 640 };~" /var/packages/Jitsi-Meet/etc/web/config.js
#sed -i -e "s~^config.constraints.video.width.*~config.constraints.video.width = { min: 720, max: 1080, ideal: 960 };~" /var/packages/Jitsi-Meet/etc/web/config.js
#sed -i -e "s~^config.constraints.video.framerate.*~config.constraints.video.framerate = { min: 10, max: 30, ideal: 20 }~" /var/packages/Jitsi-Meet/etc/web/config.js
# lighter performance: video feed limited to n number of speakers last active, sample 4, unlimited -1
#sed -i -e "s~channelLastN.*~channelLastN: 4,~" /var/packages/Jitsi-Meet/etc/web/config.js
#sed -i -e "s~// enableLayerSuspension.*~enableLayerSuspension: true,~" /var/packages/Jitsi-Meet/etc/web/config.js
#echo "limit speakers video transferred to 4 and enabling LayerSuspension.."
# switch off GENERATE_ROOMNAMES
#sed -i -e "s~GENERATE_ROOMNAMES_ON_WELCOME_PAGE.*~GENERATE_ROOMNAMES_ON_WELCOME_PAGE: false,~" /var/packages/Jitsi-Meet/etc/web/interface_config.js
#echo switching off random room name generation.."
# bugfix authentication issue #1018 in stable-5765 adding client-proxy
if ! grep -q "client-proxy" /var/packages/Jitsi-Meet/etc/jicofo/jicofo.conf ; then
sed -i -E '/^\s+disable-certificate-verification = true/a \\t\tclient-proxy = "focus.meet.jitsi"' /var/packages/Jitsi-Meet/etc/jicofo/jicofo.conf
echo "adding client-proxy post disable-certificate-verification in jicofo.conf.."
fi
# web appearance: to modify welcome-page adjust /usr/share/jitsi-meet/static in jitsi-meet container, e.g. adding html, watermark
# echo "adding modified html and watermark logo.."
#docker cp -a /var/packages/Jitsi-Meet/etc/*.html jitsi_web:/usr/share/jitsi-meet/static/
#docker cp -a /var/packages/Jitsi-Meet/etc/watermark.png jitsi_web:/usr/share/jitsi-meet/images/