2023-11-08 06:36:32 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Excalidraw Jitsi Backend Installer
|
2023-11-10 06:51:18 +00:00
|
|
|
#
|
|
|
|
# Based on:
|
|
|
|
# - https://community.jitsi.org/t/118883
|
|
|
|
#
|
2024-03-21 20:09:38 +00:00
|
|
|
# SwITNet Ltd © - 2024, https://switnet.net/
|
2023-11-08 06:36:32 +00:00
|
|
|
# GPLv3 or later.
|
|
|
|
|
2023-11-10 05:30:05 +00:00
|
|
|
# Reset
|
|
|
|
Color_Off='\e[0m' # Text Reset
|
|
|
|
# Regular Colors
|
|
|
|
Black='\e[0;30m' # Black
|
|
|
|
Red='\e[0;31m' # Red
|
|
|
|
Green='\e[0;32m' # Green
|
|
|
|
Yellow='\e[0;33m' # Yellow
|
|
|
|
Blue='\e[0;34m' # Blue
|
|
|
|
Purple='\e[0;35m' # Purple
|
|
|
|
Cyan='\e[0;36m' # Cyan
|
|
|
|
|
|
|
|
printwc() {
|
|
|
|
printf "%b$2%b" "$1" "${Color_Off}"
|
|
|
|
}
|
|
|
|
print_title() {
|
|
|
|
printwc "${Blue}" "\n#--------------------------------------------------"
|
|
|
|
printwc "${Blue}" "\n# $1"
|
|
|
|
printwc "${Blue}" "\n#--------------------------------------------------\n"
|
|
|
|
}
|
2023-11-21 08:03:59 +00:00
|
|
|
restart_jibri() {
|
|
|
|
if [ "$(dpkg-query -W -f='${Status}' "jibri" 2>/dev/null | grep -c "ok installed")" == "1" ]
|
|
|
|
then
|
|
|
|
systemctl restart jibri
|
|
|
|
systemctl restart jibri-icewm
|
|
|
|
systemctl restart jibri-xorg
|
|
|
|
else
|
|
|
|
echo "Jibri service not installed"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
restart_services() {
|
|
|
|
systemctl restart jitsi-videobridge2
|
|
|
|
systemctl restart jicofo
|
|
|
|
restart_jibri
|
|
|
|
systemctl restart prosody
|
|
|
|
}
|
2023-11-21 08:15:49 +00:00
|
|
|
test_match() {
|
|
|
|
if grep -q "$1" "$2" ; then
|
|
|
|
echo "$(basename "$2") - OK..."
|
|
|
|
else
|
|
|
|
echo "$(basename "$2"), FAIL..."
|
|
|
|
echo "Please report this to https://forge.switnet.net/switnet/quick-jibri-installer"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
}
|
2023-11-10 05:30:05 +00:00
|
|
|
|
2023-11-08 06:36:32 +00:00
|
|
|
while getopts m: option
|
|
|
|
do
|
|
|
|
case "${option}"
|
|
|
|
in
|
|
|
|
m) MODE=${OPTARG};;
|
|
|
|
\?) echo "Usage: sudo bash ./$0 [-m debug]" && exit;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
#DEBUG
|
|
|
|
if [ "$MODE" = "debug" ]; then
|
|
|
|
set -x
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! [ "$(id -u)" = 0 ]; then
|
|
|
|
echo "You need to be root or have sudo privileges!"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
clear
|
|
|
|
echo -e '\n
|
|
|
|
########################################################################
|
|
|
|
Excalidraw Jitsi Backend Installer
|
|
|
|
########################################################################
|
|
|
|
by Software, IT & Networks Ltd
|
|
|
|
\n'
|
|
|
|
|
|
|
|
DOMAIN="$(find /etc/prosody/conf.d/ -name \*.lua|awk -F'.cfg' '!/localhost/{print $1}'|xargs basename)"
|
|
|
|
WS_CONF="/etc/nginx/sites-available/$DOMAIN.conf"
|
|
|
|
PROSODY_FILE="/etc/prosody/conf.d/$DOMAIN.cfg.lua"
|
|
|
|
MEET_CONF="/etc/jitsi/meet/$DOMAIN-config.js"
|
|
|
|
WS_MATCH1='# ensure all static content can always be found first'
|
|
|
|
PROS_MATCH1='"av_moderation";'
|
|
|
|
PROS_MATCH2='breakout_rooms_muc = "breakout.'
|
|
|
|
PROS_MATCH3='VirtualHost "recorder.'
|
2023-11-21 08:03:59 +00:00
|
|
|
CONFIG_MATCH1='List of undocumented settings used in jitsi-meet'
|
2023-11-08 06:36:32 +00:00
|
|
|
EXCALIDRAW_HOME="/opt/excalidraw"
|
|
|
|
EXCAL_MATCH1="prometheus.metrics(io"
|
|
|
|
EXCAL_NEW_PORT="9091"
|
2023-11-09 00:16:40 +00:00
|
|
|
EXCAL_PORT_FILE="$EXCALIDRAW_HOME/backend/src/index.ts"
|
2023-11-08 06:36:32 +00:00
|
|
|
|
|
|
|
# Make sure we can rely on the match strings.
|
2023-11-10 05:30:05 +00:00
|
|
|
printf "Testing match strings on config files.\n"
|
2023-11-08 06:36:32 +00:00
|
|
|
test_match "$WS_MATCH1" "$WS_CONF"
|
|
|
|
test_match "$PROS_MATCH1" "$PROSODY_FILE"
|
|
|
|
test_match "$PROS_MATCH2" "$PROSODY_FILE"
|
|
|
|
test_match "$PROS_MATCH3" "$PROSODY_FILE"
|
|
|
|
test_match "$PROS_MATCH3" "$PROSODY_FILE"
|
|
|
|
test_match "$CONFIG_MATCH1" "$MEET_CONF"
|
|
|
|
|
2023-11-10 05:30:05 +00:00
|
|
|
#--------------------------------------------------
|
|
|
|
print_title "Setup excalidraw backend."
|
|
|
|
#--------------------------------------------------
|
2023-11-08 06:36:32 +00:00
|
|
|
adduser --home "$EXCALIDRAW_HOME" --disabled-password --gecos "" excalidraw
|
|
|
|
git clone https://github.com/jitsi/excalidraw-backend "$EXCALIDRAW_HOME/backend"
|
2023-11-09 00:16:40 +00:00
|
|
|
test_match "$EXCAL_MATCH1" "$EXCAL_PORT_FILE"
|
2023-11-08 06:36:32 +00:00
|
|
|
|
|
|
|
chown -R excalidraw:excalidraw "$EXCALIDRAW_HOME"
|
|
|
|
cd "$EXCALIDRAW_HOME/backend"
|
|
|
|
sudo -u excalidraw cp .env.development .env.production
|
|
|
|
|
2023-11-10 05:29:32 +00:00
|
|
|
# Use documented port to get some sort of standarization.
|
2023-11-08 06:36:32 +00:00
|
|
|
if sed -n "/$EXCAL_MATCH1/,/});/p" "$EXCAL_PORT_FILE" |grep -q port: ; then
|
2023-11-21 08:03:59 +00:00
|
|
|
echo -e "> Update predefined port for metrics to $EXCAL_NEW_PORT\n"
|
2023-11-08 06:36:32 +00:00
|
|
|
sed -i "/$EXCAL_MATCH1/,/});/s|port:.*,|port: $EXCAL_NEW_PORT,|" "$EXCAL_PORT_FILE"
|
|
|
|
else
|
2023-11-21 08:03:59 +00:00
|
|
|
echo -e "> Define new port from default to $EXCAL_NEW_PORT\n"
|
2023-11-08 06:36:32 +00:00
|
|
|
sed -i "/$EXCAL_MATCH1/a \ \ \ \ port: $EXCAL_NEW_PORT," "$EXCAL_PORT_FILE"
|
|
|
|
fi
|
|
|
|
|
2023-11-21 08:03:59 +00:00
|
|
|
printf "Installing npm backend.\n"
|
2023-11-08 06:36:32 +00:00
|
|
|
sudo -u excalidraw npm install
|
|
|
|
sudo -u excalidraw npm run build
|
|
|
|
|
2023-11-10 05:30:05 +00:00
|
|
|
#--------------------------------------------------
|
|
|
|
print_title "Setup system & jitsi config files."
|
|
|
|
#--------------------------------------------------
|
2023-11-08 06:36:32 +00:00
|
|
|
# Enable websocket on nginx
|
|
|
|
sed -i "/$WS_MATCH1/i \\\n" "$WS_CONF"
|
|
|
|
sed -i "/$WS_MATCH1/i \ \ \ \ location = /socket.io/ {" "$WS_CONF"
|
|
|
|
sed -i "/$WS_MATCH1/i \ \ \ \ \ \ \ \ proxy_pass http://127.0.0.1:3002/socket.io/?\$args;" "$WS_CONF"
|
|
|
|
sed -i "/$WS_MATCH1/i \ \ \ \ \ \ \ \ proxy_http_version 1.1;" "$WS_CONF"
|
|
|
|
sed -i "/$WS_MATCH1/i \ \ \ \ \ \ \ \ proxy_set_header Upgrade \$http_upgrade;" "$WS_CONF"
|
|
|
|
sed -i "/$WS_MATCH1/i \ \ \ \ \ \ \ \ proxy_set_header Connection \"upgrade\";" "$WS_CONF"
|
|
|
|
sed -i "/$WS_MATCH1/i \ \ \ \ \ \ \ \ proxy_set_header Host \$http_host;" "$WS_CONF"
|
|
|
|
sed -i "/$WS_MATCH1/i \ \ \ \ \ \ \ \ tcp_nodelay on;" "$WS_CONF"
|
|
|
|
sed -i "/$WS_MATCH1/i \ \ \ \ }" "$WS_CONF"
|
|
|
|
sed -i "/$WS_MATCH1/i \\\n" "$WS_CONF"
|
|
|
|
|
|
|
|
if grep -rq room_metadata /etc/prosody/conf.d/ ;then
|
2023-11-10 05:30:05 +00:00
|
|
|
echo "> Prosody seems to be already configured."
|
2023-11-08 06:36:32 +00:00
|
|
|
else
|
2023-11-10 05:30:05 +00:00
|
|
|
echo "> Setting up prosody for whiteboard..."
|
2023-11-08 06:36:32 +00:00
|
|
|
# Modules enabled
|
|
|
|
sed -i "/$PROS_MATCH1/a \ \ \ \ \ \ \ \ \"room_metadata\";" "$PROSODY_FILE"
|
|
|
|
# Define internal component
|
|
|
|
sed -i "/$PROS_MATCH2/a \ \ \ \ room_metadata_component = \"metadata.$DOMAIN\"" "$PROSODY_FILE"
|
|
|
|
# Register component
|
|
|
|
sed -i "/$PROS_MATCH3/i \\\n" "$PROSODY_FILE"
|
|
|
|
sed -i "/$PROS_MATCH3/i Component \"metadata.$DOMAIN\" \"room_metadata_component\"" "$PROSODY_FILE"
|
|
|
|
sed -i "/$PROS_MATCH3/i \ \ \ \ muc_component = \"conference.$DOMAIN\"" "$PROSODY_FILE"
|
|
|
|
sed -i "/$PROS_MATCH3/i \ \ \ \ breakout_rooms_component = \"breakout.$DOMAIN\"" "$PROSODY_FILE"
|
|
|
|
sed -i "/$PROS_MATCH3/i \\\n" "$PROSODY_FILE"
|
|
|
|
fi
|
|
|
|
|
2023-11-21 08:15:49 +00:00
|
|
|
printf "\n# Checking for whitebord setup at %s.\n" "$(basename "$MEET_CONF")"
|
2023-11-08 06:40:56 +00:00
|
|
|
if [ -z "$(sed -n '/whiteboard: {/,/},/p' "$MEET_CONF")" ]; then
|
2023-11-10 05:29:32 +00:00
|
|
|
echo "> No present configuration on current config.js file"
|
2023-11-08 06:36:32 +00:00
|
|
|
sed -i "/$CONFIG_MATCH1/i \\\n" "$MEET_CONF"
|
|
|
|
sed -i "/$CONFIG_MATCH1/i \ \ \ \ whiteboard: {" "$MEET_CONF"
|
|
|
|
sed -i "/$CONFIG_MATCH1/i \ \ \ \ \ \ \ \ enabled: true," "$MEET_CONF"
|
|
|
|
sed -i "/$CONFIG_MATCH1/i \ \ \ \ \ \ \ \ collabServerBaseUrl: 'https://$DOMAIN'" "$MEET_CONF"
|
|
|
|
sed -i "/$CONFIG_MATCH1/i \ \ \ \ }," "$MEET_CONF"
|
|
|
|
sed -i "/$CONFIG_MATCH1/i \\\n" "$MEET_CONF"
|
|
|
|
else
|
2023-11-10 05:29:32 +00:00
|
|
|
echo "> Enabling configuration on current config.js file"
|
2023-11-08 06:36:32 +00:00
|
|
|
sed -i "/whiteboard: {/,/},/s|// ||" "$MEET_CONF"
|
|
|
|
sed -i "/collabServerBaseUrl:/s|'https://.*'|'https://$DOMAIN'|" "$MEET_CONF"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if sed -n '/toolbarButtons: \[/,/\],/p' "$MEET_CONF" | \
|
|
|
|
grep -v '//'| grep -q whiteboard ; then
|
2023-11-10 05:29:32 +00:00
|
|
|
echo "> Whiteboard toolbar already enabled."
|
2023-11-08 06:36:32 +00:00
|
|
|
elif sed -n '/toolbarButtons: \[/,/\],/p' "$MEET_CONF" | \
|
|
|
|
grep -v '//'|grep -q toolbarButtons: ; then
|
2023-11-10 05:29:32 +00:00
|
|
|
echo "> Enabling whiteboard toolbar."
|
2023-11-08 06:36:32 +00:00
|
|
|
sed -i "/toolbarButtons:/a \ \ \ \ \ \ \ 'whiteboard'," "$MEET_CONF"
|
|
|
|
else
|
2023-11-10 05:30:05 +00:00
|
|
|
echo "> ToolbarButtons not customized, whiteboard should be enabled by default,"
|
|
|
|
echo " otherwise, please report to: https://forge.switnet.net/switnet/quick-jibri-installer/issues"
|
2023-11-08 06:36:32 +00:00
|
|
|
fi
|
|
|
|
|
2023-11-10 05:30:05 +00:00
|
|
|
printf "\n# Add systemd service\n"
|
2023-11-08 06:36:32 +00:00
|
|
|
cat << EOF > /etc/systemd/system/excalidraw.service
|
|
|
|
[Unit]
|
|
|
|
Description=Excalidraw backend
|
|
|
|
After=network-online.target
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
User=excalidraw
|
|
|
|
Group=excalidraw
|
|
|
|
WorkingDirectory=$EXCALIDRAW_HOME/backend
|
|
|
|
ExecStart=npm start
|
|
|
|
Restart=always
|
|
|
|
RestartSec=5s
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
EOF
|
|
|
|
|
|
|
|
systemctl enable excalidraw.service
|
|
|
|
systemctl start excalidraw.service
|
|
|
|
|
2023-11-10 05:30:05 +00:00
|
|
|
printwc "${Green}" "\nExcalidraw setup complete!\n"
|
2023-11-21 08:03:59 +00:00
|
|
|
restart_services
|