diff --git a/add-jibri-node.sh b/add-jibri-node.sh index 5cdd7fb..b6ee47e 100644 --- a/add-jibri-node.sh +++ b/add-jibri-node.sh @@ -62,6 +62,7 @@ NJN_USER_PASS="$(tr -dc "a-zA-Z0-9#_*=" < /dev/urandom | fold -w 32 | head -n1)" GITHUB_RAW="https://raw.githubusercontent.com" GIT_REPO="switnet-ltd/quick-jibri-installer" TEST_JIBRI_ENV="$GITHUB_RAW/$GIT_REPO/unstable/tools/test-jibri-env.sh" +SHORT_ID="$(awk '{print substr($0,0,7)}' /etc/machine-id)" ### 1_VAR_DEF # sed limiters for add-jibri-node.sh variables @@ -78,14 +79,9 @@ check_var() { fi } -if [ -z "$LAST" ]; then - echo "There is an error on the LAST definition, please report." - exit -elif [ "$LAST" = "TBD" ]; then - ADDUP=$((START + 1)) -else - ADDUP=$((LAST + 1)) -fi +#Change in favor of machine-id identifier +crontab -l | { cat; echo "@reboot sed -i \"/[[:space:]]control-muc/,/[[:space:]]control-login/{s|nickname = .*|nickname = \\\"$(cat /etc/machine-id)\\\"|}\" /etc/jitsi/jibri/jibri.conf"; } | crontab - +crontab -l echo " #----------------------------------------------------------------------- @@ -183,8 +179,8 @@ else fi # Rename hostname for each jibri node -hostnamectl set-hostname "jbnode${ADDUP}.${MAIN_SRV_DOMAIN}" -sed -i "1i 127.0.0.1 jbnode${ADDUP}.${MAIN_SRV_DOMAIN}" /etc/hosts +hostnamectl set-hostname "jbnode_${SHORT_ID}.${MAIN_SRV_DOMAIN}" +sed -i "1i 127.0.0.1 jbnode_${SHORT_ID}.${MAIN_SRV_DOMAIN}" /etc/hosts # Jitsi-Meet Repo echo "Add Jitsi repo" @@ -413,7 +409,7 @@ jibri { control-muc { domain = "internal.auth.$MAIN_SRV_DOMAIN" room-name = "$JibriBrewery" - nickname = "Live-$ADDUP" + nickname = "machine-id" } // The login information for the control MUC @@ -539,11 +535,6 @@ systemctl daemon-reload systemctl enable remote_jnsync.service systemctl start remote_jnsync.service -echo "Writing last node number..." -sed -i "$(var_dlim 0_VAR),$(var_dlim 1_VAR){s|LAST=.*|LAST=$ADDUP|}" add-jibri-node.sh -sed -i "$(var_dlim 0_LAST),$(var_dlim 1_LAST){s|LETS: .*|LETS: $(date -R)|}" add-jibri-node.sh -echo "Last file edition at: $(awk -F 'LETS:' '/LETS/{print$2}' add-jibri-node.sh|head -n1)" - #Enable jibri services systemctl enable jibri systemctl enable jibri-xorg @@ -551,26 +542,16 @@ systemctl enable jibri-icewm check_snd_driver -echo -e "\nSending updated add-jibri-node.sh file to main server sync user...\n" -cp $PWD/add-jibri-node.sh /tmp -sudo -u $NJN_USER scp /tmp/add-jibri-node.sh $MJS_USER@$MAIN_SRV_DOMAIN:/home/$MJS_USER/ -rm $PWD/add-jibri-node.sh /tmp/add-jibri-node.sh - echo " ######################################################################## Node addition complete!! - IMPORTANT: - The updated version of this file has been sent to the main server - at the sync user home directory, please use that one in order to - install new nodes. For security reason this version has been deleted - from this very node. - For customized support: http://switnet.net ######################################################################## " -echo "Rebooting in..." +echo "Make sure to reboot, it's necessary before *any* usage. +Rebooting in..." secs=$((15)) while [ $secs -gt 0 ]; do echo -ne "$secs\033[0K\r" diff --git a/add-jvb2-node.sh b/add-jvb2-node.sh index 37d08e2..34fdb46 100644 --- a/add-jvb2-node.sh +++ b/add-jvb2-node.sh @@ -63,10 +63,8 @@ JITSI_REPO=$(apt-cache policy | awk '/jitsi/&&/stable/{print$3}' | awk -F / 'NR= JVB2_CONF="/etc/jitsi/videobridge/config" JVB2_NCONF="/etc/jitsi/videobridge/jvb.conf" JVB2_SIP="/etc/jitsi/videobridge/sip-communicator.properties" +SHORT_ID="$(awk '{print substr($0,0,7)}' /etc/machine-id)" #PUBLIC_IP="$(dig -4 @resolver1.opendns.com ANY myip.opendns.com +short)" -NJN_RAND_TAIL="$(tr -dc "a-zA-Z0-9" < /dev/urandom | fold -w 4 | head -n1)" -NJN_USER="jvbnode${ADDUP}_${NJN_RAND_TAIL}" -NJN_USER_PASS="$(tr -dc "a-zA-Z0-9#_*=" < /dev/urandom | fold -w 32 | head -n1)" #GITHUB_RAW="https://raw.githubusercontent.com" #GIT_REPO="switnet-ltd/quick-jibri-installer" ### 1_VAR_DEF @@ -85,15 +83,6 @@ check_var() { fi } -if [ -z "$LAST" ]; then - echo "There is an error on the LAST definition, please report." - exit -elif [ "$LAST" = "TBD" ]; then - ADDUP=$((START + 1)) -else - ADDUP=$((LAST + 1)) -fi - #Check server and node OS if [ ! "$THIS_SRV_DIST" = "$MAIN_SRV_DIST" ]; then echo "Please use the same OS for the JVB2 setup on both servers." @@ -107,7 +96,7 @@ echo "Verifying System Resources:" if [ "$(nproc --all)" -lt 4 ];then echo " Warning!: The system do not meet the CPU recomendations for a JVB node for heavy loads. ->> We recommend 4 cores/threads for JVB2! +>> We recommend 4 cores/threads or above for JVB2! " CPU_MIN="N" else @@ -119,7 +108,7 @@ mem_available=$(grep MemTotal /proc/meminfo| grep -o '[0-9]\+') if [ ${mem_available} -lt 7700000 ]; then echo " Warning!: The system do not meet the CPU recomendations for a JVB node for heavy loads. ->> We recommend 8GB RAM for JVB2! +>> We recommend 8GB RAM or above for JVB2! " MEM_MIN="N" else @@ -171,8 +160,8 @@ check_var MUC_JID "$MUC_JID" check_var MAIN_SRV_DOMAIN "$MAIN_SRV_DOMAIN" # Rename hostname for each jvb2 node -hostnamectl set-hostname "jvb${ADDUP}.${MAIN_SRV_DOMAIN}" -sed -i "1i 127.0.0.1 jvb${ADDUP}.${MAIN_SRV_DOMAIN}" /etc/hosts +hostnamectl set-hostname "jvb_${SHORT_ID}.${MAIN_SRV_DOMAIN}" +sed -i "1i 127.0.0.1 jvb_${SHORT_ID}.${MAIN_SRV_DOMAIN}" /etc/hosts # Jitsi-Meet Repo echo "Add Jitsi repo" @@ -297,42 +286,14 @@ cat << JVB2 >> $JVB2_NCONF } JVB2 -echo -e "\n---- Create random nodesync user ----" -useradd -m -g jitsi $NJN_USER -echo "$NJN_USER:$NJN_USER_PASS" | chpasswd - -echo -e "\n---- We'll connect to main server ----" -read -n 1 -s -r -p "Press any key to continue..."$'\n' -sudo su $NJN_USER -c "ssh-keygen -t rsa -f ~/.ssh/id_rsa -b 4096 -o -a 100 -q -N ''" -echo "Remote pass: $MJS_USER_PASS" -ssh-keyscan -t rsa $MAIN_SRV_DOMAIN >> ~/.ssh/known_hosts -ssh $MJS_USER@$MAIN_SRV_DOMAIN sh -c "'cat >> .ssh/authorized_keys'" < /home/$NJN_USER/.ssh/id_rsa.pub -sudo su $NJN_USER -c "ssh-keyscan -t rsa $MAIN_SRV_DOMAIN >> /home/$NJN_USER/.ssh/known_hosts" - -echo "Writing last node number..." -sed -i "$(var_dlim 0_VAR),$(var_dlim 1_VAR){s|LAST=.*|LAST=$ADDUP|}" add-jvb2-node.sh -sed -i "$(var_dlim 0_LAST),$(var_dlim 1_LAST){s|LETS: .*|LETS: $(date -R)|}" add-jvb2-node.sh -echo "Last file edition at: $(grep "LETS:" add-jvb2-node.sh|head -n1|awk -F'LETS:' '{print$2}')" - #Enable jvb2 services systemctl enable jitsi-videobridge2.service systemctl restart jitsi-videobridge2.service -echo -e "\nSending updated add-jvb2-node.sh file to main server sync user...\n" -cp $PWD/add-jvb2-node.sh /tmp -sudo -u $NJN_USER scp /tmp/add-jvb2-node.sh $MJS_USER@$MAIN_SRV_DOMAIN:/home/$MJS_USER/ -rm $PWD/add-jvb2-node.sh /tmp/add-jvb2-node.sh - echo " ######################################################################## Node addition complete!! - IMPORTANT: - The updated version of this file has been sent to the main server - at the sync user home directory, please use that one in order to - install new nodes. For security reason this version has been deleted - from this very node. - For customized support: http://switnet.net ######################################################################## " diff --git a/tools/test-jibri-env.sh b/tools/test-jibri-env.sh index cc6f143..ae87a22 100644 --- a/tools/test-jibri-env.sh +++ b/tools/test-jibri-env.sh @@ -51,6 +51,7 @@ 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)") CONF_JSON="/etc/jitsi/jibri/config.json" JIBRI_CONF="/etc/jitsi/jibri/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)" @@ -163,7 +164,7 @@ please try rebooting.\nFor now wait 'til the end of the recommended kernel insta fi T4=0 else - echo -e "Great!\nModule snd-aloop found!" + echo -e "Great!, module snd-aloop found. \xE2\x9C\x94" T4=1 fi @@ -175,10 +176,10 @@ 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 "Seems to be using the latest asoundrc file available!" + echo -e "Seems to be using the latest asoundrc file available. \xE2\x9C\x94" T5=1 else - echo "asoundrc files differ, if you have errors, you might wanna check this file!" + echo -e "asoundrc files differ, if you have errors, you might wanna check this file \xE2\x9C\x96" T5=0 fi @@ -217,11 +218,22 @@ https://github.com/switnet-ltd/quick-jibri-installer/issues\n" T6_1=0 fi -TEST_TOTAL=$(awk "BEGIN{ print $T1 + $T2 + $T3 + $T4 + $T5 + $T6 + $T6_1 }") +#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 + 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 }") echo " ############################## \ -Score: $TEST_TOTAL out of 6.1 +Score: $TEST_TOTAL out of 7.1 ############################## " echo -e "\nJibri Test complete, thanks for testing.\n"