From 392d18e26e81577008f7451f46da89d38c0a1664 Mon Sep 17 00:00:00 2001 From: Vladimir Ischenko Date: Mon, 13 Jan 2025 08:09:53 +0000 Subject: [PATCH] Fix cosmetic issues in OCI scripts (#136) Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/DocSpace-buildtools/pulls/136 Co-authored-by: Vladimir Ischenko Co-committed-by: Vladimir Ischenko --- install/OneClickInstall/docspace-install.sh | 48 ++-- install/OneClickInstall/install-Debian.sh | 22 +- .../install-Debian/check-ports.sh | 16 +- .../install-Debian/install-app.sh | 22 +- .../install-Debian/install-preq.sh | 4 +- .../OneClickInstall/install-Debian/tools.sh | 32 +-- .../install-Debian/uninstall.sh | 3 +- install/OneClickInstall/install-Docker.sh | 235 +++++++++--------- install/OneClickInstall/install-RedHat.sh | 22 +- .../install-RedHat/bootstrap.sh | 2 +- .../install-RedHat/check-ports.sh | 16 +- .../install-RedHat/install-app.sh | 42 ++-- .../install-RedHat/install-preq.sh | 2 +- .../OneClickInstall/install-RedHat/tools.sh | 32 +-- .../install-RedHat/uninstall.sh | 3 +- tests/vagrant/install.sh | 4 +- 16 files changed, 253 insertions(+), 252 deletions(-) diff --git a/install/OneClickInstall/docspace-install.sh b/install/OneClickInstall/docspace-install.sh index b54796a3c23..ea5bc008b16 100644 --- a/install/OneClickInstall/docspace-install.sh +++ b/install/OneClickInstall/docspace-install.sh @@ -31,18 +31,18 @@ # terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode # -PARAMETERS="$PARAMETERS -it COMMUNITY"; -DOCKER=""; +PARAMETERS="$PARAMETERS -it COMMUNITY" +DOCKER="" LOCAL_SCRIPTS="false" product="docspace" -product_sysname="onlyoffice"; +product_sysname="onlyoffice" FILE_NAME="$(basename "$0")" while [ "$1" != "" ]; do case $1 in -ls | --localscripts ) if [ "$2" == "true" ] || [ "$2" == "false" ]; then - PARAMETERS="$PARAMETERS ${1}"; + PARAMETERS="$PARAMETERS ${1}" LOCAL_SCRIPTS=$2 shift fi @@ -50,19 +50,19 @@ while [ "$1" != "" ]; do -gb | --gitbranch ) if [ "$2" != "" ]; then - PARAMETERS="$PARAMETERS ${1}"; + PARAMETERS="$PARAMETERS ${1}" GIT_BRANCH=$2 shift fi ;; docker ) - DOCKER="true"; + DOCKER="true" shift && continue ;; package ) - DOCKER="false"; + DOCKER="false" shift && continue ;; @@ -70,24 +70,24 @@ while [ "$1" != "" ]; do if [ -z "$DOCKER" ]; then echo "Run 'bash $FILE_NAME docker' to install docker version of application or 'bash $FILE_NAME package' to install deb/rpm version." echo "Run 'bash $FILE_NAME docker -h' or 'bash $FILE_NAME package -h' to get more details." - exit 0; + exit 0 fi - PARAMETERS="$PARAMETERS -ht $FILE_NAME"; + PARAMETERS="$PARAMETERS -ht $FILE_NAME" ;; esac - PARAMETERS="$PARAMETERS ${1}"; + PARAMETERS="$PARAMETERS ${1}" shift done root_checking () { - if [ ! $( id -u ) -eq 0 ]; then + if [[ $EUID -ne 0 ]]; then echo "To perform this action you must be logged in with root rights" - exit 1; + exit 1 fi } command_exists () { - type "$1" &> /dev/null; + type "$1" &> /dev/null } install_curl () { @@ -100,40 +100,40 @@ install_curl () { if ! command_exists curl; then echo "command curl not found" - exit 1; + exit 1 fi } read_installation_method () { - echo "Select 'Y' to install ${product_sysname^^} $product using Docker (recommended). Select 'N' to install it using RPM/DEB packages."; + echo "Select 'Y' to install ${product_sysname^^} $product using Docker (recommended). Select 'N' to install it using RPM/DEB packages." read -p "Install with Docker [Y/N/C]? " choice case "$choice" in y|Y ) - DOCKER="true"; + DOCKER="true" ;; n|N ) - DOCKER="false"; + DOCKER="false" ;; c|C ) - exit 0; + exit 0 ;; * ) - echo "Please, enter Y, N or C to cancel"; + echo "Please, enter Y, N or C to cancel" ;; esac if [ "$DOCKER" == "" ]; then - read_installation_method; + read_installation_method fi } root_checking if ! command_exists curl ; then - install_curl; + install_curl fi if command_exists docker &> /dev/null && docker ps -a --format '{{.Names}}' | grep -q "${product_sysname}-api"; then @@ -145,7 +145,7 @@ elif command_exists yum &> /dev/null && rpm -q ${product}-api >/dev/null 2>&1; t fi if [ -z "$DOCKER" ]; then - read_installation_method; + read_installation_method fi if [ -z $GIT_BRANCH ]; then @@ -180,8 +180,8 @@ else rm install-Debian.sh fi else - echo "Not supported OS"; - exit 1; + echo "Not supported OS" + exit 1 fi fi diff --git a/install/OneClickInstall/install-Debian.sh b/install/OneClickInstall/install-Debian.sh index af11371a347..a8bc6d235c3 100644 --- a/install/OneClickInstall/install-Debian.sh +++ b/install/OneClickInstall/install-Debian.sh @@ -2,16 +2,16 @@ set -e -package_sysname="onlyoffice"; -DS_COMMON_NAME="onlyoffice"; +package_sysname="onlyoffice" +DS_COMMON_NAME="onlyoffice" product_name="DocSpace" product=$(tr '[:upper:]' '[:lower:]' <<< ${product_name}) INSTALLATION_TYPE="ENTERPRISE" MAKESWAP="true" -RES_APP_INSTALLED="is already installed"; +RES_APP_INSTALLED="is already installed" RES_APP_CHECK_PORTS="uses ports" -RES_CHECK_PORTS="please, make sure that the ports are free."; -RES_INSTALL_SUCCESS="Thank you for installing ONLYOFFICE ${product_name}."; +RES_CHECK_PORTS="please, make sure that the ports are free." +RES_INSTALL_SUCCESS="Thank you for installing ONLYOFFICE ${product_name}." RES_QUESTIONS="In case you have any questions contact us via http://support.onlyoffice.com or visit our forum at http://forum.onlyoffice.com" INSTALL_FLUENT_BIT="true" @@ -55,7 +55,7 @@ while [ "$1" != "" ]; do -gb | --gitbranch ) if [ "$2" != "" ]; then - PARAMETERS="$PARAMETERS ${1}"; + PARAMETERS="$PARAMETERS ${1}" GIT_BRANCH=$2 shift fi @@ -98,7 +98,7 @@ while [ "$1" != "" ]; do -it | --installation_type ) if [ "$2" != "" ]; then - INSTALLATION_TYPE=$(echo "$2" | awk '{print toupper($0)}'); + INSTALLATION_TYPE="${2^^}" shift fi ;; @@ -115,13 +115,13 @@ while [ "$1" != "" ]; do echo " Parameters:" echo " -it, --installation_type installation type (community|developer|enterprise)" echo " -u, --update use to update existing components (true|false)" - echo " -uni, --uninstall uninstall existing installation (true|false)" + echo " -uni, --uninstall uninstall existing installation (true|false)" echo " -je, --jwtenabled specifies the enabling the JWT validation (true|false)" echo " -jh, --jwtheader defines the http header that will be used to send the JWT" echo " -js, --jwtsecret defines the secret key to validate the JWT in the request" echo " -ifb, --installfluentbit install or update fluent-bit (true|false)" - echo " -du, --dashboadrsusername login for authorization in /dashboards/" - echo " -dp, --dashboadrspassword password for authorization in /dashboards/" + echo " -du, --dashboardsusername login for authorization in /dashboards/" + echo " -dp, --dashboardspassword password for authorization in /dashboards/" echo " -ls, --local_scripts use 'true' to run local scripts (true|false)" echo " -skiphc, --skiphardwarecheck use to skip hardware check (true|false)" echo " -ms, --makeswap make swap file (true|false)" @@ -148,7 +148,7 @@ fi apt-get update -y --allow-releaseinfo-change; if [ $(dpkg-query -W -f='${Status}' curl 2>/dev/null | grep -c "ok installed") -eq 0 ]; then - apt-get install -yq curl; + apt-get install -yq curl fi if [ -z $GIT_BRANCH ]; then diff --git a/install/OneClickInstall/install-Debian/check-ports.sh b/install/OneClickInstall/install-Debian/check-ports.sh index 5236b67c6f0..36c07fa33e2 100644 --- a/install/OneClickInstall/install-Debian/check-ports.sh +++ b/install/OneClickInstall/install-Debian/check-ports.sh @@ -12,28 +12,28 @@ EOF if dpkg -l | grep -q "${product}"; then echo "${product} $RES_APP_INSTALLED" - PRODUCT_INSTALLED="true"; -elif [ $UPDATE != "true" ] && netstat -lnp | awk '{print $4}' | grep -qE ":80$|:8081$|:8083$|:5001$|:5002$|:8080$|:80$"; then - echo "${product} $RES_APP_CHECK_PORTS: 80, 8080, 8081, 8083, 5001, 5002"; + PRODUCT_INSTALLED="true" +elif [ $UPDATE != "true" ] && netstat -lnp | awk '{print $4}' | grep -qE ":80$|:8080$|:8081$|:8083$|:5001$|:5002$"; then + echo "${product} $RES_APP_CHECK_PORTS: 80, 8080, 8081, 8083, 5001, 5002" echo "$RES_CHECK_PORTS" exit else - PRODUCT_INSTALLED="false"; + PRODUCT_INSTALLED="false" fi if dpkg -l | grep -q "${package_sysname}-documentserver"; then echo "${package_sysname}-documentserver $RES_APP_INSTALLED" - DOCUMENT_SERVER_INSTALLED="true"; + DOCUMENT_SERVER_INSTALLED="true" elif [ $UPDATE != "true" ] && netstat -lnp | awk '{print $4}' | grep -qE ":8083$|:5432$|:5672$|:6379$|:8000$|:8080$"; then - echo "${package_sysname}-documentserver $RES_APP_CHECK_PORTS: 8083, 5432, 5672, 6379, 8000, 8080"; + echo "${package_sysname}-documentserver $RES_APP_CHECK_PORTS: 8083, 5432, 5672, 6379, 8000, 8080" echo "$RES_CHECK_PORTS" exit else - DOCUMENT_SERVER_INSTALLED="false"; + DOCUMENT_SERVER_INSTALLED="false" fi if [ "$PRODUCT_INSTALLED" = "true" ] || [ "$DOCUMENT_SERVER_INSTALLED" = "true" ]; then if [ "$UPDATE" != "true" ]; then - exit; + exit fi fi diff --git a/install/OneClickInstall/install-Debian/install-app.sh b/install/OneClickInstall/install-Debian/install-app.sh index 65436071fbc..cbf6f503939 100644 --- a/install/OneClickInstall/install-Debian/install-app.sh +++ b/install/OneClickInstall/install-Debian/install-app.sh @@ -5,7 +5,7 @@ set -e cat</dev/null && NETWORK_REMOVED=true || echo "Failed to remove network ${NETWORK_NAME}." - read -p "Do you want to retain data (keep .env file)? (Y/n): " KEEP_DATA if [[ "$NETWORK_REMOVED" == "true" && -d "$BASE_DIR" ]]; then @@ -636,14 +635,14 @@ uninstall() { root_checking () { PID=$$ - if [ ! $( id -u ) -eq 0 ]; then + if [[ $EUID -ne 0 ]]; then echo "To perform this action you must be logged in with root rights" - exit 1; + exit 1 fi } is_command_exists () { - type "$1" &> /dev/null; + type "$1" &> /dev/null } file_exists () { @@ -653,9 +652,9 @@ file_exists () { fi if [ -f "$1" ]; then - return 0; #true + return 0 #true else - return 1; #false + return 1 #false fi } @@ -674,7 +673,7 @@ get_random_str () { LENGTH=12; fi - VALUE=$(cat /dev/urandom | tr -dc A-Za-z0-9 | head -c ${LENGTH}); + VALUE=$(cat /dev/urandom | tr -dc A-Za-z0-9 | head -c ${LENGTH}) echo "$VALUE" } @@ -744,9 +743,9 @@ get_os_info () { check_os_info () { if [[ -z ${KERNEL} || -z ${DIST} || -z ${REV} ]]; then - echo "$KERNEL, $DIST, $REV"; - echo "Not supported OS"; - exit 1; + echo "$KERNEL, $DIST, $REV" + echo "Not supported OS" + exit 1 fi if [ -f /etc/needrestart/needrestart.conf ]; then @@ -755,21 +754,21 @@ check_os_info () { } check_kernel () { - MIN_NUM_ARR=(3 10 0); - CUR_NUM_ARR=(); + MIN_NUM_ARR=(3 10 0) + CUR_NUM_ARR=() - CUR_STR_ARR=$(echo $KERNEL | grep -Po "[0-9]+\.[0-9]+\.[0-9]+" | tr "." " "); + CUR_STR_ARR=$(echo $KERNEL | grep -Po "[0-9]+\.[0-9]+\.[0-9]+" | tr "." " ") for CUR_STR_ITEM in $CUR_STR_ARR do CUR_NUM_ARR=(${CUR_NUM_ARR[@]} $CUR_STR_ITEM) done - INDEX=0; + INDEX=0 while [[ $INDEX -lt 3 ]]; do if [ ${CUR_NUM_ARR[INDEX]} -lt ${MIN_NUM_ARR[INDEX]} ]; then echo "Not supported OS Kernel" - exit 1; + exit 1 elif [ ${CUR_NUM_ARR[INDEX]} -gt ${MIN_NUM_ARR[INDEX]} ]; then INDEX=3 fi @@ -778,25 +777,25 @@ check_kernel () { } check_hardware () { - AVAILABLE_DISK_SPACE=$(df -m / | tail -1 | awk '{ print $4 }'); + AVAILABLE_DISK_SPACE=$(df -m / | tail -1 | awk '{ print $4 }') 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; + exit 1 fi - TOTAL_MEMORY=$(free --mega | grep -oP '\d+' | head -n 1); + TOTAL_MEMORY=$(free --mega | grep -oP '\d+' | head -n 1) if [ ${TOTAL_MEMORY} -lt ${MEMORY_REQUIREMENTS} ]; then echo "Minimal requirements are not met: need at least $MEMORY_REQUIREMENTS MB of RAM" - exit 1; + exit 1 fi - CPU_CORES_NUMBER=$(cat /proc/cpuinfo | grep processor | wc -l); + CPU_CORES_NUMBER=$(cat /proc/cpuinfo | grep processor | wc -l) 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; + exit 1 fi } @@ -823,21 +822,21 @@ install_docker_compose () { } check_ports () { - RESERVED_PORTS=(); - ARRAY_PORTS=(); - USED_PORTS=""; + RESERVED_PORTS=() + ARRAY_PORTS=() + USED_PORTS="" if [ "${EXTERNAL_PORT//[0-9]}" = "" ]; then for RESERVED_PORT in "${RESERVED_PORTS[@]}" do if [ "$RESERVED_PORT" -eq "$EXTERNAL_PORT" ] ; then echo "External port $EXTERNAL_PORT is reserved. Select another port" - exit 1; + exit 1 fi done else echo "Invalid external port $EXTERNAL_PORT" - exit 1; + exit 1 fi if [ "$INSTALL_PRODUCT" == "true" ]; then @@ -860,42 +859,42 @@ check_ports () { if [[ $USED_PORTS != "" ]]; then echo "The following TCP Ports must be available: $USED_PORTS" - exit 1; + exit 1 fi } check_docker_version () { - CUR_FULL_VERSION=$(docker -v | cut -d ' ' -f3 | cut -d ',' -f1); - CUR_VERSION=$(echo $CUR_FULL_VERSION | cut -d '-' -f1); - CUR_EDITION=$(echo $CUR_FULL_VERSION | cut -d '-' -f2); + CUR_FULL_VERSION=$(docker -v | cut -d ' ' -f3 | cut -d ',' -f1) + CUR_VERSION=$(echo $CUR_FULL_VERSION | cut -d '-' -f1) + CUR_EDITION=$(echo $CUR_FULL_VERSION | cut -d '-' -f2) if [ "${CUR_EDITION}" == "ce" ] || [ "${CUR_EDITION}" == "ee" ]; then - return 0; + return 0 fi if [ "${CUR_VERSION}" != "${CUR_EDITION}" ]; then echo "Unspecific docker version" - exit 1; + exit 1 fi - MIN_NUM_ARR=(1 10 0); + MIN_NUM_ARR=(1 10 0) CUR_NUM_ARR=(); - CUR_STR_ARR=$(echo $CUR_VERSION | grep -Po "[0-9]+\.[0-9]+\.[0-9]+" | tr "." " "); + CUR_STR_ARR=$(echo $CUR_VERSION | grep -Po "[0-9]+\.[0-9]+\.[0-9]+" | tr "." " ") for CUR_STR_ITEM in $CUR_STR_ARR do CUR_NUM_ARR=(${CUR_NUM_ARR[@]} $CUR_STR_ITEM) done - INDEX=0; + INDEX=0 while [[ $INDEX -lt 3 ]]; do if [ ${CUR_NUM_ARR[INDEX]} -lt ${MIN_NUM_ARR[INDEX]} ]; then echo "The outdated Docker version has been found. Please update to the latest version." - exit 1; + exit 1 elif [ ${CUR_NUM_ARR[INDEX]} -gt ${MIN_NUM_ARR[INDEX]} ]; then - return 0; + return 0 fi (( INDEX++ )) done @@ -923,7 +922,7 @@ install_docker () { echo "Your operating system does not allow Docker CE installation." echo "You can install Docker EE using the manual here - https://docs.docker.com/engine/installation/linux/rhel/" echo "" - exit 1; + exit 1 fi elif [ "${DIST}" == "SuSe" ]; then @@ -932,7 +931,7 @@ install_docker () { echo "Your operating system does not allow Docker CE installation." echo "You can install Docker EE using the manual here - https://docs.docker.com/engine/installation/linux/suse/" echo "" - exit 1; + exit 1 elif [ "${DIST}" == "altlinux" ]; then @@ -952,13 +951,13 @@ install_docker () { echo "Docker could not be installed automatically." echo "Please use this official instruction https://docs.docker.com/engine/installation/linux/other/ for its manual installation." echo "" - exit 1; + exit 1 fi if ! is_command_exists docker ; then echo "error while installing docker" - exit 1; + exit 1 fi } @@ -969,7 +968,7 @@ docker_login () { } create_network () { - NETWORT_EXIST=$(docker network ls | awk '{print $2;}' | { grep -x ${NETWORK_NAME} || true; }); + NETWORT_EXIST=$(docker network ls | awk '{print $2;}' | { grep -x ${NETWORK_NAME} || true; }) if [[ -z ${NETWORT_EXIST} ]]; then docker network create --driver bridge ${NETWORK_NAME} @@ -988,11 +987,11 @@ read_continue_installation () { ;; n|N ) - exit 0; + exit 0 ;; * ) - echo "Please, enter Y or N"; + echo "Please, enter Y or N" read_continue_installation ;; esac @@ -1036,19 +1035,19 @@ establish_conn() { } get_env_parameter () { - local PARAMETER_NAME=$1; - local CONTAINER_NAME=$2; + local PARAMETER_NAME=$1 + local CONTAINER_NAME=$2 if [[ -z ${PARAMETER_NAME} ]]; then echo "Empty parameter name" - exit 1; + exit 1 fi if is_command_exists docker ; then - [ -n "$CONTAINER_NAME" ] && CONTAINER_EXIST=$(docker ps -aqf "name=$CONTAINER_NAME"); + [ -n "$CONTAINER_NAME" ] && CONTAINER_EXIST=$(docker ps -aqf "name=$CONTAINER_NAME") if [[ -n ${CONTAINER_EXIST} ]]; then - VALUE=$(docker inspect --format='{{range .Config.Env}}{{println .}}{{end}}' ${CONTAINER_NAME} | grep "${PARAMETER_NAME}=" | sed 's/^.*=//'); + VALUE=$(docker inspect --format='{{range .Config.Env}}{{println .}}{{end}}' ${CONTAINER_NAME} | grep "${PARAMETER_NAME}=" | sed 's/^.*=//') fi fi @@ -1074,9 +1073,9 @@ get_tag_from_hub () { else if [[ -n ${USERNAME} && -n ${PASSWORD} ]]; then CREDENTIALS="{\"username\":\"$USERNAME\",\"password\":\"$PASSWORD\"}" - TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d "$CREDENTIALS" https://hub.docker.com/v2/users/login/ | jq -r '.token'); + TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d "$CREDENTIALS" https://hub.docker.com/v2/users/login/ | jq -r '.token') AUTH_HEADER="Authorization: JWT $TOKEN" - sleep 1; + sleep 1 fi HUB_URL="https://hub.docker.com/v2/repositories/${1}/tags/" @@ -1106,7 +1105,7 @@ get_available_version () { } set_docs_url_external () { - DOCUMENT_SERVER_URL_EXTERNAL=${DOCUMENT_SERVER_URL_EXTERNAL:-$(get_env_parameter "DOCUMENT_SERVER_URL_EXTERNAL" "${CONTAINER_NAME}")}; + DOCUMENT_SERVER_URL_EXTERNAL=${DOCUMENT_SERVER_URL_EXTERNAL:-$(get_env_parameter "DOCUMENT_SERVER_URL_EXTERNAL" "${CONTAINER_NAME}")} if [[ ! -z ${DOCUMENT_SERVER_URL_EXTERNAL} ]] && [[ $DOCUMENT_SERVER_URL_EXTERNAL =~ ^(https?://)?([^:/]+)(:([0-9]+))?(/.*)?$ ]]; then [[ -z ${BASH_REMATCH[1]} ]] && DOCUMENT_SERVER_URL_EXTERNAL="http://$DOCUMENT_SERVER_URL_EXTERNAL" @@ -1147,34 +1146,34 @@ set_mysql_params () { } set_docspace_params() { - HUB=${HUB:-$(get_env_parameter "HUB")}; - - ENV_EXTENSION=${ENV_EXTENSION:-$(get_env_parameter "ENV_EXTENSION" "${CONTAINER_NAME}")}; - APP_CORE_BASE_DOMAIN=${APP_CORE_BASE_DOMAIN:-$(get_env_parameter "APP_CORE_BASE_DOMAIN" "${CONTAINER_NAME}")}; - EXTERNAL_PORT=${EXTERNAL_PORT:-$(get_env_parameter "EXTERNAL_PORT" "${CONTAINER_NAME}")}; - - PREVIOUS_ELK_VERSION=$(get_env_parameter "ELK_VERSION"); - ELK_SHEME=${ELK_SHEME:-$(get_env_parameter "ELK_SHEME" "${CONTAINER_NAME}")}; - ELK_HOST=${ELK_HOST:-$(get_env_parameter "ELK_HOST" "${CONTAINER_NAME}")}; - ELK_PORT=${ELK_PORT:-$(get_env_parameter "ELK_PORT" "${CONTAINER_NAME}")}; - - REDIS_HOST=${REDIS_HOST:-$(get_env_parameter "REDIS_HOST" "${CONTAINER_NAME}")}; - REDIS_PORT=${REDIS_PORT:-$(get_env_parameter "REDIS_PORT" "${CONTAINER_NAME}")}; - REDIS_USER_NAME=${REDIS_USER_NAME:-$(get_env_parameter "REDIS_USER_NAME" "${CONTAINER_NAME}")}; - REDIS_PASSWORD=${REDIS_PASSWORD:-$(get_env_parameter "REDIS_PASSWORD" "${CONTAINER_NAME}")}; - - RABBIT_HOST=${RABBIT_HOST:-$(get_env_parameter "RABBIT_HOST" "${CONTAINER_NAME}")}; - RABBIT_PORT=${RABBIT_PORT:-$(get_env_parameter "RABBIT_PORT" "${CONTAINER_NAME}")}; - RABBIT_USER_NAME=${RABBIT_USER_NAME:-$(get_env_parameter "RABBIT_USER_NAME" "${CONTAINER_NAME}")}; - RABBIT_PASSWORD=${RABBIT_PASSWORD:-$(get_env_parameter "RABBIT_PASSWORD" "${CONTAINER_NAME}")}; - RABBIT_VIRTUAL_HOST=${RABBIT_VIRTUAL_HOST:-$(get_env_parameter "RABBIT_VIRTUAL_HOST" "${CONTAINER_NAME}")}; + HUB=${HUB:-$(get_env_parameter "HUB")} + + ENV_EXTENSION=${ENV_EXTENSION:-$(get_env_parameter "ENV_EXTENSION" "${CONTAINER_NAME}")} + APP_CORE_BASE_DOMAIN=${APP_CORE_BASE_DOMAIN:-$(get_env_parameter "APP_CORE_BASE_DOMAIN" "${CONTAINER_NAME}")} + EXTERNAL_PORT=${EXTERNAL_PORT:-$(get_env_parameter "EXTERNAL_PORT" "${CONTAINER_NAME}")} + + PREVIOUS_ELK_VERSION=$(get_env_parameter "ELK_VERSION") + ELK_SHEME=${ELK_SHEME:-$(get_env_parameter "ELK_SHEME" "${CONTAINER_NAME}")} + ELK_HOST=${ELK_HOST:-$(get_env_parameter "ELK_HOST" "${CONTAINER_NAME}")} + ELK_PORT=${ELK_PORT:-$(get_env_parameter "ELK_PORT" "${CONTAINER_NAME}")} + + REDIS_HOST=${REDIS_HOST:-$(get_env_parameter "REDIS_HOST" "${CONTAINER_NAME}")} + REDIS_PORT=${REDIS_PORT:-$(get_env_parameter "REDIS_PORT" "${CONTAINER_NAME}")} + REDIS_USER_NAME=${REDIS_USER_NAME:-$(get_env_parameter "REDIS_USER_NAME" "${CONTAINER_NAME}")} + REDIS_PASSWORD=${REDIS_PASSWORD:-$(get_env_parameter "REDIS_PASSWORD" "${CONTAINER_NAME}")} + + RABBIT_HOST=${RABBIT_HOST:-$(get_env_parameter "RABBIT_HOST" "${CONTAINER_NAME}")} + RABBIT_PORT=${RABBIT_PORT:-$(get_env_parameter "RABBIT_PORT" "${CONTAINER_NAME}")} + RABBIT_USER_NAME=${RABBIT_USER_NAME:-$(get_env_parameter "RABBIT_USER_NAME" "${CONTAINER_NAME}")} + RABBIT_PASSWORD=${RABBIT_PASSWORD:-$(get_env_parameter "RABBIT_PASSWORD" "${CONTAINER_NAME}")} + RABBIT_VIRTUAL_HOST=${RABBIT_VIRTUAL_HOST:-$(get_env_parameter "RABBIT_VIRTUAL_HOST" "${CONTAINER_NAME}")} - DASHBOARDS_USERNAME=${DASHBOARDS_USERNAME:-$(get_env_parameter "DASHBOARDS_USERNAME" "${CONTAINER_NAME}")}; - DASHBOARDS_PASSWORD=${DASHBOARDS_PASSWORD:-$(get_env_parameter "DASHBOARDS_PASSWORD" "${CONTAINER_NAME}")}; + DASHBOARDS_USERNAME=${DASHBOARDS_USERNAME:-$(get_env_parameter "DASHBOARDS_USERNAME" "${CONTAINER_NAME}")} + DASHBOARDS_PASSWORD=${DASHBOARDS_PASSWORD:-$(get_env_parameter "DASHBOARDS_PASSWORD" "${CONTAINER_NAME}")} - CERTIFICATE_PATH=${CERTIFICATE_PATH:-$(get_env_parameter "CERTIFICATE_PATH")}; - CERTIFICATE_KEY_PATH=${CERTIFICATE_KEY_PATH:-$(get_env_parameter "CERTIFICATE_KEY_PATH")}; - DHPARAM_PATH=${DHPARAM_PATH:-$(get_env_parameter "DHPARAM_PATH")}; + CERTIFICATE_PATH=${CERTIFICATE_PATH:-$(get_env_parameter "CERTIFICATE_PATH")} + CERTIFICATE_KEY_PATH=${CERTIFICATE_KEY_PATH:-$(get_env_parameter "CERTIFICATE_KEY_PATH")} + DHPARAM_PATH=${DHPARAM_PATH:-$(get_env_parameter "DHPARAM_PATH")} } set_installation_type_data () { @@ -1227,7 +1226,7 @@ reconfigure () { } install_mysql_server () { - reconfigure DATABASE_MIGRATION ${DATABASE_MIGRATION} + reconfigure DATABASE_MIGRATION ${DATABASE_MIGRATION} reconfigure MYSQL_DATABASE ${MYSQL_DATABASE} reconfigure MYSQL_USER ${MYSQL_USER} reconfigure MYSQL_PASSWORD ${MYSQL_PASSWORD} @@ -1287,9 +1286,9 @@ install_fluent_bit () { if crontab -l | grep -q "${OPENSEARCH_INDEX}"; then crontab -l | grep -v "${OPENSEARCH_INDEX}" | crontab - fi - (crontab -l 2>/dev/null; echo "0 0 */1 * * curl -s -X POST "$(get_env_parameter 'ELK_SHEME')"://${ELK_HOST:-127.0.0.1}:$(get_env_parameter 'ELK_PORT')/${OPENSEARCH_INDEX}/_delete_by_query -H 'Content-Type: application/json' -d '{\"query\": {\"range\": {\"@timestamp\": {\"lt\": \"now-30d\"}}}}'") | crontab - + (crontab -l 2>/dev/null; echo "0 0 */1 * * curl -s -X POST "$(get_env_parameter 'ELK_SHEME')"://${ELK_HOST:-127.0.0.1}:$(get_env_parameter 'ELK_PORT')/${OPENSEARCH_INDEX}/_delete_by_query -H 'Content-Type: application/json' -d '{\"query\": {\"range\": {\"@timestamp\": {\"lt\": \"now-30d\"}}}}'") | crontab - - sed -i "s/OPENSEARCH_HOST/${ELK_HOST:-"${PACKAGE_SYSNAME}-opensearch"}/g" "${BASE_DIR}/config/fluent-bit.conf" + sed -i "s/OPENSEARCH_HOST/${ELK_HOST:-"${PACKAGE_SYSNAME}-opensearch"}/g" "${BASE_DIR}/config/fluent-bit.conf" sed -i "s/OPENSEARCH_PORT/$(get_env_parameter "ELK_PORT")/g" ${BASE_DIR}/config/fluent-bit.conf sed -i "s/OPENSEARCH_INDEX/${OPENSEARCH_INDEX}/g" ${BASE_DIR}/config/fluent-bit.conf @@ -1362,12 +1361,12 @@ install_product () { } make_swap () { - DISK_REQUIREMENTS=6144; #6Gb free space - MEMORY_REQUIREMENTS=12000; #RAM ~12Gb + DISK_REQUIREMENTS=6144 #6Gb free space + MEMORY_REQUIREMENTS=12000 #RAM ~12Gb - 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; }); + 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; }) if [[ -z $EXIST ]] && [ ${TOTAL_MEMORY} -lt ${MEMORY_REQUIREMENTS} ] && [ ${AVAILABLE_DISK_SPACE} -gt ${DISK_REQUIREMENTS} ]; then @@ -1461,7 +1460,7 @@ check_docker_image () { services_check_connection () { # Fixes issues with variables when upgrading to v1.1.3 - HOSTS=("ELK_HOST" "REDIS_HOST" "RABBIT_HOST" "MYSQL_HOST"); + HOSTS=("ELK_HOST" "REDIS_HOST" "RABBIT_HOST" "MYSQL_HOST") for HOST in "${HOSTS[@]}"; do [[ "${!HOST}" == *CONTAINER_PREFIX* || "${!HOST}" == *$PACKAGE_SYSNAME* ]] && export "$HOST="; done [[ "${APP_URL_PORTAL}" == *${PACKAGE_SYSNAME}-proxy* ]] && APP_URL_PORTAL="" @@ -1568,7 +1567,7 @@ start_installation () { echo "In case you have any questions contact us via http://support.${PACKAGE_SYSNAME}.com or visit our forum at http://forum.${PACKAGE_SYSNAME}.com" echo "" - exit 0; + exit 0 } [[ $UNINSTALL != true ]] && start_installation || uninstall diff --git a/install/OneClickInstall/install-RedHat.sh b/install/OneClickInstall/install-RedHat.sh index e5ec67de5a3..3a265339197 100644 --- a/install/OneClickInstall/install-RedHat.sh +++ b/install/OneClickInstall/install-RedHat.sh @@ -3,15 +3,15 @@ set -e package_manager="yum" -package_sysname="onlyoffice"; +package_sysname="onlyoffice" product_name="DocSpace" product=$(tr '[:upper:]' '[:lower:]' <<< ${product_name}) INSTALLATION_TYPE="ENTERPRISE" MAKESWAP="true" -RES_APP_INSTALLED="is already installed"; +RES_APP_INSTALLED="is already installed" RES_APP_CHECK_PORTS="uses ports" -RES_CHECK_PORTS="please, make sure that the ports are free."; -RES_INSTALL_SUCCESS="Thank you for installing ONLYOFFICE ${product_name}."; +RES_CHECK_PORTS="please, make sure that the ports are free." +RES_INSTALL_SUCCESS="Thank you for installing ONLYOFFICE ${product_name}." RES_QUESTIONS="In case you have any questions contact us via http://support.onlyoffice.com or visit our forum at http://forum.onlyoffice.com" RES_MARIADB="To continue the installation, you need to remove MariaDB" INSTALL_FLUENT_BIT="true" @@ -56,7 +56,7 @@ while [ "$1" != "" ]; do -gb | --gitbranch ) if [ "$2" != "" ]; then - PARAMETERS="$PARAMETERS ${1}"; + PARAMETERS="$PARAMETERS ${1}" GIT_BRANCH=$2 shift fi @@ -69,14 +69,14 @@ while [ "$1" != "" ]; do fi ;; - -du | --dashboadrsusername ) + -du | --dashboardsusername ) if [ "$2" != "" ]; then DASHBOARDS_USERNAME=$2 shift fi ;; - -dp | --dashboadrspassword ) + -dp | --dashboardspassword ) if [ "$2" != "" ]; then DASHBOARDS_PASSWORD=$2 shift @@ -99,7 +99,7 @@ while [ "$1" != "" ]; do -it | --installation_type ) if [ "$2" != "" ]; then - INSTALLATION_TYPE=$(echo "$2" | awk '{print toupper($0)}'); + INSTALLATION_TYPE="${2^^}" shift fi ;; @@ -116,13 +116,13 @@ while [ "$1" != "" ]; do echo " Parameters:" echo " -it, --installation_type installation type (community|developer|enterprise)" echo " -u, --update use to update existing components (true|false)" - echo " -uni, --uninstall uninstall existing installation (true|false)" + echo " -uni, --uninstall uninstall existing installation (true|false)" echo " -je, --jwtenabled specifies the enabling the JWT validation (true|false)" echo " -jh, --jwtheader defines the http header that will be used to send the JWT" echo " -js, --jwtsecret defines the secret key to validate the JWT in the request" echo " -ifb, --installfluentbit install or update fluent-bit (true|false)" - echo " -du, --dashboadrsusername login for authorization in /dashboards/" - echo " -dp, --dashboadrspassword password for authorization in /dashboards/" + echo " -du, --dashboardsusername login for authorization in /dashboards/" + echo " -dp, --dashboardspassword password for authorization in /dashboards/" echo " -ls, --local_scripts use 'true' to run local scripts (true|false)" echo " -skiphc, --skiphardwarecheck use to skip hardware check (true|false)" echo " -ms, --makeswap make swap file (true|false)" diff --git a/install/OneClickInstall/install-RedHat/bootstrap.sh b/install/OneClickInstall/install-RedHat/bootstrap.sh index 507b45a82b8..5a0d62196de 100644 --- a/install/OneClickInstall/install-RedHat/bootstrap.sh +++ b/install/OneClickInstall/install-RedHat/bootstrap.sh @@ -11,5 +11,5 @@ cat</dev/null 2>&1; then if [ -z $MYSQL_TEMPORARY_ROOT_PASS ]; then - MYSQL="mysql --connect-expired-password -u$MYSQL_SERVER_USER -D mysql"; + 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="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') fi MYSQL_AUTHENTICATION_PLUGIN=$($MYSQL -e "SHOW VARIABLES LIKE 'default_authentication_plugin';" -s | awk '{print $2}') MYSQL_AUTHENTICATION_PLUGIN=${MYSQL_AUTHENTICATION_PLUGIN:-caching_sha2_password} $MYSQL -e "ALTER USER '${MYSQL_SERVER_USER}'@'localhost' IDENTIFIED WITH ${MYSQL_AUTHENTICATION_PLUGIN} BY '${MYSQL_ROOT_PASS}'" >/dev/null 2>&1 \ - || $MYSQL -e "UPDATE user SET plugin='${MYSQL_AUTHENTICATION_PLUGIN}', authentication_string=PASSWORD('${MYSQL_ROOT_PASS}') WHERE user='${MYSQL_SERVER_USER}' and host='localhost';" + || $MYSQL -e "UPDATE user SET plugin='${MYSQL_AUTHENTICATION_PLUGIN}', authentication_string=PASSWORD('${MYSQL_ROOT_PASS}') WHERE user='${MYSQL_SERVER_USER}' and host='localhost';" systemctl restart mysqld fi @@ -68,22 +68,22 @@ fi if [ "$DOCUMENT_SERVER_INSTALLED" = "false" ]; then declare -x DS_PORT=8083 - DS_RABBITMQ_HOST=localhost; - DS_RABBITMQ_USER=guest; - DS_RABBITMQ_PWD=guest; + DS_RABBITMQ_HOST=localhost + DS_RABBITMQ_USER=guest + DS_RABBITMQ_PWD=guest - DS_REDIS_HOST=localhost; + DS_REDIS_HOST=localhost - DS_COMMON_NAME=${DS_COMMON_NAME:-"ds"}; + DS_COMMON_NAME=${DS_COMMON_NAME:-"ds"} - DS_DB_HOST=localhost; - DS_DB_NAME=$DS_COMMON_NAME; - DS_DB_USER=$DS_COMMON_NAME; - DS_DB_PWD=$DS_COMMON_NAME; + DS_DB_HOST=localhost + DS_DB_NAME=$DS_COMMON_NAME + DS_DB_USER=$DS_COMMON_NAME + DS_DB_PWD=$DS_COMMON_NAME - declare -x JWT_ENABLED=${JWT_ENABLED:-true}; - 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}; + declare -x JWT_ENABLED=${JWT_ENABLED:-true} + 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 su - postgres -s /bin/bash -c "psql -c \"CREATE USER ${DS_DB_USER} WITH password '${DS_DB_PWD}';\"" diff --git a/install/OneClickInstall/install-RedHat/install-preq.sh b/install/OneClickInstall/install-RedHat/install-preq.sh index e183cfc9fce..e0d051f8de2 100644 --- a/install/OneClickInstall/install-RedHat/install-preq.sh +++ b/install/OneClickInstall/install-RedHat/install-preq.sh @@ -42,7 +42,7 @@ MYSQL_REPO_VERSION="$(curl https://repo.mysql.com | grep -oP "mysql84-community- 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"; + MYSQL_FIRST_TIME_INSTALL="true" fi #add opensearch repo diff --git a/install/OneClickInstall/install-RedHat/tools.sh b/install/OneClickInstall/install-RedHat/tools.sh index ef45ccb906c..dae13d5294c 100644 --- a/install/OneClickInstall/install-RedHat/tools.sh +++ b/install/OneClickInstall/install-RedHat/tools.sh @@ -3,13 +3,13 @@ set -e function make_swap () { - local DISK_REQUIREMENTS=6144; #6Gb free space - local MEMORY_REQUIREMENTS=12000; #RAM ~12Gb - SWAPFILE="/${product}_swapfile"; + local DISK_REQUIREMENTS=6144 #6Gb free space + local MEMORY_REQUIREMENTS=12000 #RAM ~12Gb + SWAPFILE="/${product}_swapfile" - local AVAILABLE_DISK_SPACE=$(df -m / | tail -1 | awk '{ print $4 }'); - local TOTAL_MEMORY=$(free --mega | grep -oP '\d+' | head -n 1); - local EXIST=$(swapon -s | awk '{ print $1 }' | { grep -x ${SWAPFILE} || true; }); + local AVAILABLE_DISK_SPACE=$(df -m / | tail -1 | awk '{ print $4 }') + 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 touch "$SWAPFILE" @@ -23,29 +23,29 @@ function make_swap () { } check_hardware () { - DISK_REQUIREMENTS=40960; - MEMORY_REQUIREMENTS=8000; - CORE_REQUIREMENTS=4; + DISK_REQUIREMENTS=40960 + MEMORY_REQUIREMENTS=8000 + CORE_REQUIREMENTS=4 - AVAILABLE_DISK_SPACE=$(df -m / | tail -1 | awk '{ print $4 }'); + AVAILABLE_DISK_SPACE=$(df -m / | tail -1 | awk '{ print $4 }') 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; + exit 1 fi - TOTAL_MEMORY=$(free --mega | grep -oP '\d+' | head -n 1); + TOTAL_MEMORY=$(free --mega | grep -oP '\d+' | head -n 1) if [ ${TOTAL_MEMORY} -lt ${MEMORY_REQUIREMENTS} ]; then echo "Minimal requirements are not met: need at least $MEMORY_REQUIREMENTS MB of RAM" - exit 1; + exit 1 fi - CPU_CORES_NUMBER=$(cat /proc/cpuinfo | grep processor | wc -l); + CPU_CORES_NUMBER=$(cat /proc/cpuinfo | grep processor | wc -l) 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; + exit 1 fi } @@ -55,7 +55,7 @@ fi UPDATE_AVAILABLE_CODE=100 DIST=$(rpm -qa --queryformat '%{NAME}\n' | grep -E 'centos-release|redhat-release|fedora-release' | awk -F '-' '{print $1}' | head -n 1) -DIST=${DIST:-$(awk -F= '/^ID=/ {gsub(/"/, "", $2); print tolower($2)}' /etc/os-release)}; +DIST=${DIST:-$(awk -F= '/^ID=/ {gsub(/"/, "", $2); print tolower($2)}' /etc/os-release)} [[ "$DIST" =~ ^(centos|redhat|fedora)$ ]] || DIST="centos" REV=$(sed -n 's/.*release\ \([0-9]*\).*/\1/p' /etc/redhat-release) REV=${REV:-"7"} diff --git a/install/OneClickInstall/install-RedHat/uninstall.sh b/install/OneClickInstall/install-RedHat/uninstall.sh index 3de3c2505ed..969210eb099 100644 --- a/install/OneClickInstall/install-RedHat/uninstall.sh +++ b/install/OneClickInstall/install-RedHat/uninstall.sh @@ -40,4 +40,5 @@ if swapon --show | grep -q "/${product}_swapfile"; then fi echo -e "Uninstallation of ${package_sysname^^} ${product_name}" \ - "$( [ "$UNINSTALL_DEPENDENCIES" = true ] && echo "and all dependencies" ) \e[32mcompleted.\e[0m" \ No newline at end of file + "$( [ "$UNINSTALL_DEPENDENCIES" = true ] && echo "and all dependencies" ) \e[32mcompleted.\e[0m" + diff --git a/tests/vagrant/install.sh b/tests/vagrant/install.sh index 05c6e7b220c..d55cc4d35d7 100644 --- a/tests/vagrant/install.sh +++ b/tests/vagrant/install.sh @@ -229,7 +229,7 @@ function install_docspace() { # Message about service status ############################################################################################# function healthcheck_systemd_services() { - for service in ${SERVICES_SYSTEMD[@]}; do + for service in "${SERVICES_SYSTEMD[@]}"; do [[ "$service" == *migration* ]] && continue; if systemctl is-active --quiet ${service}; then echo "${COLOR_GREEN}☑ OK: Service ${service} is running${COLOR_RESET}" @@ -275,7 +275,7 @@ function services_logs() { SERVICES_SYSTEMD=($(awk '/SERVICE_NAME=\(/{flag=1; next} /\)/{flag=0} flag' "build.sh" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | sed 's/^/docspace-/' | sed 's/$/.service/')) SERVICES_SYSTEMD+=("ds-converter.service" "ds-docservice.service" "ds-metrics.service") - for service in ${SERVICES_SYSTEMD[@]}; do + 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 done