quick-jibri-installer/jitsi-updater.sh

195 lines
7.1 KiB
Bash

#!/bin/bash
# Jitsi Meet recurring upgrader and customization keeper
# for Debian/*buntu binaries.
# SwITNet Ltd © - 2021, https://switnet.net/
# GNU GPLv3 or later.
Blue='\e[0;34m'
Purple='\e[0;35m'
Green='\e[0;32m'
Yellow='\e[0;33m'
Color_Off='\e[0m'
printwc() {
printf "%b$2%b" "$1" "${Color_Off}"
}
#Check if user is root
if ! [ "$(id -u)" = 0 ]; then
echo "You need to be root or have sudo privileges!"
exit 0
fi
if [ ! -f jm-bm.sh ]; then
echo "Please check that you are running the jitsi updater while being on the project folder"
echo "other wise the updater might have errors or be incomplete. Exiting..."
exit
fi
support="https://switnet.net/support"
apt_repo="/etc/apt/sources.list.d"
ENABLE_BLESSM="TBD"
CHD_LTST="$(curl -sL https://chromedriver.storage.googleapis.com/LATEST_RELEASE)"
CHD_LTST_2D="$(echo "$CHD_LTST"|cut -d "." -f 1,2)"
CHDB="$(whereis chromedriver | awk '{print$2}')"
DOMAIN="$(find /etc/prosody/conf.d/ -name \*.lua|awk -F'.cfg' '!/localhost/{print $1}'|xargs basename)"
NC_DOMAIN="TBD"
JITSI_MEET_PROXY="/etc/nginx/modules-enabled/60-jitsi-meet.conf"
if [ -f "$JITSI_MEET_PROXY" ];then
PREAD_PROXY=$(grep -nr "preread_server_name" "$JITSI_MEET_PROXY" | cut -d ":" -f1)
fi
INT_CONF="/usr/share/jitsi-meet/interface_config.js"
INT_CONF_ETC="/etc/jitsi/meet/$DOMAIN-interface_config.js"
jibri_packages="$(grep Package /var/lib/apt/lists/download.jitsi.org_*_Packages |sort -u|awk '{print $2}'|sed 's|jigasi||')"
AVATAR="$(grep -r avatar /etc/nginx/sites-*/ 2>/dev/null)"
if [ -f "$apt_repo"/google-chrome.list ]; then
google_package=$(grep Package /var/lib/apt/lists/dl.google.com_linux_chrome_deb_dists_stable_main_binary-amd64_Packages | sort -u | cut -d ' ' -f2)
else
echo "Seems no Google repo installed"
fi
if [ -z "$CHDB" ]; then
echo "Seems no chromedriver installed"
else
CHD_VER_LOCAL="$($CHDB -v | awk '{print $2}')"
CHD_VER_2D="$(echo "$CHD_VER_LOCAL"|awk '{printf "%.1f\n", $NF}')"
fi
# True if $1 is greater than $2
version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; }
check_jibri() {
if [ "$(dpkg-query -W -f='${Status}' "jibri" 2>/dev/null | grep -c "ok installed")" == "1" ]
then
systemctl restart jibri
systemctl restart jibri-icewm
systemctl restart jibri-xorg
else
echo "Jibri service not installed"
fi
}
# Restarting services
restart_services() {
systemctl restart jitsi-videobridge2
systemctl restart jicofo
check_jibri
systemctl restart prosody
}
update_jitsi_repo() {
apt-get update -o Dir::Etc::sourcelist="sources.list.d/jitsi-$1.list" \
-o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
apt-get install -qq --only-upgrade "$jibri_packages"
}
update_google_repo() {
if [ -f "$apt_repo"/google-chrome.list ]; then
apt-get update -o Dir::Etc::sourcelist="sources.list.d/google-chrome.list" \
-o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
apt-get install -qq --only-upgrade "$google_package"
else
echo "No Google repository found"
fi
}
GOOGL_VER_2D="$(/usr/bin/google-chrome --version|awk '{printf "%.1f\n", $NF}')"
upgrade_cd() {
if [ -n "$GOOGL_VER_2D" ]; then
if version_gt "$GOOGL_VER_2D" "$CHD_VER_2D" ; then
echo "Upgrading Chromedriver to Google Chromes version"
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"
rm -rf /tpm/chromedriver_linux64.zip
printf "Current version: "
printwc "$Green" "$($CHDB -v |awk '{print $2}'|awk '{printf "%.1f\n", $NF}')"
echo -e " (latest available)\n"
elif [ "$GOOGL_VER_2D" = "$CHD_LTST_2D" ]; then
echo "No need to upgrade Chromedriver"
printf "Current version: "
printwc "$Green" "$CHD_VER_2D\n"
fi
else
printwc "${Yellow}" " -> No Google Chrome versión to match, leaving untouched.\n"
fi
}
check_lst_cd() {
printwc "${Purple}" "Checking for the latest Chromedriver\n"
if [ -f "$CHDB" ]; then
printf "Current installed Chromedriver: "
printwc "${Yellow}" "$CHD_VER_2D\n"
printf "Current installed Google Chrome: "
printwc "${Green}" "$GOOGL_VER_2D\n"
upgrade_cd
else
printwc "${Yellow}" " -> Seems there is no Chromedriver installed\n"
fi
}
printwc "${Blue}" "Update & upgrade Jitsi and components\n"
if [ -f "$apt_repo"/jitsi-unstable.list ]; then
update_jitsi_repo unstable
update_google_repo
check_lst_cd
elif [ -f "$apt_repo"/jitsi-stable.list ]; then
update_jitsi_repo stable
update_google_repo
check_lst_cd
else
echo "Please check your repositories, something is not right."
exit 1
fi
# Any customization, image, name or link change for any purpose should
# be documented here so new updates won't remove those changes.
# We divide them on UI changes and branding changes, feel free to adapt
# to your needs.
#
# Please keep in mind that fees for support customization changes may
# apply.
########################################################################
# User interface changes #
########################################################################
if [ -f "$INT_CONF_ETC" ]; then
echo "Static interface_config.js exists, skipping modification..."
else
echo "This setup doesn't have a static interface_config.js, checking changes..."
printwc "${Purple}" "========== Setting Static Avatar ==========\n"
if [[ -z "$AVATAR" ]]; then
echo "Moving on..."
else
echo "Setting Static Avatar"
sed -i "/RANDOM_AVATAR_URL_PREFIX/ s|false|\'http://$DOMAIN/avatar/\'|" "$INT_CONF"
sed -i "/RANDOM_AVATAR_URL_SUFFIX/ s|false|\'.png\'|" "$INT_CONF"
fi
printwc "${Purple}" "========== Setting Support Link ==========\n"
if [[ -z "$support" ]]; then
echo "Moving on..."
else
echo "Setting Support custom link"
sed -i "s|https://jitsi.org/live|$support|g" "$INT_CONF"
fi
printwc "${Purple}" "========== Disable Blur my background ==========\n"
sed -i "s|'videobackgroundblur', ||" "$INT_CONF"
fi
if [ "$NC_DOMAIN" != "TBD" ]; then
printwc "${Purple}" "========== Enable $NC_DOMAIN for sync client ==========\n"
if [ -z "$PREAD_PROXY" ]; then
printf "\n Setting up Nextcloud domain on Jitsi Meet turn proxy\n\n"
sed -i "/server {/i \ \ map \$ssl_preread_server_name \$upstream {" "$JITSI_MEET_PROXY"
sed -i "/server {/i \ \ \ \ \ \ $DOMAIN web;" "$JITSI_MEET_PROXY"
sed -i "/server {/i \ \ \ \ \ \ $NC_DOMAIN web;" "$JITSI_MEET_PROXY"
sed -i "/server {/i \ \ }" "$JITSI_MEET_PROXY"
else
echo "$NC_DOMAIN seems to be on place, skipping..."
fi
fi
restart_services
########################################################################
# Brandless mode #
########################################################################
if [ "$ENABLE_BLESSM" = "on" ]; then
bash "$PWD"/jm-bm.sh
fi
printwc "${Blue}" "Script completed \o/!\n"