Compare chromedriver version to chrome's instead of latest available.

This commit is contained in:
Luis Guzmán 2021-02-18 01:12:39 -06:00
parent 443f52aa3c
commit 55f8238506
1 changed files with 25 additions and 20 deletions

View File

@ -23,7 +23,7 @@ support="https://switnet.net/support"
apt_repo="/etc/apt/sources.list.d" apt_repo="/etc/apt/sources.list.d"
LOC_REC="TBD" LOC_REC="TBD"
ENABLE_BLESSM="TBD" ENABLE_BLESSM="TBD"
CHD_LST="$(curl -sL https://chromedriver.storage.googleapis.com/LATEST_RELEASE)" CHD_LTST="$(curl -sL https://chromedriver.storage.googleapis.com/LATEST_RELEASE)"
CHDB="$(whereis chromedriver | awk '{print$2}')" CHDB="$(whereis chromedriver | awk '{print$2}')"
DOMAIN="$(ls /etc/prosody/conf.d/ | grep -v localhost | awk -F'.cfg' '{print $1}' | awk '!NF || !seen[$0]++')" DOMAIN="$(ls /etc/prosody/conf.d/ | grep -v localhost | awk -F'.cfg' '{print $1}' | awk '!NF || !seen[$0]++')"
NC_DOMAIN="TBD" NC_DOMAIN="TBD"
@ -33,19 +33,20 @@ PREAD_PROXY=$(grep -nr "preread_server_name" $JITSI_MEET_PROXY | cut -d ":" -f1)
fi fi
INT_CONF="/usr/share/jitsi-meet/interface_config.js" INT_CONF="/usr/share/jitsi-meet/interface_config.js"
INT_CONF_ETC="/etc/jitsi/meet/$DOMAIN-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||'|paste -s -d ' ')" 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)" AVATAR="$(grep -r avatar /etc/nginx/sites-*/ 2>/dev/null)"
if [ -f $apt_repo/google-chrome.list ]; then 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 | paste -s -d ' ') 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 else
echo "Seems no Google repo installed" echo "Seems no Google repo installed"
fi fi
if [ -z $CHDB ]; then if [ -z $CHDB ]; then
echo "Seems no chromedriver installed" echo "Seems no chromedriver installed"
else else
CHD_AVB=$(chromedriver -v | awk '{print $2}') CHD_AVB=$($CHDB -v | awk '{print $2}')
fi fi
# 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"; }
check_jibri() { check_jibri() {
@ -67,21 +68,6 @@ restart_services() {
systemctl restart prosody systemctl restart prosody
} }
upgrade_cd() {
if version_gt $CHD_LST $CHD_AVB
then
echo "Upgrading ..."
wget https://chromedriver.storage.googleapis.com/$CHD_LST/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
sudo cp chromedriver $CHDB
rm -rf chromedriver chromedriver_linux64.zip
chromedriver -v
else
echo "No need to upgrade Chromedriver"
printf "Current version: ${Green} $CHD_AVB ${Color_Off}\n"
fi
}
update_jitsi_repo() { update_jitsi_repo() {
apt-get update -o Dir::Etc::sourcelist="sources.list.d/jitsi-$1.list" \ apt-get update -o Dir::Etc::sourcelist="sources.list.d/jitsi-$1.list" \
-o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
@ -97,12 +83,31 @@ update_google_repo() {
echo "No Google repository found" echo "No Google repository found"
fi fi
} }
GOOGL_VER_2D="$(/usr/bin/google-chrome --version|awk '{print$3}'|cut -d "." -f 1,2)"
upgrade_cd() {
if [ ! -z $GOOGL_VER_2D ]; then
if version_gt $GOOGL_VER_2D "$($CHD_AVB|cut -d "." -f 1,2)"
then
echo "Upgrading ..."
wget https://chromedriver.storage.googleapis.com/$CHD_LTST/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
sudo cp chromedriver $CHDB
rm -rf chromedriver chromedriver_linux64.zip
chromedriver -v
else
echo "No need to upgrade Chromedriver"
printf "Current version: ${Green} $CHD_AVB ${Color_Off}\n"
fi
else
printf "${Yellow} -> No Google Chrome versión to match, leaving untouched.${Color_Off}\n"
fi
}
check_lst_cd() { check_lst_cd() {
printf "${Purple}Checking for the latest Chromedriver${Color_Off}\n" printf "${Purple}Checking for the latest Chromedriver${Color_Off}\n"
if [ -f $CHDB ]; then if [ -f $CHDB ]; then
printf "Current installed Chromedriver: ${Yellow} $CHD_AVB ${Color_Off}\n" printf "Current installed Chromedriver: ${Yellow} $CHD_AVB ${Color_Off}\n"
printf "Latest Chromedriver version available: ${Green} $CHD_LST ${Color_Off}\n" printf "Latest Chromedriver version available: ${Green} $CHD_LTST ${Color_Off}\n"
upgrade_cd upgrade_cd
else else
printf "${Yellow} -> Seems there is no Chromedriver installed${Color_Off}\n" printf "${Yellow} -> Seems there is no Chromedriver installed${Color_Off}\n"