From ccec4a0ab6702e3bd2a2d9f223e05bd2bdadb117 Mon Sep 17 00:00:00 2001 From: Luis Guzman Date: Wed, 23 Aug 2023 00:51:24 -0600 Subject: [PATCH] v7.2 (#100) * jitsi-updater.sh: fix check chrome driver version. * jra_nextcloud.sh: organize functions, add apt checks, higher password length and small fixes. * quick_jibri_installer.sh,jitsi-updater.sh: update chromedriver 115+ version download. * quick_jibri_installer.sh: update nodejs to a stable release. * quick_jibri_installer.sh: fix empty variable usage. * quick_jibri_installer.sh: rearrange chromedriver variables. --- jitsi-updater.sh | 20 ++++++---- jra_nextcloud.sh | 79 +++++++++++++++++++++------------------- quick_jibri_installer.sh | 14 ++++--- 3 files changed, 63 insertions(+), 50 deletions(-) diff --git a/jitsi-updater.sh b/jitsi-updater.sh index 5dd9f83..1339f16 100644 --- a/jitsi-updater.sh +++ b/jitsi-updater.sh @@ -40,7 +40,10 @@ 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)" +G_CHROME=$(apt-cache madison google-chrome-stable|awk '{print$3}'|cut -d. -f1-3) +CHROMELAB_URL="https://googlechromelabs.github.io/chrome-for-testing" +CHD_LTST_DWNL=$(curl -s $CHROMELAB_URL/known-good-versions-with-downloads.json | jq -r ".versions[].downloads.chromedriver | select(. != null) | .[].url" | grep linux64 | grep "$G_CHROME" | tail -1) +CHD_LTST=$(awk -F '/' '{print$7}' <<< "$CHD_LTST_DWNL") CHD_LTST_2D="$(cut -d "." -f 1,2 <<< "$CHD_LTST")" CHDB="$(whereis chromedriver | awk '{print$2}')" if [ -d /etc/prosody/conf.d/ ]; then @@ -66,12 +69,6 @@ read -r -a google_package < <(grep ^Package /var/lib/apt/lists/dl.google.com_*_P 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="$(awk '{printf "%.1f\n", $NF}' <<< "$CHD_VER_LOCAL")" -fi if [ -f "$apt_repo"/nodesource.list ]; then read -r -a nodejs_package < <(grep ^Package /var/lib/apt/lists/deb.nodesource.com_node*_Packages | \ sort -u | awk '{print $2}' | xargs) @@ -114,6 +111,12 @@ update_google_repo() { else echo "No Google repository found" fi + if [ -z "$CHDB" ]; then + echo "Seems no chromedriver installed" + else + CHD_VER_LOCAL="$($CHDB -v | awk '{print $2}')" + CHD_VER_2D="$(awk '{printf "%.1f\n", $NF}' <<< "$CHD_VER_LOCAL")" + fi } update_nodejs_repo() { apt-get update -o Dir::Etc::sourcelist="sources.list.d/nodesource.list" \ @@ -131,9 +134,10 @@ 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 \ + wget -q "$CHD_LTST_DWNL" \ -O /tmp/chromedriver_linux64.zip unzip -o /tmp/chromedriver_linux64.zip -d /usr/local/bin/ + mv /usr/local/bin/chromedriver-linux64/chromedriver "$CHDB" chown root:root "$CHDB" chmod 0755 "$CHDB" rm -rf /tpm/chromedriver_linux64.zip diff --git a/jra_nextcloud.sh b/jra_nextcloud.sh index bd8ff03..f379213 100644 --- a/jra_nextcloud.sh +++ b/jra_nextcloud.sh @@ -37,6 +37,10 @@ echo -e '\n by Software, IT & Networks Ltd \n' exit_if_not_installed jitsi-meet +## APT checks +apt-get update -q2 +# Manually add prerequisites. +apt-get install -y curl letsencrypt nginx DISTRO_RELEASE="$(lsb_release -sc)" DOMAIN="$(find /etc/prosody/conf.d/ -name \*.lua|awk -F'.cfg' '!/localhost/{print $1}'|xargs basename)" @@ -47,6 +51,7 @@ PHP_FPM_DIR="/etc/php/$PHPVER/fpm" PHP_INI="$PHP_FPM_DIR/php.ini" PHP_CONF="/etc/php/$PHPVER/fpm/pool.d/www.conf" NC_NGINX_SSL_PORT="$(grep "listen 44" /etc/nginx/sites-available/"$DOMAIN".conf | awk '{print$2}')" +[ -z $NC_NGINX_SSL_PORT ] && NC_NGINX_SSL_PORT="443" NC_REPO="https://download.nextcloud.com/server/releases" NCVERSION="$(curl -s -m 900 $NC_REPO/ | sed --silent 's/.*href="nextcloud-\([^"]\+\).zip.asc".*/\1/p' | sort --version-sort | tail -1)" STABLEVERSION="nextcloud-$NCVERSION" @@ -58,13 +63,13 @@ NC_DB_PASSWD="$(tr -dc "a-zA-Z0-9#_*=" < /dev/urandom | fold -w 14 | head -n1)" DIR_RECORD="$(awk -F '"' '/RECORDING/{print$2}' /home/jibri/finalize_recording.sh|awk 'NR==1{print$1}')" REDIS_CONF="/etc/redis/redis.conf" 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 + +[ -f "$JITSI_MEET_PROXY" ] && PREAD_PROXY=$(grep -nr "preread_server_name" "$JITSI_MEET_PROXY" | cut -d ":" -f1) PUBLIC_IP="$(dig +short myip.opendns.com @resolver1.opendns.com)" ISO3166_CODE=TBD NL="$(printf '\n ')" TMP_GPG_REPO="$(mktemp -d)" + add_gpg_keyring() { apt-key adv --recv-keys --keyserver keyserver.ubuntu.com "$1" apt-key export "$1" | gpg --dearmour | tee "$TMP_GPG_REPO"/"$1".gpg >/dev/null @@ -85,7 +90,34 @@ for i in $1 apt-get -y install $packages packages="" } - +exit_ifinstalled() { +if [ "$(dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed")" == "1" ]; then + echo " This instance already has $1 installed, exiting..." + echo " If you think this is an error, please report to: + -> https://github.com/switnet-ltd/quick-jibri-installer/issues " + exit +fi +} +install_ifnot() { +if [ "$(dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed")" == "1" ]; then + echo " $1 is installed, skipping..." +else + echo -e "\n---- Installing $1 ----" + apt-get -yq2 install "$1" +fi +} +add_php() { +if [ "$PHP_REPO" = "php" ]; then + echo "PHP $PHPVER already installed" + apt-get -q2 update + apt-get -yq2 dist-upgrade +else + echo "# Adding Ondrej PHP $PHPVER PPA Repository" + add_gpg_keyring E5267A6C + echo "deb [arch=amd64] http://ppa.launchpad.net/ondrej/php/ubuntu $DISTRO_RELEASE main" > /etc/apt/sources.list.d/php"$PHPVER".list + apt-get update -q2 +fi +} while [[ "$ANS_NCD" != "yes" ]] do read -p "> Please set your domain (or subdomain) here for Nextcloud: (e.g.: cloud.domain.com)$NL" -r NC_DOMAIN @@ -124,11 +156,11 @@ do echo " - This field is mandatory." fi done -while [ -z "$NC_PASS" ] || [ ${#NC_PASS} -lt 6 ] +while [ -z "$NC_PASS" ] || [ ${#NC_PASS} -lt 8 ] do read -p "Nextcloud user password: " -r NC_PASS - if [ -z "$NC_PASS" ] || [ ${#NC_PASS} -lt 6 ]; then - echo -e " - This field is mandatory. \nPlease make sure it's at least 6 characters.\n" + if [ -z "$NC_PASS" ] || [ ${#NC_PASS} -lt8 ]; then + echo -e " - This field is mandatory. \nPlease make sure it's at least 8 characters.\n" fi done #Enable HSTS @@ -169,34 +201,6 @@ else exit fi -exit_ifinstalled() { -if [ "$(dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed")" == "1" ]; then - echo " This instance already has $1 installed, exiting..." - echo " If you think this is an error, please report to: - -> https://github.com/switnet-ltd/quick-jibri-installer/issues " - exit -fi -} -install_ifnot() { -if [ "$(dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed")" == "1" ]; then - echo " $1 is installed, skipping..." -else - echo -e "\n---- Installing $1 ----" - apt-get -yq2 install "$1" -fi -} -add_php() { -if [ "$PHP_REPO" = "php" ]; then - echo "PHP $PHPVER already installed" - apt-get -q2 update - apt-get -yq2 dist-upgrade -else - echo "# Adding Ondrej PHP $PHPVER PPA Repository" - add_gpg_keyring E5267A6C - echo "deb [arch=amd64] http://ppa.launchpad.net/ondrej/php/ubuntu $DISTRO_RELEASE main" > /etc/apt/sources.list.d/php"$PHPVER".list - apt-get update -q2 -fi -} #Prevent root folder permission issues cp "$PWD"/files/jra-nc-app-ef.json /tmp @@ -206,7 +210,8 @@ exit_ifinstalled postgresql-"$PSGVER" # PostgresSQL install_ifnot postgresql-"$PSGVER" -# PHP 7.4 +# PHP 7.4 / 8.1 + add_php install_aval_package " \ imagemagick \ @@ -488,7 +493,7 @@ echo -e "\nApply custom mods...\n" sed -i "/datadirectory/a \ \ \'skeletondirectory\' => \'\'," "$NC_CONFIG" sed -i "/skeletondirectory/a \ \ \'simpleSignUpLink.shown\' => false," "$NC_CONFIG" sed -i "/simpleSignUpLink.shown/a \ \ \'knowledgebaseenabled\' => false," "$NC_CONFIG" -sed -i "s|http://localhost|http://$NC_DOMAIN|" "$NC_CONFIG" +sed -i "s|http://localhost|https://$NC_DOMAIN|" "$NC_CONFIG" echo -e "\nAdd crontab...\n" crontab -u www-data -l | { cat; echo "*/5 * * * * php -f $NC_PATH/cron.php"; } | crontab -u www-data - diff --git a/quick_jibri_installer.sh b/quick_jibri_installer.sh index e952dee..2233b76 100644 --- a/quick_jibri_installer.sh +++ b/quick_jibri_installer.sh @@ -391,7 +391,7 @@ echo " if [ "$(dpkg-query -W -f='${Status}' nodejs 2>/dev/null | grep -c "ok")" == "1" ]; then echo "Nodejs is installed, skipping..." else - curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - + curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash - apt-get install -yq2 nodejs echo "Installing nodejs esprima package..." npm install -g esprima @@ -404,9 +404,6 @@ elif [ "$(npm list -g esprima 2>/dev/null | grep -c "esprima")" == "1" ]; then echo "Good. Esprima package is already installed" fi -CHD_LTST=$(curl -sL https://chromedriver.storage.googleapis.com/LATEST_RELEASE) -GCMP_JSON="/etc/opt/chrome/policies/managed/managed_policies.json" - echo "# Installing Google Chrome / ChromeDriver" if [ "$GOOGLE_ACTIVE_REPO" = "main" ]; then echo "Google repository already set." @@ -420,13 +417,20 @@ apt-get -q2 update apt-get install -yq2 google-chrome-stable rm -rf /etc/apt/sources.list.d/dl_google_com_linux_chrome_deb.list +G_CHROME=$(apt-cache madison google-chrome-stable|awk '{print$3}'|cut -d. -f1-3) +CHROMELAB_URL="https://googlechromelabs.github.io/chrome-for-testing" +CHD_LTST_DWNL=$(curl -s $CHROMELAB_URL/known-good-versions-with-downloads.json | jq -r ".versions[].downloads.chromedriver | select(. != null) | .[].url" | grep linux64 | grep "$G_CHROME" | tail -1) +CHD_LTST=$(awk -F '/' '{print$7}' <<< "$CHD_LTST_DWNL") +GCMP_JSON="/etc/opt/chrome/policies/managed/managed_policies.json" + if [ -f /usr/local/bin/chromedriver ]; then echo "Chromedriver already installed." else echo "Installing Chromedriver" - wget -q https://chromedriver.storage.googleapis.com/"$CHD_LTST"/chromedriver_linux64.zip \ + wget -q "$CHD_LTST_DWNL" \ -O /tmp/chromedriver_linux64.zip unzip -o /tmp/chromedriver_linux64.zip -d /usr/local/bin/ + mv /usr/local/bin/chromedriver-linux64/chromedriver /usr/local/bin/chromedriver chown root:root /usr/local/bin/chromedriver chmod 0755 /usr/local/bin/chromedriver rm -rf /tmp/chromedriver_linux64.zip