Comply tools section with shellcheck recommendations.

This commit is contained in:
Luis Guzmán 2022-05-11 23:52:44 -05:00
parent ced6574cfa
commit 1875cf5db5
6 changed files with 105 additions and 106 deletions

View File

@ -19,7 +19,7 @@ done
} }
# Check if user is root # Check if user is root
if [ $UID != 0 ]; then if [ "$UID" != 0 ]; then
echo You need to run this script as root or sudo rights! echo You need to run this script as root or sudo rights!
exit 1 exit 1
fi fi
@ -30,36 +30,36 @@ GRUB_FILE="/etc/default/grub"
echo -e "# Check and update HWE kernel if possible...\n" echo -e "# Check and update HWE kernel if possible...\n"
apt-get -q2 update apt-get -q2 update
HWE_VIR_MOD=$(apt-cache madison linux-image-generic-hwe-$(lsb_release -sr) 2>/dev/null|head -n1|grep -c "hwe-$(lsb_release -sr)") HWE_VIR_MOD="$(apt-cache madison linux-image-generic-hwe-"$(lsb_release -sr)" 2>/dev/null|head -n1|grep -c hwe-"$(lsb_release -sr)")"
if [ "$HWE_VIR_MOD" = "1" ]; then if [ "$HWE_VIR_MOD" = "1" ]; then
apt-get -y install \ apt-get -y install \
linux-image-generic-hwe-$(lsb_release -sr) \ linux-image-generic-hwe-"$(lsb_release -sr)" \
linux-tools-generic-hwe-$(lsb_release -sr) linux-tools-generic-hwe-"$(lsb_release -sr)"
else else
apt-get -y install \ apt-get -y install \
linux-image-generic \ linux-image-generic \
linux-modules-extra-$(uname -r) linux-modules-extra-"$(uname -r)"
fi fi
apt-get -y autoremove apt-get -y autoremove
apt-get autoclean apt-get autoclean
#Write update-grub output #Write update-grub output
update-grub > $KERNEL_LOG 2>&1 update-grub > "$KERNEL_LOG" 2>&1
#Get clean output #Get clean output
cat $KERNEL_LOG | awk -F'boot/' '{print$2}'|sed '/^[[:space:]]*$/d' | \ awk -F'boot/' '{print$2}' < "$KERNEL_LOG"|sed '/^[[:space:]]*$/d' | \
tee ${KERNEL_LOG}.tmp tee "$KERNEL_LOG".tmp
mv ${KERNEL_LOG}.tmp $KERNEL_LOG mv "$KERNEL_LOG".tmp "$KERNEL_LOG"
echo -e "Check if AWS kernel is installed.\n" echo -e "Check if AWS kernel is installed.\n"
[ $(grep -wc aws $KERNEL_LOG) = 0 ] && echo "No AWS kernel found, exiting..." && exit [ "$(grep -wc aws "$KERNEL_LOG")" = 0 ] && echo "No AWS kernel found, exiting..." && exit
#Get kernel number #Get kernel number
RAW_KERNEL_NUM="$(grep -Fn generic $KERNEL_LOG|head -n1|cut -d ':' -f1)" RAW_KERNEL_NUM="$(grep -Fn generic "$KERNEL_LOG"|head -n1|cut -d ':' -f1)"
FIXED_KERNEL_NUM="$(awk "BEGIN{ print $RAW_KERNEL_NUM - 1 }")" FIXED_KERNEL_NUM="$(awk "BEGIN{ print $RAW_KERNEL_NUM - 1 }")"
echo -e "Set up GRUB for custom kernel.\n" echo -e "Set up GRUB for custom kernel.\n"
sed -i "s|GRUB_DEFAULT=.*|GRUB_DEFAULT=\"1\>$FIXED_KERNEL_NUM\"|" $GRUB_FILE sed -i "s|GRUB_DEFAULT=.*|GRUB_DEFAULT=\"1\>$FIXED_KERNEL_NUM\"|" "$GRUB_FILE"
echo -e "Saving changes...\n" echo -e "Saving changes...\n"
update-grub update-grub

View File

@ -18,7 +18,7 @@ set -x
fi fi
#Check if user is root #Check if user is root
if ! [ $(id -u) = 0 ]; then if ! [ "$(id -u)" = 0 ]; then
echo "You need to be root or have sudo privileges!" echo "You need to be root or have sudo privileges!"
exit 0 exit 0
fi fi
@ -27,8 +27,8 @@ apt-get -y install fail2ban
if \ if \
[ -f /var/log/ssh_f2b.log ] && \ [ -f /var/log/ssh_f2b.log ] && \
[ $(grep -c 604800 /etc/fail2ban/jail.local) = "1" ] && \ [ "$(grep -c 604800 /etc/fail2ban/jail.local)" = "1" ] && \
[ $(grep -c ssh_f2b.log /etc/fail2ban/jail.local) = "1"]; then [ "$(grep -c ssh_f2b.log /etc/fail2ban/jail.local)" = "1" ]; then
echo -e "\nFail2ban seems to be already configured.\n" echo -e "\nFail2ban seems to be already configured.\n"
else else
echo -e "\nConfiguring Fail2ban...\n" echo -e "\nConfiguring Fail2ban...\n"

View File

@ -25,7 +25,7 @@ echo -e '
\n' \n'
#Check if user is root #Check if user is root
if ! [ $(id -u) = 0 ]; then if ! [ "$(id -u)" = 0 ]; then
echo "You need to be root or have sudo privileges!" echo "You need to be root or have sudo privileges!"
exit 0 exit 0
fi fi
@ -46,13 +46,13 @@ else
fi fi
if [ -d /etc/prosody/ ];then if [ -d /etc/prosody/ ];then
DOMAIN=$(ls /etc/prosody/conf.d/ | grep -v localhost | awk -F'.cfg' '{print $1}' | awk '!NF || !seen[$0]++') DOMAIN="$(find /etc/prosody/conf.d/ -name \*.lua|awk -F'.cfg' '!/localhost/{print $1}'|xargs basename)"
fi fi
CONF_JSON="/etc/jitsi/jibri/config.json" CONF_JSON="/etc/jitsi/jibri/config.json"
JIBRI_CONF="/etc/jitsi/jibri/jibri.conf" JIBRI_CONF="/etc/jitsi/jibri/jibri.conf"
DIR_RECORD=/var/jbrecord DIR_RECORD="/var/jbrecord"
REC_DIR=/home/jibri/finalize_recording.sh REC_DIR="/home/jibri/finalize_recording.sh"
JibriBrewery=JibriBrewery JibriBrewery="JibriBrewery"
check_read_vars() { check_read_vars() {
echo "Checking $1" echo "Checking $1"
@ -73,44 +73,44 @@ fi
} }
#Prevent re-run on completed jibri upgraded instance #Prevent re-run on completed jibri upgraded instance
if [ -f $CONF_JSON_disabled ] && \ if [ -f "$CONF_JSON"_disabled ] && \
[ -f $JIBRI_CONF ] && \ [ -f "$JIBRI_CONF" ] && \
[ -f $JIBRI_CONF-dpkg-file ]; then [ -f "$JIBRI_CONF"-dpkg-file ]; then
echo -e "\n> This jibri config has been upgraded already, we'll exit...\n\nIf you think there maybe an error on checking you current jibri configuration.\nPlease report this to \ echo -e "\n> This jibri config has been upgraded already, we'll exit...\n\nIf you think there maybe an error on checking you current jibri configuration.\nPlease report this to \
https://github.com/switnet-ltd/quick-jibri-installer/issues\n" https://github.com/switnet-ltd/quick-jibri-installer/issues\n"
exit exit
elif [ ! -f $CONF_JSON ] && \ elif [ ! -f "$CONF_JSON" ] && \
[ -f $JIBRI_CONF ] && \ [ -f "$JIBRI_CONF" ] && \
[ -f $JIBRI_CONF-dpkg-file ]; then [ -f "$JIBRI_CONF"-dpkg-file ]; then
echo -e "\n> This jibri seems to be running the latest configuration already, we'll exit...\n\nIf you think there maybe an error on checking you current jibri configuration.\nPlease report this to \ echo -e "\n> This jibri seems to be running the latest configuration already, we'll exit...\n\nIf you think there maybe an error on checking you current jibri configuration.\nPlease report this to \
https://github.com/switnet-ltd/quick-jibri-installer/issues\n" https://github.com/switnet-ltd/quick-jibri-installer/issues\n"
exit exit
elif [ -f $CONF_JSON ] && \ elif [ -f "$CONF_JSON" ] && \
[ -f $JIBRI_CONF ]; then [ -f "$JIBRI_CONF" ]; then
echo -e "\n> This jibri config seems to be candidate for upgrading, we'll continue...\nIf you think there maybe an error on checking you current jibri configuration.\nPlease report this to \ echo -e "\n> This jibri config seems to be candidate for upgrading, we'll continue...\nIf you think there maybe an error on checking you current jibri configuration.\nPlease report this to \
https://github.com/switnet-ltd/quick-jibri-installer/issues\n" https://github.com/switnet-ltd/quick-jibri-installer/issues\n"
fi fi
#Read missing variables #Read missing variables
if [ -f $CONF_JSON ]; then if [ -f "$CONF_JSON" ]; then
echo "Reading current config.json file..." echo "Reading current config.json file..."
if [ -z $DOMAIN ]; then if [ -z "$DOMAIN" ]; then
DOMAIN=$(jq .xmpp_environments[0].xmpp_domain $CONF_JSON|cut -d '"' -f2) DOMAIN="$(jq .xmpp_environments[0].xmpp_domain $CONF_JSON|cut -d '"' -f2)"
fi fi
JB_NAME=$(jq .xmpp_environments[0].name $CONF_JSON|cut -d '"' -f2) JB_NAME="$(jq .xmpp_environments[0].name $CONF_JSON|cut -d '"' -f2)"
JB_AUTH_PASS=$(jq .xmpp_environments[0].control_login.password $CONF_JSON|cut -d '"' -f2) JB_AUTH_PASS="$(jq .xmpp_environments[0].control_login.password $CONF_JSON|cut -d '"' -f2)"
JB_REC_PASS=$(jq .xmpp_environments[0].call_login.password $CONF_JSON|cut -d '"' -f2) JB_REC_PASS="$(jq .xmpp_environments[0].call_login.password $CONF_JSON|cut -d '"' -f2)"
JB_NICKN=$(jq .xmpp_environments[0].control_muc.nickname $CONF_JSON|cut -d '"' -f2) JB_NICKN="$(jq .xmpp_environments[0].control_muc.nickname $CONF_JSON|cut -d '"' -f2)"
else else
echo "Can't find the instance config.json file, exiting..." echo "Can't find the instance config.json file, exiting..."
exit exit
fi fi
check_read_vars "Jibri Name" $JB_NAME check_read_vars "Jibri Name" "$JB_NAME"
check_read_vars "(Main server) Domain" $DOMAIN check_read_vars "(Main server) Domain" "$DOMAIN"
check_read_vars "Control login passwd" $JB_AUTH_PASS check_read_vars "Control login passwd" "$JB_AUTH_PASS"
check_read_vars "Call login passwd" $JB_REC_PASS check_read_vars "Call login passwd" "$JB_REC_PASS"
check_read_vars "Jibri Node nickname" $JB_NICKN check_read_vars "Jibri Node nickname" "$JB_NICKN"
if [ "$MODE" = "debug" ]; then if [ "$MODE" = "debug" ]; then
echo "$JB_NAME" echo "$JB_NAME"
@ -122,10 +122,10 @@ fi
#Backup and setup new conf file #Backup and setup new conf file
echo -e "Backing up config.json for historical purposes at:\n ${CONF_JSON}_disabled" echo -e "Backing up config.json for historical purposes at:\n ${CONF_JSON}_disabled"
mv $CONF_JSON ${CONF_JSON}_disabled mv "$CONF_JSON" "${CONF_JSON}"_disabled
mv $JIBRI_CONF ${JIBRI_CONF}-dpkg-file mv "$JIBRI_CONF" "${JIBRI_CONF}"-dpkg-file
cat << NEW_CONF > $JIBRI_CONF cat << NEW_CONF > "$JIBRI_CONF"
// New XMPP environment config. // New XMPP environment config.
jibri { jibri {
recording { recording {
@ -195,8 +195,8 @@ jibri {
NEW_CONF NEW_CONF
echo "Check final jibri.conf file:" echo "Check final jibri.conf file:"
cat $JIBRI_CONF cat "$JIBRI_CONF"
read -n 1 -s -r -p "Press any key to continue..."$'\n' read -n 1 -s -r -p "Press any key to continue..."
restart_services_jibri restart_services_jibri
systemctl status jibri systemctl status jibri

View File

@ -18,7 +18,7 @@ if [ "$MODE" = "debug" ]; then
fi fi
#Check if user is root #Check if user is root
if ! [ $(id -u) = 0 ]; then if ! [ "$(id -u)" = 0 ]; then
echo "You need to be root or have sudo privileges!" echo "You need to be root or have sudo privileges!"
exit 0 exit 0
fi fi
@ -46,15 +46,15 @@ if [ -f "$JIBRI_OPT/jibri-res_enh.jar" ] && \
fi fi
mkdir /tmp/jibri mkdir /tmp/jibri
cd /tmp/jibri cd /tmp/jibri || exit
#Get md5sum for current jibri installed. #Get md5sum for current jibri installed.
apt-get download jibri=$INSTALLED_JIBRI_VERSION apt-get download jibri="$INSTALLED_JIBRI_VERSION"
ar x jibri_*.deb ar x jibri_*.deb
tar xvf data.tar.xz tar xvf data.tar.xz
UPSTREAM_DEB_JAR_SUM="$(md5sum 2>/dev/null /tmp/jibri/opt/jitsi/jibri/jibri.jar |awk '{print$1}')" UPSTREAM_DEB_JAR_SUM="$(md5sum 2>/dev/null /tmp/jibri/opt/jitsi/jibri/jibri.jar |awk '{print$1}')"
if [ -z $UPSTREAM_DEB_JAR_SUM ]; then if [ -z "$UPSTREAM_DEB_JAR_SUM" ]; then
echo "Not possible to continue, exiting..." echo "Not possible to continue, exiting..."
exit exit
fi fi
@ -66,8 +66,8 @@ apt-get -y install devscripts \
openjdk-8-jdk openjdk-8-jdk
#Build repository #Build repository
git clone https://github.com/jitsi/jibri $JIBRI_ENH_PATH git clone https://github.com/jitsi/jibri "$JIBRI_ENH_PATH"
cd $JIBRI_ENH_PATH cd "$JIBRI_ENH_PATH" || exit
# Default values # Default values
## videoEncodePreset - "veryfast" || h264ConstantRateFactor - 25 ## videoEncodePreset - "veryfast" || h264ConstantRateFactor - 25
@ -77,18 +77,18 @@ sed -i "/videoEncodePreset/s|String =.*|String = \"medium\",|" src/main/kotlin/
sed -i "/h264ConstantRateFactor/s|Int =.*|Int = 17,|" src/main/kotlin/org/jitsi/jibri/capture/ffmpeg/FfmpegCapturer.kt sed -i "/h264ConstantRateFactor/s|Int =.*|Int = 17,|" src/main/kotlin/org/jitsi/jibri/capture/ffmpeg/FfmpegCapturer.kt
mvn package mvn package
JIBRI_JAR="$(ls -Sh $JIBRI_ENH_PATH/target|awk '/dependencies/&&/.jar/{print}'|awk 'NR==1{print}')" JIBRI_JAR="$(find "$JIBRI_ENH_PATH" -name \*.jar|awk '/dependencies/{print}'|awk 'NR==1{print}')"
cp $JIBRI_ENH_PATH/target/$JIBRI_JAR $JIBRI_ENH_PATH/target/jibri.jar cp "$JIBRI_ENH_PATH"/target/"$JIBRI_JAR" "$JIBRI_ENH_PATH"/target/jibri.jar
# Backing up default binaries # Backing up default binaries
if [ "$UPSTREAM_DEB_JAR_SUM" = "$(md5sum 2>/dev/null $JIBRI_OPT/jibri.jar|awk '{print$1}')" ]; then if [ "$UPSTREAM_DEB_JAR_SUM" = "$(md5sum 2>/dev/null $JIBRI_OPT/jibri.jar|awk '{print$1}')" ]; then
cp $JIBRI_OPT/jibri.jar $JIBRI_OPT/jibri-dpkg-package.jar cp "$JIBRI_OPT"/jibri.jar "$JIBRI_OPT"/jibri-dpkg-package.jar
fi fi
# Migrate original to enhanced jibri # Migrate original to enhanced jibri
cp $JIBRI_ENH_PATH/target/jibri.jar $JIBRI_OPT/jibri-res_enh.jar cp "$JIBRI_ENH_PATH"/target/jibri.jar "$JIBRI_OPT"/jibri-res_enh.jar
if [ -f $JIBRI_OPT/jibri-dpkg-package.jar ];then if [ -f "$JIBRI_OPT"/jibri-dpkg-package.jar ];then
cp $JIBRI_OPT/jibri-res_enh.jar $JIBRI_OPT/jibri.jar cp "$JIBRI_OPT"/jibri-res_enh.jar "$JIBRI_OPT"/jibri.jar
fi fi
JIBRI_RES_ENH_HASH="$(md5sum 2>/dev/null $JIBRI_OPT/jibri-res_enh.jar|awk '{print$1}')" JIBRI_RES_ENH_HASH="$(md5sum 2>/dev/null $JIBRI_OPT/jibri-res_enh.jar|awk '{print$1}')"
@ -99,12 +99,12 @@ if [ "$JIBRI_RES_ENH_HASH" = "$USED_JIBRI_HASH" ]; then
else else
echo "Something went wrong, restoring default package..." echo "Something went wrong, restoring default package..."
if [ "$(md5sum 2>/dev/null $JIBRI_OPT/jibri-dpkg-package.jar|awk '{print$1}')" = "$UPSTREAM_DEB_JAR_SUM" ]; then if [ "$(md5sum 2>/dev/null $JIBRI_OPT/jibri-dpkg-package.jar|awk '{print$1}')" = "$UPSTREAM_DEB_JAR_SUM" ]; then
cp $JIBRI_OPT/jibri-dpkg-package.jar $JIBRI_OPT/jibri.jar cp "$JIBRI_OPT"/jibri-dpkg-package.jar "$JIBRI_OPT"/jibri.jar
CLEAN="true" CLEAN="true"
else else
if [ -f /tmp/jibri/opt/jitsi/jibri/jibri.jar ]; then if [ -f /tmp/jibri/opt/jitsi/jibri/jibri.jar ]; then
echo "Restoring from upstream package..." echo "Restoring from upstream package..."
cp /tmp/jibri/opt/jitsi/jibri/jibri.jar $JIBRI_OPT/jibri.jar cp /tmp/jibri/opt/jitsi/jibri/jibri.jar "$JIBRI_OPT"/jibri.jar
CLEAN="true" CLEAN="true"
else else
echo "Wow, someone took the time to avoid restoration, please manually review your changes." echo "Wow, someone took the time to avoid restoration, please manually review your changes."
@ -115,7 +115,7 @@ else
fi fi
if [ "$CLEAN" = "true" ]; then if [ "$CLEAN" = "true" ]; then
rm -r /tmp/jibri rm -r /tmp/jibri
rm -r $JIBRI_ENH_PATH rm -r "$JIBRI_ENH_PATH"
rm /opt/jitsi/jibri/jibri-res_enh.jar rm /opt/jitsi/jibri/jibri-res_enh.jar
fi fi

View File

@ -18,7 +18,7 @@ if [ "$MODE" = "debug" ]; then
fi fi
#Check if user is root #Check if user is root
if ! [ $(id -u) = 0 ]; then if ! [ "$(id -u)" = 0 ]; then
echo "You need to be root or have sudo privileges!" echo "You need to be root or have sudo privileges!"
exit 0 exit 0
fi fi
@ -32,16 +32,16 @@ while [ $secs -gt 0 ]; do
done done
} }
remove_residuals() { remove_residuals() {
if [ -d $1 ]; then if [ -d "$1" ]; then
rm -r $1 rm -r "$1"
fi fi
} }
purge_debconf() { purge_debconf() {
echo PURGE | debconf-communicate $1 echo PURGE | debconf-communicate "$1"
} }
remove_services() { remove_services() {
systemctl disable $1 systemctl disable "$1"
systemctl stop $1 systemctl stop "$1"
} }
echo -e ' echo -e '
######################################################################## ########################################################################
@ -50,8 +50,8 @@ echo -e '
by Software, IT & Networks Ltd by Software, IT & Networks Ltd
\n' \n'
SYNC_USER="$(ls /home|awk '/jbsync/{print}')" SYNC_USER="$(find /home -maxdepth 1 -type d |awk '/jbsync/{print}')"
DOMAIN="$(ls /etc/prosody/conf.d/ | awk -F'.cfg' '!/localhost/{print $1}' | awk '!NF || !seen[$0]++')" DOMAIN="$(find /etc/prosody/conf.d/ -name \*.lua|awk -F'.cfg' '!/localhost/{print $1}'|xargs basename)"
echo "We are about to remove and clean all the jitsi-meet platform bits and pieces... echo "We are about to remove and clean all the jitsi-meet platform bits and pieces...
Please make sure you have backed up anything you don't want to loose." Please make sure you have backed up anything you don't want to loose."
@ -128,8 +128,8 @@ purge_debconf jitsi-meet-web-config
purge_debconf jitsi-videobridge2 purge_debconf jitsi-videobridge2
#Remove unused users & groups #Remove unused users & groups
if [ ! -z $SYNC_USER ]; then if [ -n "$SYNC_USER" ]; then
deluser --remove-home $SYNC_USER deluser --remove-home "$SYNC_USER"
fi fi
if [ -d /home/jibri ]; then if [ -d /home/jibri ]; then
deluser --remove-home jibri deluser --remove-home jibri

View File

@ -25,7 +25,7 @@ echo -e '
\n' \n'
#Check if user is root #Check if user is root
if ! [ $(id -u) = 0 ]; then if ! [ "$(id -u)" = 0 ]; then
echo "You need to be root or have sudo privileges!" echo "You need to be root or have sudo privileges!"
exit 0 exit 0
fi fi
@ -39,30 +39,30 @@ check_google_binaries() {
if [ -z "$2" ]; then if [ -z "$2" ]; then
echo "Warning: No $1 doesn't seem installed" echo "Warning: No $1 doesn't seem installed"
else else
echo $2 echo "$2"
fi fi
} }
# True if $1 is greater than $2 # True if $1 is greater than $2
version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; } version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; }
JITSI_REPO=$(apt-cache policy | grep http | grep jitsi | grep stable | awk '{print $3}' | head -n 1 | cut -d "/" -f1) JITSI_REPO="$(apt-cache policy | grep http | grep jitsi | grep stable | awk '{print $3}' | head -n 1 | cut -d "/" -f1)"
SND_AL_MODULE=$(lsmod | awk '{print$1}'| grep snd_aloop) SND_AL_MODULE=$(lsmod | awk '{print$1}'| grep snd_aloop)
HWE_VIR_MOD=$(apt-cache madison linux-image-generic-hwe-$(lsb_release -sr) 2>/dev/null|head -n1|grep -c "hwe-$(lsb_release -sr)") HWE_VIR_MOD="$(apt-cache madison linux-image-generic-hwe-"$(lsb_release -sr)" 2>/dev/null|head -n1|grep -c hwe-"$(lsb_release -sr)")"
CONF_JSON="/etc/jitsi/jibri/config.json" CONF_JSON="/etc/jitsi/jibri/config.json"
JIBRI_CONF="/etc/jitsi/jibri/jibri.conf" JIBRI_CONF="/etc/jitsi/jibri/jibri.conf"
JMS_DOMAIN="$(awk -F '"' '/xmpp-domain/{print$2}' $JIBRI_CONF)" JMS_DOMAIN="$(awk -F '"' '/xmpp-domain/{print$2}' "$JIBRI_CONF")"
CHDB="$(whereis chromedriver | awk '{print$2}')" CHDB="$(whereis chromedriver | awk '{print$2}')"
CHD_VER_LOCAL="$($CHDB --version 2>/dev/null| awk '{print$1,$2}')" CHD_VER_LOCAL="$($CHDB --version 2>/dev/null| awk '{print$1,$2}')"
GOOGL_VER_LOCAL="$(/usr/bin/google-chrome --version 2>/dev/null)" GOOGL_VER_LOCAL="$(/usr/bin/google-chrome --version 2>/dev/null)"
CHD_VER_2D="$(echo $CHD_VER_LOCAL|awk '{print$2}'|cut -d "." -f 1,2)" 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)" GOOGL_VER_2D="$(echo "$GOOGL_VER_LOCAL"|awk '{print$3}'|cut -d "." -f 1,2)"
CHD_LTST="$(curl -sL https://chromedriver.storage.googleapis.com/LATEST_RELEASE)" CHD_LTST="$(curl -sL https://chromedriver.storage.googleapis.com/LATEST_RELEASE)"
CHD_LTST_2D="$(echo $CHD_LTST|cut -d "." -f 1,2)" CHD_LTST_2D="$(echo "$CHD_LTST"|cut -d "." -f 1,2)"
#T1 #T1
echo -e "\n#1 -- Check repository --\n" echo -e "\n#1 -- Check repository --\n"
if [ -z $JITSI_REPO ]; then if [ -z "$JITSI_REPO" ]; then
echo "No repository detected, wait whaaaat?..." echo "No repository detected, wait whaaaat?..."
while [[ "$CONT_TEST" != "yes" && "$CONT_TEST" != "no" ]] while [[ "$CONT_TEST" != "yes" && "$CONT_TEST" != "no" ]]
do do
@ -103,7 +103,7 @@ echo -e "\n#3 -- Check Google Chrome/driver software. --\n"
check_google_binaries "Google Chrome" "$GOOGL_VER_LOCAL" check_google_binaries "Google Chrome" "$GOOGL_VER_LOCAL"
check_google_binaries "Chromedriver" "$CHD_VER_LOCAL" check_google_binaries "Chromedriver" "$CHD_VER_LOCAL"
if [ ! -z "$CHD_VER_LOCAL" ] && [ ! -z "$GOOGL_VER_LOCAL" ]; then if [ -n "$CHD_VER_LOCAL" ] && [ -n "$GOOGL_VER_LOCAL" ]; then
# Chrome upgrade process # Chrome upgrade process
if [ "$(apt-show-versions google-chrome-stable | grep -c "uptodate")" = "1" ]; then if [ "$(apt-show-versions google-chrome-stable | grep -c "uptodate")" = "1" ]; then
echo -e "Google Chrome is already up to date: \xE2\x9C\x94" echo -e "Google Chrome is already up to date: \xE2\x9C\x94"
@ -112,17 +112,17 @@ if [ ! -z "$CHD_VER_LOCAL" ] && [ ! -z "$GOOGL_VER_LOCAL" ]; then
apt-get -yq install --only-upgrade google-chrome-stable apt-get -yq install --only-upgrade google-chrome-stable
fi fi
# Only upgrade chromedriver if it's on a lower version, not just a different one. # Only upgrade chromedriver if it's on a lower version, not just a different one.
if [ $CHD_VER_2D = $GOOGL_VER_2D ]; then if [ "$CHD_VER_2D" = "$GOOGL_VER_2D" ]; then
echo -e "\nChromedriver version seems according to Google Chrome: \xE2\x9C\x94" echo -e "\nChromedriver version seems according to Google Chrome: \xE2\x9C\x94"
T3=1 T3=1
elif version_gt "$GOOGL_VER_2D" "$CHD_VER_2D" && \ elif version_gt "$GOOGL_VER_2D" "$CHD_VER_2D" && \
[ "$GOOGL_VER_2D" = "$CHD_LTST_2D" ]; then [ "$GOOGL_VER_2D" = "$CHD_LTST_2D" ]; then
echo -e "\nAttempting Chromedriver update!" echo -e "\nAttempting Chromedriver update!"
wget -q https://chromedriver.storage.googleapis.com/$CHD_LTST/chromedriver_linux64.zip \ wget -q https://chromedriver.storage.googleapis.com/"$CHD_LTST"/chromedriver_linux64.zip \
-O /tmp/chromedriver_linux64.zip -O /tmp/chromedriver_linux64.zip
unzip -o /tmp/chromedriver_linux64.zip -d /usr/local/bin/ unzip -o /tmp/chromedriver_linux64.zip -d /usr/local/bin/
chown root:root $CHDB chown root:root "$CHDB"
chmod 0755 $CHDB chmod 0755 "$CHDB"
rm -rf /tpm/chromedriver_linux64.zip rm -rf /tpm/chromedriver_linux64.zip
if [ "$($CHDB -v | awk '{print $2}'|cut -d "." -f 1,2)" = "$GOOGL_VER_2D" ]; then if [ "$($CHDB -v | awk '{print $2}'|cut -d "." -f 1,2)" = "$GOOGL_VER_2D" ]; then
echo "Successful update" echo "Successful update"
@ -140,24 +140,24 @@ fi
#T4 #T4
echo -e "\n#4 -- Test kernel modules --\n" echo -e "\n#4 -- Test kernel modules --\n"
if [ -z $SND_AL_MODULE ]; then if [ -z "$SND_AL_MODULE" ]; then
#First make sure the recommended kernel is installed. #First make sure the recommended kernel is installed.
if [ "$HWE_VIR_MOD" = "1" ]; then if [ "$HWE_VIR_MOD" = "1" ]; then
apt-get -y install \ apt-get -y install \
linux-image-generic-hwe-$(lsb_release -sr) linux-image-generic-hwe-"$(lsb_release -sr)"
else else
apt-get -y install \ apt-get -y install \
linux-image-generic \ linux-image-generic \
linux-modules-extra-$(uname -r) linux-modules-extra-"$(uname -r)"
fi fi
echo -e "\nNo module snd_aloop detected. \xE2\x9C\x96 <== IMPORTANT! \nCurrent kernel: $(uname -r)\n" echo -e "\nNo module snd_aloop detected. \xE2\x9C\x96 <== IMPORTANT! \nCurrent kernel: $(uname -r)\n"
echo -e "\nIf you just installed a new kernel, \ echo -e "\nIf you just installed a new kernel, \
please try rebooting.\nFor now wait 'til the end of the recommended kernel installation." please try rebooting.\nFor now wait 'til the end of the recommended kernel installation."
echo "# Check and Install HWE kernel if possible..." echo "# Check and Install HWE kernel if possible..."
if uname -r | grep -q aws;then if uname -r | grep -q aws;then
KNL_HWE="$(apt-cache madison linux-image-generic-hwe-$(lsb_release -sr)|awk 'NR==1{print$3}'|cut -d "." -f1-4)" 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)" KNL_MENU="$(awk -F\' '/menuentry / {print $2}' /boot/grub/grub.cfg|awk '!/recovery/&&/generic/{print$3,$4}'|grep "$KNL_HWE")"
if [ ! -z "$KNL_MENU" ];then if [ -n "$KNL_MENU" ];then
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 "\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" echo -e "\n > $KNL_MENU"
fi fi
@ -172,8 +172,8 @@ fi
echo -e "\n#5 -- Test .asoundrc file --\n" echo -e "\n#5 -- Test .asoundrc file --\n"
ASRC_MASTER="https://raw.githubusercontent.com/jitsi/jibri/master/resources/debian-package/etc/jitsi/jibri/asoundrc" ASRC_MASTER="https://raw.githubusercontent.com/jitsi/jibri/master/resources/debian-package/etc/jitsi/jibri/asoundrc"
ASRC_INSTALLED="/home/jibri/.asoundrc" ASRC_INSTALLED="/home/jibri/.asoundrc"
ASRC_MASTER_MD5SUM=$(curl -sL $ASRC_MASTER | md5sum | cut -d ' ' -f 1) ASRC_MASTER_MD5SUM="$(curl -sL "$ASRC_MASTER" | md5sum | cut -d ' ' -f 1)"
ASRC_INSTALLED_MD5SUM=$(md5sum $ASRC_INSTALLED | cut -d ' ' -f 1) ASRC_INSTALLED_MD5SUM="$(md5sum "$ASRC_INSTALLED" | cut -d ' ' -f 1)"
if [ "$ASRC_MASTER_MD5SUM" == "$ASRC_INSTALLED_MD5SUM" ]; then if [ "$ASRC_MASTER_MD5SUM" == "$ASRC_INSTALLED_MD5SUM" ]; then
echo -e "Seems to be using the latest asoundrc file available. \xE2\x9C\x94" echo -e "Seems to be using the latest asoundrc file available. \xE2\x9C\x94"
@ -187,20 +187,20 @@ fi
echo -e "\n#6 -- Old or new config --\n" echo -e "\n#6 -- Old or new config --\n"
echo -e "What config version is this using?" echo -e "What config version is this using?"
if [ -f ${CONF_JSON}_disabled ] && \ if [ -f "${CONF_JSON}"_disabled ] && \
[ -f $JIBRI_CONF ] && \ [ -f "$JIBRI_CONF" ] && \
[ -f $JIBRI_CONF-dpkg-file ]; then [ -f "$JIBRI_CONF"-dpkg-file ]; then
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 \ 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 \
https://github.com/switnet-ltd/quick-jibri-installer/issues\n" https://github.com/switnet-ltd/quick-jibri-installer/issues\n"
T6=1 T6=1
elif [ ! -f $CONF_JSON ] && \ elif [ ! -f "$CONF_JSON" ] && \
[ -f $JIBRI_CONF ] && \ [ -f "$JIBRI_CONF" ] && \
[ -f ${JIBRI_CONF}-dpkg-file ]; then [ -f "${JIBRI_CONF}"-dpkg-file ]; then
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 \ 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 \
https://github.com/switnet-ltd/quick-jibri-installer/issues\n" https://github.com/switnet-ltd/quick-jibri-installer/issues\n"
T6=1 T6=1
elif [ -f ${CONF_JSON} ] && \ elif [ -f "${CONF_JSON}" ] && \
[ -f $JIBRI_CONF ]; then [ -f "$JIBRI_CONF" ]; then
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 \ 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 \
https://github.com/switnet-ltd/quick-jibri-installer/issues\n" https://github.com/switnet-ltd/quick-jibri-installer/issues\n"
T6=0 T6=0
@ -220,8 +220,7 @@ fi
#T7 #T7
echo -e "\n#7 -- Check for open communication port among Jibri and JMS --\n" echo -e "\n#7 -- Check for open communication port among Jibri and JMS --\n"
nc -z -v -w5 $JMS_DOMAIN 5222 if ! nc -z -v -w5 "$JMS_DOMAIN" 5222 ; then
if [ "$?" -ne 0 ]; then
echo -e "Connection failed! \xE2\x9C\x96\n > You might want to check both Jibri & JMS firewall rules (TCP 5222)." echo -e "Connection failed! \xE2\x9C\x96\n > You might want to check both Jibri & JMS firewall rules (TCP 5222)."
T7=0 T7=0
else else