From 08cb7a21544679b4cba80f7fca14cccaa63a7de4 Mon Sep 17 00:00:00 2001 From: Vladimir Ischenko Date: Fri, 24 Jan 2025 09:00:34 +0300 Subject: [PATCH] Test OCI --- install/OneClickInstall/docspace-install.sh | 69 +++++++++---------- .../OneClickInstall/install-RedHat/tools.sh | 42 +++++------ 2 files changed, 55 insertions(+), 56 deletions(-) diff --git a/install/OneClickInstall/docspace-install.sh b/install/OneClickInstall/docspace-install.sh index 361ea4c1a4c..b54796a3c23 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 [[ $EUID -ne 0 ]]; then + if [ ! $( id -u ) -eq 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,45 +100,44 @@ 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 DOCKER="true" - PARAMETERS="-u true $PARAMETERS" elif command_exists apt-get &> /dev/null && dpkg -s ${product}-api >/dev/null 2>&1; then DOCKER="false" elif command_exists yum &> /dev/null && rpm -q ${product}-api >/dev/null 2>&1; then @@ -146,10 +145,10 @@ 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 +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" @@ -157,32 +156,32 @@ 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 - echo "Not supported OS" - exit 1 + echo "Not supported OS"; + exit 1; fi fi diff --git a/install/OneClickInstall/install-RedHat/tools.sh b/install/OneClickInstall/install-RedHat/tools.sh index 0222fb3e83e..ef45ccb906c 100644 --- a/install/OneClickInstall/install-RedHat/tools.sh +++ b/install/OneClickInstall/install-RedHat/tools.sh @@ -3,15 +3,15 @@ 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 + 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" @@ -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 + 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 + 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=$(grep -c ^processor /proc/cpuinfo) + CPU_CORES_NUMBER=$(cat /proc/cpuinfo | grep processor | wc -l); - 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 + 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"} @@ -74,7 +74,7 @@ if [ "$DIST" == "fedora" ]; then OPENRESTY_REV=$([ "$REV" -ge 37 ] && echo 36 || echo "$REV") FEDORA_SUPP=$(curl https://docs.fedoraproject.org/en-US/releases/ | awk '/Supported Releases/,/EOL Releases/' | grep -oP 'F\d+' | tr -d 'F') - echo "$FEDORA_SUPP" | grep -q "$REV" || SUPPORTED_FEDORA_FLAG="false" + [ ! "$(echo "$FEDORA_SUPP" | grep "$REV")" ] && SUPPORTED_FEDORA_FLAG="false" fi # Check if it's Centos less than 8 or Fedora release is out of service