2020-09-28 16:39:15 +00:00
#!/bin/bash
# Simple Jibri Env tester
2023-11-08 06:34:51 +00:00
# SwITNet Ltd © - 2023, https://switnet.net/
2020-09-28 16:39:15 +00:00
# GNU GPLv3 or later.
while getopts m: option
do
case " ${ option } "
in
m) MODE = ${ OPTARG } ; ;
2022-05-21 01:07:02 +00:00
\? ) echo " Usage: sudo bash ./ $0 [-m debug] " && exit; ;
2020-09-28 16:39:15 +00:00
esac
done
#DEBUG
if [ " $MODE " = "debug" ] ; then
set -x
fi
echo -e '
########################################################################
Welcome to Jibri Environment Tester
########################################################################
by Software, IT & Networks Ltd
\n '
#Check if user is root
2022-05-21 01:07:02 +00:00
if ! [ " $( id -u) " = 0 ] ; then
2020-09-28 16:39:15 +00:00
echo "You need to be root or have sudo privileges!"
exit 0
fi
echo "Checking for updates...."
2020-10-11 01:43:13 +00:00
apt-get -q2 update
2021-02-18 01:03:39 +00:00
apt-get -yq2 install apt-show-versions \
curl
2020-09-30 02:42:19 +00:00
2020-10-10 11:30:19 +00:00
check_google_binaries( ) {
if [ -z " $2 " ] ; then
echo " Warning: No $1 doesn't seem installed "
else
2022-05-21 01:07:02 +00:00
echo " $2 "
2020-10-10 11:30:19 +00:00
fi
}
2021-02-18 07:15:52 +00:00
# True if $1 is greater than $2
version_gt( ) { test " $( printf '%s\n' " $@ " | sort -V | head -n 1) " != " $1 " ; }
2021-02-18 01:03:39 +00:00
2022-05-21 01:07:02 +00:00
JITSI_REPO = " $( apt-cache policy | grep http | grep jitsi | grep stable | awk '{print $3}' | head -n 1 | cut -d "/" -f1) "
2021-02-18 01:03:39 +00:00
SND_AL_MODULE = $( lsmod | awk '{print$1}' | grep snd_aloop)
2022-05-21 01:07:02 +00:00
HWE_VIR_MOD = " $( apt-cache madison linux-image-generic-hwe-" $( lsb_release -sr) " 2>/dev/null| head -n1| grep -c hwe-" $( lsb_release -sr) " ) "
2021-02-18 01:03:39 +00:00
CONF_JSON = "/etc/jitsi/jibri/config.json"
JIBRI_CONF = "/etc/jitsi/jibri/jibri.conf"
2022-05-21 01:07:02 +00:00
JMS_DOMAIN = " $( awk -F '"' '/xmpp-domain/{print$2}' " $JIBRI_CONF " ) "
2021-02-18 07:15:52 +00:00
CHDB = " $( whereis chromedriver | awk '{print$2}' ) "
CHD_VER_LOCAL = " $( $CHDB --version 2>/dev/null| awk '{print$1,$2}' ) "
2021-02-18 01:03:39 +00:00
GOOGL_VER_LOCAL = " $( /usr/bin/google-chrome --version 2>/dev/null) "
2022-05-21 01:07:02 +00:00
CHD_VER_2D = " $( echo " $CHD_VER_LOCAL " | awk '{print$2}' | cut -d "." -f 1,2) "
GOOGL_VER_2D = " $( echo " $GOOGL_VER_LOCAL " | awk '{print$3}' | cut -d "." -f 1,2) "
2021-02-18 08:00:36 +00:00
CHD_LTST = " $( curl -sL https://chromedriver.storage.googleapis.com/LATEST_RELEASE) "
2022-05-21 01:07:02 +00:00
CHD_LTST_2D = " $( echo " $CHD_LTST " | cut -d "." -f 1,2) "
2021-02-18 01:03:39 +00:00
2020-10-10 11:30:19 +00:00
#T1
echo -e "\n#1 -- Check repository --\n"
2022-05-21 01:07:02 +00:00
if [ -z " $JITSI_REPO " ] ; then
2020-09-28 16:39:15 +00:00
echo "No repository detected, wait whaaaat?..."
2020-10-10 11:30:19 +00:00
while [ [ " $CONT_TEST " != "yes" && " $CONT_TEST " != "no" ] ]
do
read -p "> Do you still want to continue the test?: (yes or no)" $'\n' -r CONT_TEST
if [ " $CONT_TEST " = "no" ] ; then
echo "Exiting..."
exit
elif [ " $CONT_TEST " = "yes" ] ; then
echo "Hmm, seems there won't be anything to test, continuing anyway..."
2021-02-18 01:03:39 +00:00
T1 = 0
2020-10-10 11:30:19 +00:00
fi
done
2020-09-28 16:39:15 +00:00
else
echo " This installation is using the \" $JITSI_REPO \" repository. "
2020-10-10 11:30:19 +00:00
T1 = 1
2020-09-28 16:39:15 +00:00
fi
2020-10-10 11:30:19 +00:00
#T2
echo -e "\n#2 -- Check latest updates for jibri --\n"
2020-09-28 16:39:15 +00:00
if [ " $( dpkg-query -W -f= '${Status}' jibri 2>/dev/null | grep -c "ok installed" ) " = = "1" ] ; then
echo "Jibri is installed, checking version:"
apt-show-versions jibri
else
echo "Wait!, jibri is not installed on this system using apt, exiting..."
exit
fi
2020-10-07 21:58:51 +00:00
if [ " $( apt-show-versions jibri | grep -c "uptodate" ) " = "1" ] ; then
2021-02-18 07:15:52 +00:00
echo -e "Jibri is already up to date: \xE2\x9C\x94"
2020-10-07 21:58:51 +00:00
else
2021-02-18 07:15:52 +00:00
echo -e "\nAttempting jibri upgrade!"
apt-get -y install --only-upgrade jibri
2020-10-07 21:58:51 +00:00
fi
2020-10-10 11:30:19 +00:00
T2 = 1
2020-09-28 16:39:15 +00:00
2020-10-10 11:30:19 +00:00
#T3
echo -e "\n#3 -- Check Google Chrome/driver software. --\n"
2021-02-18 01:03:39 +00:00
check_google_binaries "Google Chrome" " $GOOGL_VER_LOCAL "
check_google_binaries "Chromedriver" " $CHD_VER_LOCAL "
2022-05-21 01:07:02 +00:00
if [ -n " $CHD_VER_LOCAL " ] && [ -n " $GOOGL_VER_LOCAL " ] ; then
2021-02-18 01:03:39 +00:00
# Chrome upgrade process
if [ " $( apt-show-versions google-chrome-stable | grep -c "uptodate" ) " = "1" ] ; then
echo -e "Google Chrome is already up to date: \xE2\x9C\x94"
else
echo -e "\nAttempting Google Chrome upgrade!"
2021-02-18 07:15:52 +00:00
apt-get -yq install --only-upgrade google-chrome-stable
2021-02-18 01:03:39 +00:00
fi
# Only upgrade chromedriver if it's on a lower version, not just a different one.
2022-05-21 01:07:02 +00:00
if [ " $CHD_VER_2D " = " $GOOGL_VER_2D " ] ; then
2021-02-18 04:18:10 +00:00
echo -e "\nChromedriver version seems according to Google Chrome: \xE2\x9C\x94"
2021-02-18 01:03:39 +00:00
T3 = 1
2021-02-18 08:00:36 +00:00
elif version_gt " $GOOGL_VER_2D " " $CHD_VER_2D " && \
[ " $GOOGL_VER_2D " = " $CHD_LTST_2D " ] ; then
2021-02-18 04:18:10 +00:00
echo -e "\nAttempting Chromedriver update!"
2022-05-21 01:07:02 +00:00
wget -q https://chromedriver.storage.googleapis.com/" $CHD_LTST " /chromedriver_linux64.zip \
2021-02-18 08:21:59 +00:00
-O /tmp/chromedriver_linux64.zip
2021-02-18 08:32:17 +00:00
unzip -o /tmp/chromedriver_linux64.zip -d /usr/local/bin/
2022-05-21 01:07:02 +00:00
chown root:root " $CHDB "
chmod 0755 " $CHDB "
2021-02-18 01:03:39 +00:00
rm -rf /tpm/chromedriver_linux64.zip
2021-02-18 08:46:26 +00:00
if [ " $( $CHDB -v | awk '{print $2}' | cut -d "." -f 1,2) " = " $GOOGL_VER_2D " ] ; then
2021-05-22 20:50:42 +00:00
echo "Successful update"
2021-02-18 01:03:39 +00:00
T3 = 1
else
echo "Something might gone wrong on the update process, please report."
T3 = 0
fi
else
T3 = 0
fi
else
T3 = 0
2020-10-10 11:30:19 +00:00
fi
#T4
echo -e "\n#4 -- Test kernel modules --\n"
2022-05-21 01:07:02 +00:00
if [ -z " $SND_AL_MODULE " ] ; then
2020-10-07 21:58:51 +00:00
#First make sure the recommended kernel is installed.
2021-01-26 22:11:14 +00:00
if [ " $HWE_VIR_MOD " = "1" ] ; then
2020-10-07 21:58:51 +00:00
apt-get -y install \
2022-05-21 01:07:02 +00:00
linux-image-generic-hwe-" $( lsb_release -sr) "
2021-01-26 22:11:14 +00:00
else
2020-10-07 21:58:51 +00:00
apt-get -y install \
2021-01-26 22:11:14 +00:00
linux-image-generic \
2022-05-21 01:07:02 +00:00
linux-modules-extra-" $( uname -r) "
2020-10-07 21:58:51 +00:00
fi
2020-10-10 11:30:19 +00:00
echo -e " \nNo module snd_aloop detected. \xE2\x9C\x96 <== IMPORTANT! \nCurrent kernel: $( uname -r) \n "
2020-10-05 11:24:12 +00:00
echo -e " \nIf you just installed a new kernel, \
2020-09-28 16:39:15 +00:00
please try rebooting.\n For now wait ' til the end of the recommended kernel installation."
echo "# Check and Install HWE kernel if possible..."
2020-10-05 23:40:56 +00:00
if uname -r | grep -q aws; then
2022-05-21 01:07:02 +00:00
KNL_HWE = " $( apt-cache madison linux-image-generic-hwe-" $( lsb_release -sr) " | awk 'NR==1{print$3}' | cut -d "." -f1-4) "
KNL_MENU = " $( awk -F\' '/menuentry / {print $2}' /boot/grub/grub.cfg| awk '!/recovery/&&/generic/{print$3,$4}' | grep " $KNL_HWE " ) "
if [ -n " $KNL_MENU " ] ; then
2020-10-07 21:58:51 +00:00
echo -e "\nSeems you are using an AWS kernel \xE2\x9C\x96 <== IMPORTANT! \nYou might consider modify your grub (/etc/default/grub) to use the following:" && \
echo -e " \n > $KNL_MENU "
2020-10-05 12:26:10 +00:00
fi
fi
2020-10-10 11:30:19 +00:00
T4 = 0
2020-09-28 16:39:15 +00:00
else
2021-06-12 20:55:56 +00:00
echo -e "Great!, module snd-aloop found. \xE2\x9C\x94"
2020-10-10 11:30:19 +00:00
T4 = 1
2020-09-28 16:39:15 +00:00
fi
2020-10-10 11:30:19 +00:00
#T5
echo -e "\n#5 -- Test .asoundrc file --\n"
2020-09-28 16:39:15 +00:00
ASRC_MASTER = "https://raw.githubusercontent.com/jitsi/jibri/master/resources/debian-package/etc/jitsi/jibri/asoundrc"
ASRC_INSTALLED = "/home/jibri/.asoundrc"
2022-05-21 01:07:02 +00:00
ASRC_MASTER_MD5SUM = " $( curl -sL " $ASRC_MASTER " | md5sum | cut -d ' ' -f 1) "
ASRC_INSTALLED_MD5SUM = " $( md5sum " $ASRC_INSTALLED " | cut -d ' ' -f 1) "
2020-09-28 16:39:15 +00:00
if [ " $ASRC_MASTER_MD5SUM " = = " $ASRC_INSTALLED_MD5SUM " ] ; then
2021-06-12 20:55:56 +00:00
echo -e "Seems to be using the latest asoundrc file available. \xE2\x9C\x94"
2020-10-10 11:30:19 +00:00
T5 = 1
2020-09-28 16:39:15 +00:00
else
2021-06-12 20:55:56 +00:00
echo -e "asoundrc files differ, if you have errors, you might wanna check this file \xE2\x9C\x96"
2020-10-10 11:30:19 +00:00
T5 = 0
2020-09-28 16:39:15 +00:00
fi
2020-10-10 11:30:19 +00:00
#T6
echo -e "\n#6 -- Old or new config --\n"
2020-09-28 16:39:15 +00:00
echo -e "What config version is this using?"
2022-05-21 01:07:02 +00:00
if [ -f " ${ CONF_JSON } " _disabled ] && \
[ -f " $JIBRI_CONF " ] && \
[ -f " $JIBRI_CONF " -dpkg-file ] ; then
2021-02-19 21:24:27 +00:00
echo -e " \n> This jibri config has been upgraded already. \xE2\x9C\x94 \n\nIf you think there maybe an error on checking you current jibri configuration.\nPlease report this to \
2023-11-07 20:42:50 +00:00
https://forge.switnet.net/switnet/quick-jibri-installer/issues\n "
2020-10-10 11:30:19 +00:00
T6 = 1
2022-05-21 01:07:02 +00:00
elif [ ! -f " $CONF_JSON " ] && \
[ -f " $JIBRI_CONF " ] && \
[ -f " ${ JIBRI_CONF } " -dpkg-file ] ; then
2021-05-22 20:50:42 +00:00
echo -e " \n> This jibri seems to be running the latest configuration already. \xE2\x9C\x94 \n\nIf you think there maybe an error on checking you current jibri configuration.\nPlease report this to \
2023-11-07 20:42:50 +00:00
https://forge.switnet.net/switnet/quick-jibri-installer/issues\n "
2020-10-10 11:30:19 +00:00
T6 = 1
2022-05-21 01:07:02 +00:00
elif [ -f " ${ CONF_JSON } " ] && \
[ -f " $JIBRI_CONF " ] ; then
2021-02-19 21:24:27 +00:00
echo -e " \n> This jibri config seems to be candidate for upgrading. \xE2\x9C\x96 \nIf you think there maybe an error on checking you current jibri configuration.\nPlease report this to \
2023-11-07 20:42:50 +00:00
https://forge.switnet.net/switnet/quick-jibri-installer/issues\n "
2020-10-10 11:30:19 +00:00
T6 = 0
2020-10-01 07:12:09 +00:00
fi
2020-09-28 16:39:15 +00:00
2021-02-19 21:24:27 +00:00
#T6.1
echo -e "\n#6.1 -- Check for specific Chrome flag --\n"
if [ " $( grep -c "ignore-certificate-errors" $JIBRI_CONF ) " != 0 ] ; then
echo -e " \n> Seems you have the \"--ignore-certificate-errors\" flag required for Chrome v88 and later. \xE2\x9C\x94 \n\nIf you think there maybe an error on checking you current jibri configuration.\nPlease report this to \
2023-11-07 20:42:50 +00:00
https://forge.switnet.net/switnet/quick-jibri-installer/issues\n "
2021-02-19 21:24:27 +00:00
T6_1 = "0.1"
else
2023-11-07 20:42:50 +00:00
echo -e " \n> The jibri config may be missing the required chrome flags. \xE2\x9C\x96 \nPlease check:\n https://forge.switnet.net/switnet/quick-jibri-installer/src/branch/master/quick_jibri_installer.sh#L870 \n\nIf you think there maybe an error on checking you current jibri configuration.\nPlease report this to \
https://forge.switnet.net/switnet/quick-jibri-installer/issues\n "
2021-02-19 21:24:27 +00:00
T6_1 = 0
fi
2021-06-12 20:55:56 +00:00
#T7
2021-06-17 06:27:51 +00:00
echo -e "\n#7 -- Check for open communication port among Jibri and JMS --\n"
2022-05-21 01:07:02 +00:00
if ! nc -z -v -w5 " $JMS_DOMAIN " 5222 ; then
2021-06-12 20:55:56 +00:00
echo -e "Connection failed! \xE2\x9C\x96\n > You might want to check both Jibri & JMS firewall rules (TCP 5222)."
T7 = 0
else
echo -e "Connection succeeded! \xE2\x9C\x94\n"
T7 = 1
fi
TEST_TOTAL = $( awk " BEGIN{ print $T1 + $T2 + $T3 + $T4 + $T5 + $T6 + $T6_1 + $T7 } " )
2020-10-10 11:30:19 +00:00
echo "
2021-02-19 21:36:50 +00:00
##############################
2020-10-10 11:30:19 +00:00
\
2021-06-12 20:55:56 +00:00
Score: $TEST_TOTAL out of 7.1
2021-02-19 21:36:50 +00:00
##############################
2020-10-10 11:30:19 +00:00
"
2020-09-28 16:39:15 +00:00
echo -e "\nJibri Test complete, thanks for testing.\n"