Skip to content

Instantly share code, notes, and snippets.

@Ark74
Last active January 7, 2019 09:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ark74/01b1c87527169cc490488b2dcd5726c3 to your computer and use it in GitHub Desktop.
Save Ark74/01b1c87527169cc490488b2dcd5726c3 to your computer and use it in GitHub Desktop.
First attempt to simplify the jitsi-jibri installation. - DEPRECATED please check: https://github.com/switnet-ltd/quick-jibri-installer
#!/bin/bash
# Quick Jibri Installer
# Luis Guzman - ark@switnet.org
# GPLv3 or later
# SYSTEM SETUP
JITSI_UNS_REPO=$(apt-cache policy | grep http | grep jitsi | grep unstable | awk '{print $3}' | head -n 1 | cut -d "/" -f 1)
CERTBOT_REPO=$(apt-cache policy | grep http | grep certbot | head -n 1 | awk '{print $2}' | cut -d "/" -f 4)
APACHE_2=$(dpkg-query -W -f='${Status}' apache2 2>/dev/null | grep -c "ok installed")
NGINX=$(dpkg-query -W -f='${Status}' nginx 2>/dev/null | grep -c "ok installed")
DIST=$(lsb_release -sc)
check_serv() {
if [ "$APACHE_2" -eq 1 ] || [ "$NGINX" -eq 1 ]; then
echo "
Webserver already installed!
"
else
echo "
Installing nginx as webserver!
"
apt -yqq install nginx
fi
}
check_snd_driver() {
if [ "$(modprobe snd-aloop | grep -c "FATAL:")" == 1 ]; then
echo "Seems to be an issue with your audio driver, please fix this before continue."
exit
else
echo "Audio driver seems ok."
fi
}
update_certbot() {
if [ "$CERTBOT_REPO" = "certbot" ]; then
echo "
Cerbot repository already on the system!
Checking for updates...
"
apt -qq update
apt -yqq dist-upgrade
else
echo "
Adding cerbot (formerly letsencrypt) PPA repository for latest updates
"
echo "deb http://ppa.launchpad.net/certbot/certbot/ubuntu $DIST main" > /etc/apt/sources.list.d/certbot.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 75BCA694
apt -qq update
apt -yqq dist-upgrade
fi
}
clear
# Check correct user (sudo or root)
if [ "$EUID" == 0 ]
then echo "Ok, you have superuser powers"
else
echo "You should run it with root or sudo permissions."
exit
fi
# Jitsi-Meet Repo
echo "Add Jitsi key"
if [ "$JITSI_UNS_REPO" = "unstable" ]; then
echo "Jitsi unstable repository already installed"
else
echo 'deb https://download.jitsi.org unstable/' > /etc/apt/sources.list.d/jitsi-unstable.list
wget -qO - https://download.jitsi.org/jitsi-key.gpg.key | apt-key add -
fi
# Requirements
echo "We'll start by installing system requirements this may take a while please be patient..."
apt update -yq2
apt dist-upgrade -yq2
apt -yqq install \
bmon \
curl \
ffmpeg \
git \
htop \
linux-image-extra-virtual \
unzip \
wget
check_serv
# Installing Jitsi Framework
apt -yqq install \
jitsi-meet \
jibri
# ALSA - Loopback
echo "snd-aloop" | sudo tee -a /etc/modules
check_snd_driver
# Installing Google Chrome / ChromeDriver
echo "Installing Google Chrome Stable"
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/dl_google_com_linux_chrome_deb.list
apt update
apt install -yqq google-chrome-stable
rm -rf /etc/apt/sources.list.d/dl_google_com_linux_chrome_deb.list
echo "Installing Chromedriver"
CHD_VER=$(curl -sL https://chromedriver.storage.googleapis.com/LATEST_RELEASE)
wget https://chromedriver.storage.googleapis.com/$CHD_VER/chromedriver_linux64.zip -O /tmp/chromedriver_linux64.zip
unzip /tmp/chromedriver_linux64.zip -d /usr/local/bin/
chown root:root /usr/local/bin/chromedriver
chmod 0755 /usr/local/bin/chromedriver
rm -rf /tpm/chromedriver_linux64.zip
# Check Google Software Working
/usr/bin/google-chrome --version
/usr/local/bin/chromedriver --version
echo '
########################################################################
Starting Jibri configuration
########################################################################
'
# MEET / JIBRI SETUP
DOMAIN=$(ls /etc/prosody/conf.d/ | grep -v localhost | cut -d "." -f "1,2,3")
JB_AUTH_PASS_FILE=/var/JB_AUTH_PASS.txt
JB_REC_PASS_FILE=/var/JB_REC_PASS.txt
PROSODY_FILE=/etc/prosody/conf.d/$DOMAIN.cfg.lua
JICOFO_SIP=/etc/jitsi/jicofo/sip-communicator.properties
MEET_CONF=/etc/jitsi/meet/$DOMAIN-config.js
CONF_JSON=/etc/jitsi/jibri/config.json
DIR_RECORD=/tmp/recordings
REC_DIR=/home/jibri/finalize_recording.sh
JB_NAME="Jibri Sessions"
read -p "Jibri internal.auth.$DOMAIN password: "$'\n' -sr JB_AUTH_PASS
read -p "Jibri recorder.$DOMAIN password: "$'\n' -sr JB_REC_PASS
echo "$JB_AUTH_PASS" > $JB_AUTH_PASS_FILE
chmod 600 $JB_AUTH_PASS_FILE
echo "$JB_REC_PASS" > $JB_REC_PASS_FILE
chmod 600 $JB_REC_PASS_FILE
JibriBrewery=JibriBrewery
# Configure Jibri
## PROSODY
cat << MUC-JIBRI >> $PROSODY_FILE
-- internal muc component, meant to enable pools of jibri and jigasi clients
Component "conference.$DOMAIN" "muc"
modules_enabled = {
"ping";
}
storage = "null"
muc_room_cache_size = 1000
MUC-JIBRI
cat << REC-JIBRI >> $PROSODY_FILE
VirtualHost "recorder.$DOMAIN"
modules_enabled = {
"ping";
}
authentication = "internal_plain"
REC-JIBRI
### Prosody users
prosodyctl register jibri auth.$DOMAIN $JB_AUTH_PASS
prosodyctl register recorder recorder.$DOMAIN $JB_REC_PASS
## JICOFO
# /etc/jitsi/jicofo/sip-communicator.properties
cat << BREWERY >> $JICOFO_SIP
#org.jitsi.jicofo.auth.URL=XMPP:$DOMAIN
org.jitsi.jicofo.jibri.BREWERY=$JibriBrewery@internal.auth.$DOMAIN
org.jitsi.jicofo.jibri.PENDING_TIMEOUT=90
BREWERY
# /etc/jitsi/meet/$DOMAIN-config.js
sed -i "s|guest.example.com|guest.$DOMAIN|" $MEET_CONF
sed -i "s|// fileRecordingsEnabled: false,|fileRecordingsEnabled: true,| " $MEET_CONF
sed -i "s|// liveStreamingEnabled: false,|liveStreamingEnabled: true,\\
\ \ \ \ \hiddenDomain: \'recorder.$DOMAIN\',|" $MEET_CONF
# Recording directory
cat << REC_DIR > $REC_DIR
#!/bin/bash
RECORDINGS_DIR=$1
echo "This is a dummy finalize script" > /tmp/finalize.out
echo "The script was invoked with recordings directory $RECORDINGS_DIR." >> /tmp/finalize.out
echo "You should put any finalize logic (renaming, uploading to a service" >> /tmp/finalize.out
echo "or storage provider, etc.) in this script" >> /tmp/finalize.out
exit 0
REC_DIR
## JSON Config
cp $CONF_JSON CONF_JSON.orig
cat << CONF_JSON > $CONF_JSON
{
"recording_directory":"$DIR_RECORD",
"finalize_recording_script_path": "$REC_DIR",
"xmpp_environments": [
{
"name": "$JB_NAME",
"xmpp_server_hosts": [
"$DOMAIN"
],
"xmpp_domain": "$DOMAIN",
"control_login": {
"domain": "auth.$DOMAIN",
"username": "jibri",
"password": "$JB_AUTH_PASS"
},
"control_muc": {
"domain": "internal.auth.$DOMAIN",
"room_name": "$JibriBrewery",
"nickname": "Live"
},
"call_login": {
"domain": "recorder.$DOMAIN",
"username": "recorder",
"password": "$JB_REC_PASS"
},
"room_jid_domain_string_to_strip_from_start": "conference.",
"usage_timeout": "0"
}
]
}
CONF_JSON
#Enable jibri services
systemctl enable jibri
systemctl enable jibri-xorg
systemctl enable jibri-icewm
echo '
########################################################################
Starting LetsEncrypt configuration
########################################################################
'
bash /usr/share/jitsi-meet/scripts/install-letsencrypt-cert.sh
update_certbot
echo "Installation complete, we'll reboot and see.
Cross your fingers. :D"
#
apt -y autoremove
apt autoclean
echo "Rebooting in..."
secs=$((15))
while [ $secs -gt 0 ]; do
echo -ne "$secs\033[0K\r"
sleep 1
: $((secs--))
done
reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment