From 1875cf5db5cbf4bd9260e615116c8a8be709d002 Mon Sep 17 00:00:00 2001 From: Ark74 Date: Wed, 11 May 2022 23:52:44 -0500 Subject: [PATCH] Comply tools section with shellcheck recommendations. --- tools/aws-grub-setup.sh | 24 +++++------ tools/fail2ban_ssh.sh | 6 +-- tools/jibri-conf-upgrade.sh | 68 +++++++++++++++--------------- tools/jibri-resolution-enhancer.sh | 30 ++++++------- tools/start-over.sh | 20 ++++----- tools/test-jibri-env.sh | 63 ++++++++++++++------------- 6 files changed, 105 insertions(+), 106 deletions(-) diff --git a/tools/aws-grub-setup.sh b/tools/aws-grub-setup.sh index 409bb4a..14c2c24 100644 --- a/tools/aws-grub-setup.sh +++ b/tools/aws-grub-setup.sh @@ -19,7 +19,7 @@ done } # 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! exit 1 fi @@ -30,36 +30,36 @@ GRUB_FILE="/etc/default/grub" echo -e "# Check and update HWE kernel if possible...\n" 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 apt-get -y install \ - linux-image-generic-hwe-$(lsb_release -sr) \ - linux-tools-generic-hwe-$(lsb_release -sr) + linux-image-generic-hwe-"$(lsb_release -sr)" \ + linux-tools-generic-hwe-"$(lsb_release -sr)" else apt-get -y install \ linux-image-generic \ - linux-modules-extra-$(uname -r) + linux-modules-extra-"$(uname -r)" fi apt-get -y autoremove apt-get autoclean #Write update-grub output -update-grub > $KERNEL_LOG 2>&1 +update-grub > "$KERNEL_LOG" 2>&1 #Get clean output -cat $KERNEL_LOG | awk -F'boot/' '{print$2}'|sed '/^[[:space:]]*$/d' | \ -tee ${KERNEL_LOG}.tmp -mv ${KERNEL_LOG}.tmp $KERNEL_LOG +awk -F'boot/' '{print$2}' < "$KERNEL_LOG"|sed '/^[[:space:]]*$/d' | \ +tee "$KERNEL_LOG".tmp +mv "$KERNEL_LOG".tmp "$KERNEL_LOG" 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 -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 }")" 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" update-grub diff --git a/tools/fail2ban_ssh.sh b/tools/fail2ban_ssh.sh index 84257a0..35d2186 100644 --- a/tools/fail2ban_ssh.sh +++ b/tools/fail2ban_ssh.sh @@ -18,7 +18,7 @@ set -x fi #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!" exit 0 fi @@ -27,8 +27,8 @@ apt-get -y install fail2ban if \ [ -f /var/log/ssh_f2b.log ] && \ -[ $(grep -c 604800 /etc/fail2ban/jail.local) = "1" ] && \ -[ $(grep -c ssh_f2b.log /etc/fail2ban/jail.local) = "1"]; then +[ "$(grep -c 604800 /etc/fail2ban/jail.local)" = "1" ] && \ +[ "$(grep -c ssh_f2b.log /etc/fail2ban/jail.local)" = "1" ]; then echo -e "\nFail2ban seems to be already configured.\n" else echo -e "\nConfiguring Fail2ban...\n" diff --git a/tools/jibri-conf-upgrade.sh b/tools/jibri-conf-upgrade.sh index 177f676..654fa63 100644 --- a/tools/jibri-conf-upgrade.sh +++ b/tools/jibri-conf-upgrade.sh @@ -25,7 +25,7 @@ echo -e ' \n' #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!" exit 0 fi @@ -46,19 +46,19 @@ else fi 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 CONF_JSON="/etc/jitsi/jibri/config.json" JIBRI_CONF="/etc/jitsi/jibri/jibri.conf" -DIR_RECORD=/var/jbrecord -REC_DIR=/home/jibri/finalize_recording.sh -JibriBrewery=JibriBrewery +DIR_RECORD="/var/jbrecord" +REC_DIR="/home/jibri/finalize_recording.sh" +JibriBrewery="JibriBrewery" check_read_vars() { echo "Checking $1" if [ -z "$2" ];then - echo "This variable seems wrong, please check before continue" - exit 1 + echo "This variable seems wrong, please check before continue" + exit 1 fi } restart_services_jibri() { @@ -73,44 +73,44 @@ fi } #Prevent re-run on completed jibri upgraded instance -if [ -f $CONF_JSON_disabled ] && \ - [ -f $JIBRI_CONF ] && \ - [ -f $JIBRI_CONF-dpkg-file ]; then +if [ -f "$CONF_JSON"_disabled ] && \ + [ -f "$JIBRI_CONF" ] && \ + [ -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 \ https://github.com/switnet-ltd/quick-jibri-installer/issues\n" exit -elif [ ! -f $CONF_JSON ] && \ - [ -f $JIBRI_CONF ] && \ - [ -f $JIBRI_CONF-dpkg-file ]; then +elif [ ! -f "$CONF_JSON" ] && \ + [ -f "$JIBRI_CONF" ] && \ + [ -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 \ https://github.com/switnet-ltd/quick-jibri-installer/issues\n" exit -elif [ -f $CONF_JSON ] && \ - [ -f $JIBRI_CONF ]; then +elif [ -f "$CONF_JSON" ] && \ + [ -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 \ https://github.com/switnet-ltd/quick-jibri-installer/issues\n" fi #Read missing variables -if [ -f $CONF_JSON ]; then +if [ -f "$CONF_JSON" ]; then echo "Reading current config.json file..." - if [ -z $DOMAIN ]; then - DOMAIN=$(jq .xmpp_environments[0].xmpp_domain $CONF_JSON|cut -d '"' -f2) + if [ -z "$DOMAIN" ]; then + DOMAIN="$(jq .xmpp_environments[0].xmpp_domain $CONF_JSON|cut -d '"' -f2)" fi - 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_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_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_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)" else echo "Can't find the instance config.json file, exiting..." exit fi -check_read_vars "Jibri Name" $JB_NAME -check_read_vars "(Main server) Domain" $DOMAIN -check_read_vars "Control login passwd" $JB_AUTH_PASS -check_read_vars "Call login passwd" $JB_REC_PASS -check_read_vars "Jibri Node nickname" $JB_NICKN +check_read_vars "Jibri Name" "$JB_NAME" +check_read_vars "(Main server) Domain" "$DOMAIN" +check_read_vars "Control login passwd" "$JB_AUTH_PASS" +check_read_vars "Call login passwd" "$JB_REC_PASS" +check_read_vars "Jibri Node nickname" "$JB_NICKN" if [ "$MODE" = "debug" ]; then echo "$JB_NAME" @@ -122,10 +122,10 @@ fi #Backup and setup new conf file 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 -cat << NEW_CONF > $JIBRI_CONF +mv "$JIBRI_CONF" "${JIBRI_CONF}"-dpkg-file +cat << NEW_CONF > "$JIBRI_CONF" // New XMPP environment config. jibri { recording { @@ -195,13 +195,13 @@ jibri { NEW_CONF echo "Check final jibri.conf file:" -cat $JIBRI_CONF -read -n 1 -s -r -p "Press any key to continue..."$'\n' +cat "$JIBRI_CONF" +read -n 1 -s -r -p "Press any key to continue..." restart_services_jibri systemctl status jibri if [ -f /var/log/jitsi/jicofo.log ]; then -echo -e "Checking for jicofo recognizing \"Live\" jibri node..." -tail -n 10 | grep Live + echo -e "Checking for jicofo recognizing \"Live\" jibri node..." + tail -n 10 | grep Live fi diff --git a/tools/jibri-resolution-enhancer.sh b/tools/jibri-resolution-enhancer.sh index c18e879..f7e27bd 100644 --- a/tools/jibri-resolution-enhancer.sh +++ b/tools/jibri-resolution-enhancer.sh @@ -18,7 +18,7 @@ if [ "$MODE" = "debug" ]; then fi #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!" exit 0 fi @@ -46,15 +46,15 @@ if [ -f "$JIBRI_OPT/jibri-res_enh.jar" ] && \ fi mkdir /tmp/jibri -cd /tmp/jibri +cd /tmp/jibri || exit #Get md5sum for current jibri installed. -apt-get download jibri=$INSTALLED_JIBRI_VERSION +apt-get download jibri="$INSTALLED_JIBRI_VERSION" ar x jibri_*.deb tar xvf data.tar.xz 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..." exit fi @@ -66,8 +66,8 @@ apt-get -y install devscripts \ openjdk-8-jdk #Build repository -git clone https://github.com/jitsi/jibri $JIBRI_ENH_PATH -cd $JIBRI_ENH_PATH +git clone https://github.com/jitsi/jibri "$JIBRI_ENH_PATH" +cd "$JIBRI_ENH_PATH" || exit # Default values ## 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 mvn package -JIBRI_JAR="$(ls -Sh $JIBRI_ENH_PATH/target|awk '/dependencies/&&/.jar/{print}'|awk 'NR==1{print}')" -cp $JIBRI_ENH_PATH/target/$JIBRI_JAR $JIBRI_ENH_PATH/target/jibri.jar +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 # Backing up default binaries 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 # Migrate original to enhanced jibri -cp $JIBRI_ENH_PATH/target/jibri.jar $JIBRI_OPT/jibri-res_enh.jar -if [ -f $JIBRI_OPT/jibri-dpkg-package.jar ];then - cp $JIBRI_OPT/jibri-res_enh.jar $JIBRI_OPT/jibri.jar +cp "$JIBRI_ENH_PATH"/target/jibri.jar "$JIBRI_OPT"/jibri-res_enh.jar +if [ -f "$JIBRI_OPT"/jibri-dpkg-package.jar ];then + cp "$JIBRI_OPT"/jibri-res_enh.jar "$JIBRI_OPT"/jibri.jar fi 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 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 - cp $JIBRI_OPT/jibri-dpkg-package.jar $JIBRI_OPT/jibri.jar + cp "$JIBRI_OPT"/jibri-dpkg-package.jar "$JIBRI_OPT"/jibri.jar CLEAN="true" else if [ -f /tmp/jibri/opt/jitsi/jibri/jibri.jar ]; then 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" else echo "Wow, someone took the time to avoid restoration, please manually review your changes." @@ -115,7 +115,7 @@ else fi if [ "$CLEAN" = "true" ]; then rm -r /tmp/jibri - rm -r $JIBRI_ENH_PATH + rm -r "$JIBRI_ENH_PATH" rm /opt/jitsi/jibri/jibri-res_enh.jar fi diff --git a/tools/start-over.sh b/tools/start-over.sh index 4db729f..3b7441a 100644 --- a/tools/start-over.sh +++ b/tools/start-over.sh @@ -18,7 +18,7 @@ if [ "$MODE" = "debug" ]; then fi #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!" exit 0 fi @@ -32,16 +32,16 @@ while [ $secs -gt 0 ]; do done } remove_residuals() { - if [ -d $1 ]; then - rm -r $1 + if [ -d "$1" ]; then + rm -r "$1" fi } purge_debconf() { - echo PURGE | debconf-communicate $1 + echo PURGE | debconf-communicate "$1" } remove_services() { - systemctl disable $1 - systemctl stop $1 + systemctl disable "$1" + systemctl stop "$1" } echo -e ' ######################################################################## @@ -50,8 +50,8 @@ echo -e ' by Software, IT & Networks Ltd \n' -SYNC_USER="$(ls /home|awk '/jbsync/{print}')" -DOMAIN="$(ls /etc/prosody/conf.d/ | awk -F'.cfg' '!/localhost/{print $1}' | awk '!NF || !seen[$0]++')" +SYNC_USER="$(find /home -maxdepth 1 -type d |awk '/jbsync/{print}')" +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... 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 #Remove unused users & groups -if [ ! -z $SYNC_USER ]; then - deluser --remove-home $SYNC_USER +if [ -n "$SYNC_USER" ]; then + deluser --remove-home "$SYNC_USER" fi if [ -d /home/jibri ]; then deluser --remove-home jibri diff --git a/tools/test-jibri-env.sh b/tools/test-jibri-env.sh index ae87a22..39e1a0a 100644 --- a/tools/test-jibri-env.sh +++ b/tools/test-jibri-env.sh @@ -25,7 +25,7 @@ echo -e ' \n' #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!" exit 0 fi @@ -39,30 +39,30 @@ check_google_binaries() { if [ -z "$2" ]; then echo "Warning: No $1 doesn't seem installed" else - echo $2 + echo "$2" fi } # True if $1 is greater than $2 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) -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" 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}')" CHD_VER_LOCAL="$($CHDB --version 2>/dev/null| awk '{print$1,$2}')" 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)" -GOOGL_VER_2D="$(echo $GOOGL_VER_LOCAL|awk '{print$3}'|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)" 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 echo -e "\n#1 -- Check repository --\n" -if [ -z $JITSI_REPO ]; then +if [ -z "$JITSI_REPO" ]; then echo "No repository detected, wait whaaaat?..." while [[ "$CONT_TEST" != "yes" && "$CONT_TEST" != "no" ]] 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 "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 if [ "$(apt-show-versions google-chrome-stable | grep -c "uptodate")" = "1" ]; then 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 fi # 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" T3=1 elif version_gt "$GOOGL_VER_2D" "$CHD_VER_2D" && \ [ "$GOOGL_VER_2D" = "$CHD_LTST_2D" ]; then 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 unzip -o /tmp/chromedriver_linux64.zip -d /usr/local/bin/ - chown root:root $CHDB - chmod 0755 $CHDB + chown root:root "$CHDB" + chmod 0755 "$CHDB" rm -rf /tpm/chromedriver_linux64.zip if [ "$($CHDB -v | awk '{print $2}'|cut -d "." -f 1,2)" = "$GOOGL_VER_2D" ]; then echo "Successful update" @@ -140,24 +140,24 @@ fi #T4 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. if [ "$HWE_VIR_MOD" = "1" ]; then apt-get -y install \ - linux-image-generic-hwe-$(lsb_release -sr) + linux-image-generic-hwe-"$(lsb_release -sr)" else apt-get -y install \ linux-image-generic \ - linux-modules-extra-$(uname -r) + linux-modules-extra-"$(uname -r)" fi 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, \ please try rebooting.\nFor now wait 'til the end of the recommended kernel installation." echo "# Check and Install HWE kernel if possible..." 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_MENU="$(awk -F\' '/menuentry / {print $2}' /boot/grub/grub.cfg|awk '!/recovery/&&/generic/{print$3,$4}'|grep $KNL_HWE)" - if [ ! -z "$KNL_MENU" ];then + 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 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" fi @@ -172,8 +172,8 @@ fi 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_INSTALLED="/home/jibri/.asoundrc" -ASRC_MASTER_MD5SUM=$(curl -sL $ASRC_MASTER | md5sum | cut -d ' ' -f 1) -ASRC_INSTALLED_MD5SUM=$(md5sum $ASRC_INSTALLED | 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)" if [ "$ASRC_MASTER_MD5SUM" == "$ASRC_INSTALLED_MD5SUM" ]; then 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 "What config version is this using?" -if [ -f ${CONF_JSON}_disabled ] && \ - [ -f $JIBRI_CONF ] && \ - [ -f $JIBRI_CONF-dpkg-file ]; then +if [ -f "${CONF_JSON}"_disabled ] && \ + [ -f "$JIBRI_CONF" ] && \ + [ -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 \ https://github.com/switnet-ltd/quick-jibri-installer/issues\n" T6=1 -elif [ ! -f $CONF_JSON ] && \ - [ -f $JIBRI_CONF ] && \ - [ -f ${JIBRI_CONF}-dpkg-file ]; then +elif [ ! -f "$CONF_JSON" ] && \ + [ -f "$JIBRI_CONF" ] && \ + [ -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 \ https://github.com/switnet-ltd/quick-jibri-installer/issues\n" T6=1 -elif [ -f ${CONF_JSON} ] && \ - [ -f $JIBRI_CONF ]; then +elif [ -f "${CONF_JSON}" ] && \ + [ -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 \ https://github.com/switnet-ltd/quick-jibri-installer/issues\n" T6=0 @@ -220,8 +220,7 @@ fi #T7 echo -e "\n#7 -- Check for open communication port among Jibri and JMS --\n" -nc -z -v -w5 $JMS_DOMAIN 5222 -if [ "$?" -ne 0 ]; then +if ! nc -z -v -w5 "$JMS_DOMAIN" 5222 ; then echo -e "Connection failed! \xE2\x9C\x96\n > You might want to check both Jibri & JMS firewall rules (TCP 5222)." T7=0 else