diff --git a/install/OneClickInstall/docspace-install.sh b/install/OneClickInstall/docspace-install.sh index ea5bc008b16..f021db8c44e 100644 --- a/install/OneClickInstall/docspace-install.sh +++ b/install/OneClickInstall/docspace-install.sh @@ -148,7 +148,7 @@ if [ -z "$DOCKER" ]; then read_installation_method fi -if [ -z $GIT_BRANCH ]; then +if [ -z "$GIT_BRANCH" ]; then DOWNLOAD_URL_PREFIX="https://download.${product_sysname}.com/${product}" else DOWNLOAD_URL_PREFIX="https://raw.githubusercontent.com/${product_sysname^^}/${product}-buildtools/${GIT_BRANCH}/install/OneClickInstall" @@ -156,27 +156,27 @@ fi if [ "$DOCKER" == "true" ]; then if [ "$LOCAL_SCRIPTS" == "true" ]; then - bash install-Docker.sh ${PARAMETERS} || EXIT_CODE=$? + bash install-Docker.sh "${PARAMETERS}" || EXIT_CODE=$? else - curl -s -O ${DOWNLOAD_URL_PREFIX}/install-Docker.sh - bash install-Docker.sh ${PARAMETERS} || EXIT_CODE=$? + curl -s -O "${DOWNLOAD_URL_PREFIX}"/install-Docker.sh + bash install-Docker.sh "${PARAMETERS}" || EXIT_CODE=$? rm install-Docker.sh fi else if [ -f /etc/redhat-release ] ; then if [ "$LOCAL_SCRIPTS" == "true" ]; then - bash install-RedHat.sh ${PARAMETERS} || EXIT_CODE=$? + bash install-RedHat.sh "${PARAMETERS}" || EXIT_CODE=$? else - curl -s -O ${DOWNLOAD_URL_PREFIX}/install-RedHat.sh - bash install-RedHat.sh ${PARAMETERS} || EXIT_CODE=$? + curl -s -O "${DOWNLOAD_URL_PREFIX}"/install-RedHat.sh + bash install-RedHat.sh "${PARAMETERS}" || EXIT_CODE=$? rm install-RedHat.sh fi elif [ -f /etc/debian_version ] ; then if [ "$LOCAL_SCRIPTS" == "true" ]; then - bash install-Debian.sh ${PARAMETERS} || EXIT_CODE=$? + bash install-Debian.sh "${PARAMETERS}" || EXIT_CODE=$? else - curl -s -O ${DOWNLOAD_URL_PREFIX}/install-Debian.sh - bash install-Debian.sh ${PARAMETERS} || EXIT_CODE=$? + curl -s -O "${DOWNLOAD_URL_PREFIX}"/install-Debian.sh + bash install-Debian.sh "${PARAMETERS}" || EXIT_CODE=$? rm install-Debian.sh fi else diff --git a/install/OneClickInstall/install-Debian.sh b/install/OneClickInstall/install-Debian.sh index 228f3c63d67..fd6cc54a903 100644 --- a/install/OneClickInstall/install-Debian.sh +++ b/install/OneClickInstall/install-Debian.sh @@ -162,7 +162,7 @@ if [ "${UNINSTALL}" == "true" ]; then if [ "${LOCAL_SCRIPTS}" == "true" ]; then source install-Debian/uninstall.sh else - source <(curl -fsSL ${DOWNLOAD_URL_PREFIX}/uninstall.sh) + source <(curl -fsSL "${DOWNLOAD_URL_PREFIX}"/uninstall.sh) fi exit 0 fi @@ -174,7 +174,7 @@ else fi # add onlyoffice repo -mkdir -p -m 700 $HOME/.gnupg +mkdir -p -m 700 "$HOME"/.gnupg echo "deb [signed-by=/usr/share/keyrings/onlyoffice.gpg] http://download.onlyoffice.com/repo/debian squeeze main" | tee /etc/apt/sources.list.d/onlyoffice.list curl -fsSL https://download.onlyoffice.com/GPG-KEY-ONLYOFFICE | gpg --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/onlyoffice.gpg --import chmod 644 /usr/share/keyrings/onlyoffice.gpg @@ -189,8 +189,8 @@ if [ "${LOCAL_SCRIPTS}" == "true" ]; then source install-Debian/install-preq.sh source install-Debian/install-app.sh else - source <(curl ${DOWNLOAD_URL_PREFIX}/tools.sh) - source <(curl ${DOWNLOAD_URL_PREFIX}/check-ports.sh) - source <(curl ${DOWNLOAD_URL_PREFIX}/install-preq.sh) - source <(curl ${DOWNLOAD_URL_PREFIX}/install-app.sh) + source <(curl "${DOWNLOAD_URL_PREFIX}"/tools.sh) + source <(curl "${DOWNLOAD_URL_PREFIX}"/check-ports.sh) + source <(curl "${DOWNLOAD_URL_PREFIX}"/install-preq.sh) + source <(curl "${DOWNLOAD_URL_PREFIX}"/install-app.sh) fi diff --git a/install/OneClickInstall/install-Debian/install-app.sh b/install/OneClickInstall/install-Debian/install-app.sh index cbf6f503939..bc117aeb994 100644 --- a/install/OneClickInstall/install-Debian/install-app.sh +++ b/install/OneClickInstall/install-Debian/install-app.sh @@ -18,14 +18,14 @@ case "${INSTALLATION_TYPE}" in esac if [ "$UPDATE" = "true" ] && [ "$DOCUMENT_SERVER_INSTALLED" = "true" ]; then - ds_pkg_installed_name=$(dpkg -l | grep ${package_sysname}-documentserver | tail -n1 | awk '{print $2}') + ds_pkg_installed_name=$(dpkg -l | grep "${package_sysname}"-documentserver | tail -n1 | awk '{print $2}') if [ -n "${ds_pkg_installed_name}" ] && [ "${ds_pkg_installed_name}" != "${ds_pkg_name}" ]; then - debconf-get-selections | grep ^${ds_pkg_installed_name} | sed s/${ds_pkg_installed_name}/${ds_pkg_name}/g | debconf-set-selections - DEBIAN_FRONTEND=noninteractive apt-get purge -yq ${ds_pkg_installed_name} - apt-get install -yq ${ds_pkg_name} + debconf-get-selections | grep ^"${ds_pkg_installed_name}" | sed s/"${ds_pkg_installed_name}"/"${ds_pkg_name}"/g | debconf-set-selections + DEBIAN_FRONTEND=noninteractive apt-get purge -yq "${ds_pkg_installed_name}" + apt-get install -yq "${ds_pkg_name}" RECONFIGURE_PRODUCT="true" else - apt-get install -y --only-upgrade ${ds_pkg_name} + apt-get install -y --only-upgrade "${ds_pkg_name}" fi fi @@ -41,20 +41,20 @@ if [ "$DOCUMENT_SERVER_INSTALLED" = "false" ]; then DS_JWT_SECRET=${DS_JWT_SECRET:-$(cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 32)} DS_JWT_HEADER=${DS_JWT_HEADER:-AuthorizationJwt} - if ! su - postgres -s /bin/bash -c "psql -lqt" | cut -d \| -f 1 | grep -q ${DS_DB_NAME}; then + if ! su - postgres -s /bin/bash -c "psql -lqt" | cut -d \| -f 1 | grep -q "${DS_DB_NAME}"; then su - postgres -s /bin/bash -c "psql -c \"CREATE USER ${DS_DB_USER} WITH password '${DS_DB_PWD}';\"" su - postgres -s /bin/bash -c "psql -c \"CREATE DATABASE ${DS_DB_NAME} OWNER ${DS_DB_USER};\"" fi - echo ${package_sysname}-documentserver $DS_COMMON_NAME/ds-port select $DS_PORT | sudo debconf-set-selections - echo ${package_sysname}-documentserver $DS_COMMON_NAME/db-pwd select $DS_DB_PWD | sudo debconf-set-selections - echo ${package_sysname}-documentserver $DS_COMMON_NAME/db-user select $DS_DB_USER | sudo debconf-set-selections - echo ${package_sysname}-documentserver $DS_COMMON_NAME/db-name select $DS_DB_NAME | sudo debconf-set-selections - echo ${package_sysname}-documentserver $DS_COMMON_NAME/jwt-enabled select ${DS_JWT_ENABLED} | sudo debconf-set-selections - echo ${package_sysname}-documentserver $DS_COMMON_NAME/jwt-secret select ${DS_JWT_SECRET} | sudo debconf-set-selections - echo ${package_sysname}-documentserver $DS_COMMON_NAME/jwt-header select ${DS_JWT_HEADER} | sudo debconf-set-selections + echo "${package_sysname}"-documentserver "$DS_COMMON_NAME"/ds-port select "$DS_PORT" | sudo debconf-set-selections + echo "${package_sysname}"-documentserver "$DS_COMMON_NAME"/db-pwd select "$DS_DB_PWD" | sudo debconf-set-selections + echo "${package_sysname}"-documentserver "$DS_COMMON_NAME"/db-user select "$DS_DB_USER" | sudo debconf-set-selections + echo "${package_sysname}"-documentserver "$DS_COMMON_NAME"/db-name select "$DS_DB_NAME" | sudo debconf-set-selections + echo "${package_sysname}"-documentserver "$DS_COMMON_NAME"/jwt-enabled select "${DS_JWT_ENABLED}" | sudo debconf-set-selections + echo "${package_sysname}"-documentserver "$DS_COMMON_NAME"/jwt-secret select "${DS_JWT_SECRET}" | sudo debconf-set-selections + echo "${package_sysname}"-documentserver "$DS_COMMON_NAME"/jwt-header select "${DS_JWT_HEADER}" | sudo debconf-set-selections - apt-get install -yq ${ds_pkg_name} + apt-get install -yq "${ds_pkg_name}" fi if [ "$MAKESWAP" == "true" ]; then @@ -62,19 +62,19 @@ if [ "$MAKESWAP" == "true" ]; then fi if [ "$PRODUCT_INSTALLED" = "false" ]; then - echo ${product} ${product}/db-pwd select $MYSQL_SERVER_PASS | sudo debconf-set-selections - echo ${product} ${product}/db-user select $MYSQL_SERVER_USER | sudo debconf-set-selections - echo ${product} ${product}/db-name select $MYSQL_SERVER_DB_NAME | sudo debconf-set-selections + echo "${product}" "${product}"/db-pwd select "$MYSQL_SERVER_PASS" | sudo debconf-set-selections + echo "${product}" "${product}"/db-user select "$MYSQL_SERVER_USER" | sudo debconf-set-selections + echo "${product}" "${product}"/db-name select "$MYSQL_SERVER_DB_NAME" | sudo debconf-set-selections - apt-get install -y ${product} || true #Fix error 'Failed to fetch' - apt-get install -y ${product} + apt-get install -y "${product}" || true #Fix error 'Failed to fetch' + apt-get install -y "${product}" elif [ "$UPDATE" = "true" ] && [ "$PRODUCT_INSTALLED" = "true" ]; then - CURRENT_VERSION=$(dpkg-query -W -f='${Version}' ${product} 2>/dev/null) - AVAILABLE_VERSIONS=$(apt show ${product} 2>/dev/null | grep -E '^Version:' | awk '{print $2}') + CURRENT_VERSION=$(dpkg-query -W -f='${Version}' "${product}" 2>/dev/null) + AVAILABLE_VERSIONS=$(apt show "${product}" 2>/dev/null | grep -E '^Version:' | awk '{print $2}') if [[ "$AVAILABLE_VERSIONS" != *"$CURRENT_VERSION"* ]]; then - apt-get install -o DPkg::options::="--force-confnew" -y --only-upgrade ${product} opensearch=${ELASTIC_VERSION} + apt-get install -o DPkg::options::="--force-confnew" -y --only-upgrade "${product}" opensearch="${ELASTIC_VERSION}" elif [ "${RECONFIGURE_PRODUCT}" = "true" ]; then - DEBIAN_FRONTEND=noninteractive dpkg-reconfigure ${product} + DEBIAN_FRONTEND=noninteractive dpkg-reconfigure "${product}" fi fi diff --git a/install/OneClickInstall/install-Debian/install-preq.sh b/install/OneClickInstall/install-Debian/install-preq.sh index 8c76e8f6d0c..efa6346a840 100644 --- a/install/OneClickInstall/install-Debian/install-preq.sh +++ b/install/OneClickInstall/install-Debian/install-preq.sh @@ -40,7 +40,7 @@ ELASTIC_VERSION="2.18.0" export OPENSEARCH_INITIAL_ADMIN_PASSWORD="$(echo "${package_sysname}!A1")" #add opensearch dashboards repo -if [ ${INSTALL_FLUENT_BIT} == "true" ]; then +if [ "${INSTALL_FLUENT_BIT}" == "true" ]; then curl -o- https://artifacts.opensearch.org/publickeys/opensearch.pgp | gpg --dearmor --batch --yes -o /usr/share/keyrings/opensearch-keyring echo "deb [signed-by=/usr/share/keyrings/opensearch-keyring] https://artifacts.opensearch.org/releases/bundle/opensearch-dashboards/2.x/apt stable main" > /etc/apt/sources.list.d/opensearch-dashboards-2.x.list DASHBOARDS_VERSION="2.18.0" @@ -54,7 +54,7 @@ curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - if [ "$DIST" = "ubuntu" ]; then add-apt-repository -y ppa:dotnet/backports elif [ "$DIST" = "debian" ]; then - curl https://packages.microsoft.com/config/$DIST/$REV/packages-microsoft-prod.deb -O + curl https://packages.microsoft.com/config/"$DIST"/"$REV"/packages-microsoft-prod.deb -O echo -e "Package: *\nPin: origin \"packages.microsoft.com\"\nPin-Priority: 1002" | tee /etc/apt/preferences.d/99microsoft-prod.pref dpkg -i packages-microsoft-prod.deb && rm packages-microsoft-prod.deb fi @@ -69,23 +69,23 @@ if ! dpkg -l | grep -q "mysql-server"; then MYSQL_SERVER_PASS=${MYSQL_SERVER_PASS:-"$(cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 12)"} # setup mysql 8.4 package - curl -OL http://repo.mysql.com/${MYSQL_PACKAGE_NAME} + curl -OL http://repo.mysql.com/"${MYSQL_PACKAGE_NAME}" echo "mysql-apt-config mysql-apt-config/repo-codename select $DISTRIB_CODENAME" | debconf-set-selections echo "mysql-apt-config mysql-apt-config/repo-distro select $DIST" | debconf-set-selections echo "mysql-apt-config mysql-apt-config/select-server select mysql-8.4-lts" | debconf-set-selections - DEBIAN_FRONTEND=noninteractive dpkg -i ${MYSQL_PACKAGE_NAME} - rm -f ${MYSQL_PACKAGE_NAME} + DEBIAN_FRONTEND=noninteractive dpkg -i "${MYSQL_PACKAGE_NAME}" + rm -f "${MYSQL_PACKAGE_NAME}" - echo mysql-community-server mysql-community-server/root-pass password ${MYSQL_SERVER_PASS} | debconf-set-selections - echo mysql-community-server mysql-community-server/re-root-pass password ${MYSQL_SERVER_PASS} | debconf-set-selections + echo mysql-community-server mysql-community-server/root-pass password "${MYSQL_SERVER_PASS}" | debconf-set-selections + echo mysql-community-server mysql-community-server/re-root-pass password "${MYSQL_SERVER_PASS}" | debconf-set-selections echo mysql-community-server mysql-server/default-auth-override select "Use Strong Password Encryption (RECOMMENDED)" | debconf-set-selections - echo mysql-server mysql-server/root_password password ${MYSQL_SERVER_PASS} | debconf-set-selections - echo mysql-server mysql-server/root_password_again password ${MYSQL_SERVER_PASS} | debconf-set-selections + echo mysql-server mysql-server/root_password password "${MYSQL_SERVER_PASS}" | debconf-set-selections + echo mysql-server mysql-server/root_password_again password "${MYSQL_SERVER_PASS}" | debconf-set-selections elif dpkg -l | grep -q "mysql-apt-config" && [ "$(apt-cache policy mysql-apt-config | awk 'NR==2{print $2}')" != "${MYSQL_REPO_VERSION}" ]; then curl -OL http://repo.mysql.com/${MYSQL_PACKAGE_NAME} - DEBIAN_FRONTEND=noninteractive dpkg -i ${MYSQL_PACKAGE_NAME} - rm -f ${MYSQL_PACKAGE_NAME} + DEBIAN_FRONTEND=noninteractive dpkg -i "${MYSQL_PACKAGE_NAME}" + rm -f "${MYSQL_PACKAGE_NAME}" fi # add redis repo --- temporary fix for complete installation on Ubuntu 24.04. REDIS_DIST_CODENAME change to DISTRIB_CODENAME @@ -142,12 +142,12 @@ apt-get install -o DPkg::options::="--force-confnew" -yq \ JAVA_PATH=$(find /usr/lib/jvm/ -name "java" -path "*temurin-${JAVA_VERSION}*" | head -1) update-alternatives --install /usr/bin/java java "$JAVA_PATH" 100 && update-alternatives --set java "$JAVA_PATH" -if [ ${INSTALL_FLUENT_BIT} == "true" ]; then +if [ "${INSTALL_FLUENT_BIT}" == "true" ]; then [[ "$DISTRIB_CODENAME" =~ noble ]] && FLUENTBIT_DIST_CODENAME="jammy" || FLUENTBIT_DIST_CODENAME="${DISTRIB_CODENAME}" curl https://packages.fluentbit.io/fluentbit.key | gpg --dearmor > /usr/share/keyrings/fluentbit-keyring.gpg echo "deb [signed-by=/usr/share/keyrings/fluentbit-keyring.gpg] https://packages.fluentbit.io/$DIST/$FLUENTBIT_DIST_CODENAME $FLUENTBIT_DIST_CODENAME main" | tee /etc/apt/sources.list.d/fluent-bit.list apt update - apt-get install -yq opensearch-dashboards=${DASHBOARDS_VERSION} fluent-bit + apt-get install -yq opensearch-dashboards="${DASHBOARDS_VERSION}" fluent-bit fi # disable apparmor for mysql diff --git a/install/OneClickInstall/install-Debian/tools.sh b/install/OneClickInstall/install-Debian/tools.sh index 5ca82cfc945..23698158f0f 100644 --- a/install/OneClickInstall/install-Debian/tools.sh +++ b/install/OneClickInstall/install-Debian/tools.sh @@ -9,15 +9,15 @@ make_swap () { AVAILABLE_DISK_SPACE=$(df -m / | tail -1 | awk '{ print $4 }') TOTAL_MEMORY=$(free --mega | grep -oP '\d+' | head -n 1) - EXIST=$(swapon -s | awk '{ print $1 }' | { grep -x ${SWAPFILE} || true; }) + EXIST=$(swapon -s | awk '{ print $1 }' | { grep -x "${SWAPFILE}" || true; }) - if [[ -z $EXIST ]] && [ ${TOTAL_MEMORY} -lt ${MEMORY_REQUIREMENTS} ] && [ ${AVAILABLE_DISK_SPACE} -gt ${DISK_REQUIREMENTS} ]; then + if [[ -z $EXIST ]] && [ "${TOTAL_MEMORY}" -lt ${MEMORY_REQUIREMENTS} ] && [ "${AVAILABLE_DISK_SPACE}" -gt ${DISK_REQUIREMENTS} ]; then touch "${SWAPFILE}" [[ "$(df -T / | awk 'NR==2{print $2}')" = "btrfs" ]] && chattr +C "${SWAPFILE}" - fallocate -l 6G ${SWAPFILE} - chmod 600 ${SWAPFILE} - mkswap ${SWAPFILE} - swapon ${SWAPFILE} + fallocate -l 6G "${SWAPFILE}" + chmod 600 "${SWAPFILE}" + mkswap "${SWAPFILE}" + swapon "${SWAPFILE}" echo "$SWAPFILE none swap sw 0 0" >> /etc/fstab fi } @@ -54,19 +54,19 @@ check_hardware () { AVAILABLE_DISK_SPACE=$(df -m / | tail -1 | awk '{ print $4 }') - if [ ${AVAILABLE_DISK_SPACE} -lt ${DISK_REQUIREMENTS} ]; then + if [ "${AVAILABLE_DISK_SPACE}" -lt ${DISK_REQUIREMENTS} ]; then echo "Minimal requirements are not met: need at least $DISK_REQUIREMENTS MB of free HDD space" exit 1 fi TOTAL_MEMORY=$(free --mega | grep -oP '\d+' | head -n 1) - if [ ${TOTAL_MEMORY} -lt ${MEMORY_REQUIREMENTS} ]; then + if [ "${TOTAL_MEMORY}" -lt ${MEMORY_REQUIREMENTS} ]; then echo "Minimal requirements are not met: need at least $MEMORY_REQUIREMENTS MB of RAM" exit 1 fi - CPU_CORES_NUMBER=$(cat /proc/cpuinfo | grep processor | wc -l) + CPU_CORES_NUMBER=$(grep -c ^processor /proc/cpuinfo) if [ ${CPU_CORES_NUMBER} -lt ${CORE_REQUIREMENTS} ]; then echo "The system does not meet the minimal hardware requirements. CPU with at least $CORE_REQUIREMENTS cores is required" diff --git a/install/OneClickInstall/install-Docker.sh b/install/OneClickInstall/install-Docker.sh index dfa326af2f3..9cea2639623 100644 --- a/install/OneClickInstall/install-Docker.sh +++ b/install/OneClickInstall/install-Docker.sh @@ -765,7 +765,7 @@ check_hardware () { exit 1 fi - CPU_CORES_NUMBER=$(cat /proc/cpuinfo | grep processor | wc -l) + CPU_CORES_NUMBER=$(grep -c ^processor /proc/cpuinfo) if [ ${CPU_CORES_NUMBER} -lt ${CORE_REQUIREMENTS} ]; then echo "The system does not meet the minimal hardware requirements. CPU with at least $CORE_REQUIREMENTS cores is required" diff --git a/install/OneClickInstall/install-RedHat.sh b/install/OneClickInstall/install-RedHat.sh index 75f8552e735..56c851ba32c 100644 --- a/install/OneClickInstall/install-RedHat.sh +++ b/install/OneClickInstall/install-RedHat.sh @@ -158,7 +158,7 @@ if [ "${UNINSTALL}" == "true" ]; then if [ "${LOCAL_SCRIPTS}" == "true" ]; then source install-RedHat/uninstall.sh else - source <(curl -fsSL ${DOWNLOAD_URL_PREFIX}/uninstall.sh) + source <(curl -fsSL "${DOWNLOAD_URL_PREFIX}"/uninstall.sh) fi exit 0 fi @@ -179,9 +179,9 @@ if [ "$LOCAL_SCRIPTS" = "true" ]; then source install-RedHat/install-preq.sh source install-RedHat/install-app.sh else - source <(curl ${DOWNLOAD_URL_PREFIX}/tools.sh) - source <(curl ${DOWNLOAD_URL_PREFIX}/bootstrap.sh) - source <(curl ${DOWNLOAD_URL_PREFIX}/check-ports.sh) - source <(curl ${DOWNLOAD_URL_PREFIX}/install-preq.sh) - source <(curl ${DOWNLOAD_URL_PREFIX}/install-app.sh) + source <(curl "${DOWNLOAD_URL_PREFIX}"/tools.sh) + source <(curl "${DOWNLOAD_URL_PREFIX}"/bootstrap.sh) + source <(curl "${DOWNLOAD_URL_PREFIX}"/check-ports.sh) + source <(curl "${DOWNLOAD_URL_PREFIX}"/install-preq.sh) + source <(curl "${DOWNLOAD_URL_PREFIX}"/install-app.sh) fi diff --git a/install/OneClickInstall/install-RedHat/check-ports.sh b/install/OneClickInstall/install-RedHat/check-ports.sh index 84995652f6b..32933a10750 100644 --- a/install/OneClickInstall/install-RedHat/check-ports.sh +++ b/install/OneClickInstall/install-RedHat/check-ports.sh @@ -10,7 +10,7 @@ cat</dev/null 2>&1; then - if [ -z $MYSQL_TEMPORARY_ROOT_PASS ]; then + if [ -z "$MYSQL_TEMPORARY_ROOT_PASS" ]; then MYSQL="mysql --connect-expired-password -u$MYSQL_SERVER_USER -D mysql" else MYSQL="mysql --connect-expired-password -u$MYSQL_SERVER_USER -p${MYSQL_TEMPORARY_ROOT_PASS} -D mysql" - MYSQL_ROOT_PASS=$(echo $MYSQL_TEMPORARY_ROOT_PASS | sed -e 's/;/%/g' -e 's/=/%/g') + MYSQL_ROOT_PASS=$(echo "$MYSQL_TEMPORARY_ROOT_PASS" | sed -e 's/;/%/g' -e 's/=/%/g') fi MYSQL_AUTHENTICATION_PLUGIN=$($MYSQL -e "SHOW VARIABLES LIKE 'default_authentication_plugin';" -s | awk '{print $2}') @@ -85,7 +85,7 @@ if [ "$DOCUMENT_SERVER_INSTALLED" = "false" ]; then declare -x JWT_SECRET=${JWT_SECRET:-$(cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 32)} declare -x JWT_HEADER=${JWT_HEADER:-AuthorizationJwt} - if ! su - postgres -s /bin/bash -c "psql -lqt" | cut -d \| -f 1 | grep -q ${DS_DB_NAME}; then + if ! su - postgres -s /bin/bash -c "psql -lqt" | cut -d \| -f 1 | grep -q "${DS_DB_NAME}"; then su - postgres -s /bin/bash -c "psql -c \"CREATE USER ${DS_DB_USER} WITH password '${DS_DB_PWD}';\"" su - postgres -s /bin/bash -c "psql -c \"CREATE DATABASE ${DS_DB_NAME} OWNER ${DS_DB_USER};\"" fi @@ -140,16 +140,16 @@ fi { ${package_manager} check-update ${product}; PRODUCT_CHECK_UPDATE=$?; } || true if [ "$PRODUCT_INSTALLED" = "false" ]; then ${package_manager} install -y ${product} --best --allowerasing $TESTING_REPO - ${product}-configuration \ + "${product}"-configuration \ -mysqlh "${MYSQL_SERVER_HOST}" \ -mysqld "${MYSQL_SERVER_DB_NAME}" \ -mysqlu "${MYSQL_SERVER_USER}" \ -mysqlp "${MYSQL_ROOT_PASS}" elif [[ "${PRODUCT_CHECK_UPDATE}" -eq "${UPDATE_AVAILABLE_CODE}" || "${RECONFIGURE_PRODUCT}" = "true" ]]; then - ENVIRONMENT=$(grep -oP 'ENVIRONMENT=\K.*' /etc/${package_sysname}/${product}/systemd.env || grep -oP 'ENVIRONMENT=\K.*' /usr/lib/systemd/system/${product}-api.service) - CONNECTION_STRING=$(json -f /etc/${package_sysname}/${product}/appsettings.$ENVIRONMENT.json ConnectionStrings.default.connectionString) - ${package_manager} -y update ${product} --best --allowerasing $TESTING_REPO - ${product}-configuration \ + ENVIRONMENT=$(grep -oP 'ENVIRONMENT=\K.*' /etc/"${package_sysname}"/"${product}"/systemd.env || grep -oP 'ENVIRONMENT=\K.*' /usr/lib/systemd/system/"${product}"-api.service) + CONNECTION_STRING=$(json -f /etc/"${package_sysname}"/"${product}"/appsettings."$ENVIRONMENT".json ConnectionStrings.default.connectionString) + ${package_manager} -y update "${product}" --best --allowerasing $TESTING_REPO + "${product}"-configuration \ -mysqlh "$(grep -oP 'Server=\K[^;]*' <<< "${CONNECTION_STRING}")" \ -mysqld "$(grep -oP 'Database=\K[^;]*' <<< "${CONNECTION_STRING}")" \ -mysqlu "$(grep -oP 'User ID=\K[^;]*' <<< "${CONNECTION_STRING}")" \ diff --git a/install/OneClickInstall/install-RedHat/install-preq.sh b/install/OneClickInstall/install-RedHat/install-preq.sh index a9ca4be90d1..58f6fd2e581 100644 --- a/install/OneClickInstall/install-RedHat/install-preq.sh +++ b/install/OneClickInstall/install-RedHat/install-preq.sh @@ -16,10 +16,10 @@ ${package_manager} clean all ${package_manager} -y install yum-utils { yum check-update postgresql; PSQLExitCode=$?; } || true #Checking for postgresql update -{ yum check-update $DIST*-release; exitCode=$?; } || true #Checking for distribution update +{ yum check-update "$DIST"*-release; exitCode=$?; } || true #Checking for distribution update if rpm -qa | grep mariadb.*config >/dev/null 2>&1; then - echo $RES_MARIADB && exit 0 + echo "$RES_MARIADB" && exit 0 fi #Add repository EPEL @@ -39,7 +39,7 @@ curl -fsSL https://rpm.nodesource.com/setup_${NODE_VERSION}.x | sed '/update -y/ #add mysql repo dnf remove -y @mysql && dnf module -y reset mysql && dnf module -y disable mysql MYSQL_REPO_VERSION="$(curl https://repo.mysql.com | grep -oP "mysql84-community-release-${MYSQL_DISTR_NAME}${REV}-\K.*" | grep -o '^[^.]*' | sort | tail -n1)" -yum install -y https://repo.mysql.com/mysql84-community-release-${MYSQL_DISTR_NAME}${REV}-${MYSQL_REPO_VERSION}.noarch.rpm || true +yum install -y https://repo.mysql.com/mysql84-community-release-"${MYSQL_DISTR_NAME}""${REV}"-"${MYSQL_REPO_VERSION}".noarch.rpm || true if ! rpm -q mysql-community-server; then MYSQL_FIRST_TIME_INSTALL="true" @@ -95,9 +95,9 @@ JAVA_PATH=$(find /usr/lib/jvm/ -name "java" -path "*java-${JAVA_VERSION}*" | hea alternatives --install /usr/bin/java java "$JAVA_PATH" 100 && alternatives --set java "$JAVA_PATH" #add repo, install fluent-bit -if [ ${INSTALL_FLUENT_BIT} == "true" ]; then +if [ "${INSTALL_FLUENT_BIT}" == "true" ]; then [ "$DIST" != "fedora" ] && curl https://raw.githubusercontent.com/fluent/fluent-bit/master/install.sh | bash || yum -y install fluent-bit - ${package_manager} -y install opensearch-dashboards-${DASHBOARDS_VERSION} --enablerepo=opensearch-dashboards-2.x + ${package_manager} -y install opensearch-dashboards-"${DASHBOARDS_VERSION}" --enablerepo=opensearch-dashboards-2.x fi if [[ $PSQLExitCode -eq $UPDATE_AVAILABLE_CODE ]]; then diff --git a/install/OneClickInstall/install-RedHat/tools.sh b/install/OneClickInstall/install-RedHat/tools.sh index dae13d5294c..6d27ae15ce9 100644 --- a/install/OneClickInstall/install-RedHat/tools.sh +++ b/install/OneClickInstall/install-RedHat/tools.sh @@ -11,7 +11,7 @@ function make_swap () { local TOTAL_MEMORY=$(free --mega | grep -oP '\d+' | head -n 1) local EXIST=$(swapon -s | awk '{ print $1 }' | { grep -x ${SWAPFILE} || true; }) - if [[ -z $EXIST ]] && [ ${TOTAL_MEMORY} -lt ${MEMORY_REQUIREMENTS} ] && [ ${AVAILABLE_DISK_SPACE} -gt ${DISK_REQUIREMENTS} ]; then + if [[ -z $EXIST ]] && [ "${TOTAL_MEMORY}" -lt ${MEMORY_REQUIREMENTS} ] && [ "${AVAILABLE_DISK_SPACE}" -gt ${DISK_REQUIREMENTS} ]; then touch "$SWAPFILE" [[ "$(df -T / | awk 'NR==2{print $2}')" = "btrfs" ]] && chattr +C "$SWAPFILE" fallocate -l 6G "$SWAPFILE" @@ -29,21 +29,21 @@ check_hardware () { AVAILABLE_DISK_SPACE=$(df -m / | tail -1 | awk '{ print $4 }') - if [ ${AVAILABLE_DISK_SPACE} -lt ${DISK_REQUIREMENTS} ]; then + if [ "${AVAILABLE_DISK_SPACE}" -lt ${DISK_REQUIREMENTS} ]; then echo "Minimal requirements are not met: need at least $DISK_REQUIREMENTS MB of free HDD space" exit 1 fi TOTAL_MEMORY=$(free --mega | grep -oP '\d+' | head -n 1) - if [ ${TOTAL_MEMORY} -lt ${MEMORY_REQUIREMENTS} ]; then + if [ "${TOTAL_MEMORY}" -lt ${MEMORY_REQUIREMENTS} ]; then echo "Minimal requirements are not met: need at least $MEMORY_REQUIREMENTS MB of RAM" exit 1 fi - CPU_CORES_NUMBER=$(cat /proc/cpuinfo | grep processor | wc -l) + CPU_CORES_NUMBER=$(grep -c ^processor /proc/cpuinfo) - if [ ${CPU_CORES_NUMBER} -lt ${CORE_REQUIREMENTS} ]; then + if [ "${CPU_CORES_NUMBER}" -lt ${CORE_REQUIREMENTS} ]; then echo "The system does not meet the minimal hardware requirements. CPU with at least $CORE_REQUIREMENTS cores is required" exit 1 fi diff --git a/tests/vagrant/install.sh b/tests/vagrant/install.sh index c61799a1cb0..41c90489be3 100644 --- a/tests/vagrant/install.sh +++ b/tests/vagrant/install.sh @@ -63,7 +63,7 @@ function check_hw() { # Outputs: None ############################################################################################# function add-repo-deb() { - mkdir -p $HOME/.gnupg && chmod 700 $HOME/.gnupg + mkdir -p "$HOME"/.gnupg && chmod 700 "$HOME"/.gnupg echo "deb [signed-by=/usr/share/keyrings/onlyoffice.gpg] https://nexus.onlyoffice.com/repository/4testing-debian stable main" | \ sudo tee /etc/apt/sources.list.d/onlyoffice4testing.list curl -fsSL https://download.onlyoffice.com/GPG-KEY-ONLYOFFICE | \ @@ -231,7 +231,7 @@ function install_docspace() { function healthcheck_systemd_services() { for service in "${SERVICES_SYSTEMD[@]}"; do [[ "$service" == *migration* ]] && continue; - if systemctl is-active --quiet ${service}; then + if systemctl is-active --quiet "${service}"; then echo "${COLOR_GREEN}☑ OK: Service ${service} is running${COLOR_RESET}" else echo "${COLOR_RED}⚠ FAILED: Service ${service} is not running${COLOR_RESET}" @@ -277,7 +277,7 @@ function services_logs() { for service in "${SERVICES_SYSTEMD[@]}"; do echo $LINE_SEPARATOR && echo "${COLOR_GREEN}Check logs for systemd service: $service${COLOR_RESET}" && echo $LINE_SEPARATOR - journalctl -u $service -n 30 || true + journalctl -u "$service" -n 30 || true done local DOCSPACE_LOGS_DIR="/var/log/onlyoffice/docspace"