|
|
@ -3,6 +3,26 @@
|
|
|
|
# SwITNet Ltd © - 2023, https://switnet.net/
|
|
|
|
# SwITNet Ltd © - 2023, https://switnet.net/
|
|
|
|
# GPLv3 or later.
|
|
|
|
# GPLv3 or later.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 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"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
while getopts m: option
|
|
|
|
while getopts m: option
|
|
|
|
do
|
|
|
|
do
|
|
|
|
case "${option}"
|
|
|
|
case "${option}"
|
|
|
@ -47,14 +67,15 @@ EXCAL_PORT_FILE="$EXCALIDRAW_HOME/backend/src/index.ts"
|
|
|
|
# Test for matches
|
|
|
|
# Test for matches
|
|
|
|
test_match() {
|
|
|
|
test_match() {
|
|
|
|
if grep -q "$1" "$2" ; then
|
|
|
|
if grep -q "$1" "$2" ; then
|
|
|
|
echo "It is possible to setup $(basename "$2"), continuing..."
|
|
|
|
echo "$(basename "$2") - OK..."
|
|
|
|
else
|
|
|
|
else
|
|
|
|
echo "It is not possible to setup $(basename "$2"), stopping here."
|
|
|
|
echo "$(basename "$2"), FAIL..."
|
|
|
|
echo "Please report this to https://forge.switnet.net/switnet/quick-jibri-installer"
|
|
|
|
echo "Please report this to https://forge.switnet.net/switnet/quick-jibri-installer"
|
|
|
|
exit
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
# Make sure we can rely on the match strings.
|
|
|
|
# Make sure we can rely on the match strings.
|
|
|
|
|
|
|
|
printf "Testing match strings on config files.\n"
|
|
|
|
test_match "$WS_MATCH1" "$WS_CONF"
|
|
|
|
test_match "$WS_MATCH1" "$WS_CONF"
|
|
|
|
test_match "$PROS_MATCH1" "$PROSODY_FILE"
|
|
|
|
test_match "$PROS_MATCH1" "$PROSODY_FILE"
|
|
|
|
test_match "$PROS_MATCH2" "$PROSODY_FILE"
|
|
|
|
test_match "$PROS_MATCH2" "$PROSODY_FILE"
|
|
|
@ -62,6 +83,9 @@ test_match "$PROS_MATCH3" "$PROSODY_FILE"
|
|
|
|
test_match "$PROS_MATCH3" "$PROSODY_FILE"
|
|
|
|
test_match "$PROS_MATCH3" "$PROSODY_FILE"
|
|
|
|
test_match "$CONFIG_MATCH1" "$MEET_CONF"
|
|
|
|
test_match "$CONFIG_MATCH1" "$MEET_CONF"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#--------------------------------------------------
|
|
|
|
|
|
|
|
print_title "Setup excalidraw backend."
|
|
|
|
|
|
|
|
#--------------------------------------------------
|
|
|
|
adduser --home "$EXCALIDRAW_HOME" --disabled-password --gecos "" excalidraw
|
|
|
|
adduser --home "$EXCALIDRAW_HOME" --disabled-password --gecos "" excalidraw
|
|
|
|
git clone https://github.com/jitsi/excalidraw-backend "$EXCALIDRAW_HOME/backend"
|
|
|
|
git clone https://github.com/jitsi/excalidraw-backend "$EXCALIDRAW_HOME/backend"
|
|
|
|
test_match "$EXCAL_MATCH1" "$EXCAL_PORT_FILE"
|
|
|
|
test_match "$EXCAL_MATCH1" "$EXCAL_PORT_FILE"
|
|
|
@ -70,18 +94,22 @@ chown -R excalidraw:excalidraw "$EXCALIDRAW_HOME"
|
|
|
|
cd "$EXCALIDRAW_HOME/backend"
|
|
|
|
cd "$EXCALIDRAW_HOME/backend"
|
|
|
|
sudo -u excalidraw cp .env.development .env.production
|
|
|
|
sudo -u excalidraw cp .env.development .env.production
|
|
|
|
|
|
|
|
|
|
|
|
# Keep used replacement port to get some sort of standarization.
|
|
|
|
# Use documented port to get some sort of standarization.
|
|
|
|
if sed -n "/$EXCAL_MATCH1/,/});/p" "$EXCAL_PORT_FILE" |grep -q port: ; then
|
|
|
|
if sed -n "/$EXCAL_MATCH1/,/});/p" "$EXCAL_PORT_FILE" |grep -q port: ; then
|
|
|
|
echo "Update predefined port for metrics to $EXCAL_NEW_PORT"
|
|
|
|
echo "> Update predefined port for metrics to $EXCAL_NEW_PORT\n"
|
|
|
|
sed -i "/$EXCAL_MATCH1/,/});/s|port:.*,|port: $EXCAL_NEW_PORT,|" "$EXCAL_PORT_FILE"
|
|
|
|
sed -i "/$EXCAL_MATCH1/,/});/s|port:.*,|port: $EXCAL_NEW_PORT,|" "$EXCAL_PORT_FILE"
|
|
|
|
else
|
|
|
|
else
|
|
|
|
echo "Define new port from default to $EXCAL_NEW_PORT"
|
|
|
|
echo "> Define new port from default to $EXCAL_NEW_PORT\n"
|
|
|
|
sed -i "/$EXCAL_MATCH1/a \ \ \ \ port: $EXCAL_NEW_PORT," "$EXCAL_PORT_FILE"
|
|
|
|
sed -i "/$EXCAL_MATCH1/a \ \ \ \ port: $EXCAL_NEW_PORT," "$EXCAL_PORT_FILE"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf "\nInstalling npm backend.\n"
|
|
|
|
sudo -u excalidraw npm install
|
|
|
|
sudo -u excalidraw npm install
|
|
|
|
sudo -u excalidraw npm run build
|
|
|
|
sudo -u excalidraw npm run build
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#--------------------------------------------------
|
|
|
|
|
|
|
|
print_title "Setup system & jitsi config files."
|
|
|
|
|
|
|
|
#--------------------------------------------------
|
|
|
|
# Enable websocket on nginx
|
|
|
|
# Enable websocket on nginx
|
|
|
|
sed -i "/$WS_MATCH1/i \\\n" "$WS_CONF"
|
|
|
|
sed -i "/$WS_MATCH1/i \\\n" "$WS_CONF"
|
|
|
|
sed -i "/$WS_MATCH1/i \ \ \ \ location = /socket.io/ {" "$WS_CONF"
|
|
|
|
sed -i "/$WS_MATCH1/i \ \ \ \ location = /socket.io/ {" "$WS_CONF"
|
|
|
@ -95,9 +123,9 @@ sed -i "/$WS_MATCH1/i \ \ \ \ }" "$WS_CONF"
|
|
|
|
sed -i "/$WS_MATCH1/i \\\n" "$WS_CONF"
|
|
|
|
sed -i "/$WS_MATCH1/i \\\n" "$WS_CONF"
|
|
|
|
|
|
|
|
|
|
|
|
if grep -rq room_metadata /etc/prosody/conf.d/ ;then
|
|
|
|
if grep -rq room_metadata /etc/prosody/conf.d/ ;then
|
|
|
|
echo "Prosody seems to be already configured."
|
|
|
|
echo "> Prosody seems to be already configured."
|
|
|
|
else
|
|
|
|
else
|
|
|
|
echo "Setting up prosody for whiteboard..."
|
|
|
|
echo "> Setting up prosody for whiteboard..."
|
|
|
|
# Modules enabled
|
|
|
|
# Modules enabled
|
|
|
|
sed -i "/$PROS_MATCH1/a \ \ \ \ \ \ \ \ \"room_metadata\";" "$PROSODY_FILE"
|
|
|
|
sed -i "/$PROS_MATCH1/a \ \ \ \ \ \ \ \ \"room_metadata\";" "$PROSODY_FILE"
|
|
|
|
# Define internal component
|
|
|
|
# Define internal component
|
|
|
@ -110,9 +138,9 @@ else
|
|
|
|
sed -i "/$PROS_MATCH3/i \\\n" "$PROSODY_FILE"
|
|
|
|
sed -i "/$PROS_MATCH3/i \\\n" "$PROSODY_FILE"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
echo "Checking for $(basename "$MEET_CONF") setup."
|
|
|
|
echo "Checking for whitebord setup at $(basename "$MEET_CONF")."
|
|
|
|
if [ -z "$(sed -n '/whiteboard: {/,/},/p' "$MEET_CONF")" ]; then
|
|
|
|
if [ -z "$(sed -n '/whiteboard: {/,/},/p' "$MEET_CONF")" ]; then
|
|
|
|
echo "No present configuration on current config.js file"
|
|
|
|
echo "> No present configuration on current config.js file"
|
|
|
|
sed -i "/$CONFIG_MATCH1/i \\\n" "$MEET_CONF"
|
|
|
|
sed -i "/$CONFIG_MATCH1/i \\\n" "$MEET_CONF"
|
|
|
|
sed -i "/$CONFIG_MATCH1/i \ \ \ \ whiteboard: {" "$MEET_CONF"
|
|
|
|
sed -i "/$CONFIG_MATCH1/i \ \ \ \ whiteboard: {" "$MEET_CONF"
|
|
|
|
sed -i "/$CONFIG_MATCH1/i \ \ \ \ \ \ \ \ enabled: true," "$MEET_CONF"
|
|
|
|
sed -i "/$CONFIG_MATCH1/i \ \ \ \ \ \ \ \ enabled: true," "$MEET_CONF"
|
|
|
@ -120,24 +148,24 @@ if [ -z "$(sed -n '/whiteboard: {/,/},/p' "$MEET_CONF")" ]; then
|
|
|
|
sed -i "/$CONFIG_MATCH1/i \ \ \ \ }," "$MEET_CONF"
|
|
|
|
sed -i "/$CONFIG_MATCH1/i \ \ \ \ }," "$MEET_CONF"
|
|
|
|
sed -i "/$CONFIG_MATCH1/i \\\n" "$MEET_CONF"
|
|
|
|
sed -i "/$CONFIG_MATCH1/i \\\n" "$MEET_CONF"
|
|
|
|
else
|
|
|
|
else
|
|
|
|
echo "Enabling configuration on current config.js file"
|
|
|
|
echo "> Enabling configuration on current config.js file"
|
|
|
|
sed -i "/whiteboard: {/,/},/s|// ||" "$MEET_CONF"
|
|
|
|
sed -i "/whiteboard: {/,/},/s|// ||" "$MEET_CONF"
|
|
|
|
sed -i "/collabServerBaseUrl:/s|'https://.*'|'https://$DOMAIN'|" "$MEET_CONF"
|
|
|
|
sed -i "/collabServerBaseUrl:/s|'https://.*'|'https://$DOMAIN'|" "$MEET_CONF"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if sed -n '/toolbarButtons: \[/,/\],/p' "$MEET_CONF" | \
|
|
|
|
if sed -n '/toolbarButtons: \[/,/\],/p' "$MEET_CONF" | \
|
|
|
|
grep -v '//'| grep -q whiteboard ; then
|
|
|
|
grep -v '//'| grep -q whiteboard ; then
|
|
|
|
echo "Whiteboard toolbar already enabled."
|
|
|
|
echo "> Whiteboard toolbar already enabled."
|
|
|
|
elif sed -n '/toolbarButtons: \[/,/\],/p' "$MEET_CONF" | \
|
|
|
|
elif sed -n '/toolbarButtons: \[/,/\],/p' "$MEET_CONF" | \
|
|
|
|
grep -v '//'|grep -q toolbarButtons: ; then
|
|
|
|
grep -v '//'|grep -q toolbarButtons: ; then
|
|
|
|
echo "Enabling whiteboard toolbar."
|
|
|
|
echo "> Enabling whiteboard toolbar."
|
|
|
|
sed -i "/toolbarButtons:/a \ \ \ \ \ \ \ 'whiteboard'," "$MEET_CONF"
|
|
|
|
sed -i "/toolbarButtons:/a \ \ \ \ \ \ \ 'whiteboard'," "$MEET_CONF"
|
|
|
|
else
|
|
|
|
else
|
|
|
|
echo "ToolbarButtons not customized, whiteboard should be enabled by default,"
|
|
|
|
echo "> ToolbarButtons not customized, whiteboard should be enabled by default,"
|
|
|
|
echo "otherwise, please report to: https://forge.switnet.net/switnet/quick-jibri-installer/issues"
|
|
|
|
echo " otherwise, please report to: https://forge.switnet.net/switnet/quick-jibri-installer/issues"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Systemd service
|
|
|
|
printf "\n# Add systemd service\n"
|
|
|
|
cat << EOF > /etc/systemd/system/excalidraw.service
|
|
|
|
cat << EOF > /etc/systemd/system/excalidraw.service
|
|
|
|
[Unit]
|
|
|
|
[Unit]
|
|
|
|
Description=Excalidraw backend
|
|
|
|
Description=Excalidraw backend
|
|
|
@ -158,4 +186,4 @@ EOF
|
|
|
|
systemctl enable excalidraw.service
|
|
|
|
systemctl enable excalidraw.service
|
|
|
|
systemctl start excalidraw.service
|
|
|
|
systemctl start excalidraw.service
|
|
|
|
|
|
|
|
|
|
|
|
echo -e "\nExcalidraw installation/setup complete!\n"
|
|
|
|
printwc "${Green}" "\nExcalidraw setup complete!\n"
|
|
|
|