Skip to content

Commit

Permalink
Add hardware check in deb and rpm OneClickInstall (#479)
Browse files Browse the repository at this point in the history
* Add hardware check in deb and rpm OneClickInstall

* Modify docker document server run config (#476)

* Revert "Modify docker document server run config (#476)"

This reverts commit 9ed7f71.
  • Loading branch information
evgeniy-antonyuk authored Dec 10, 2021
1 parent 0855ead commit eca872c
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
11 changes: 11 additions & 0 deletions build/install/OneClickInstall/install-Debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ while [ "$1" != "" ]; do
fi
;;

-skiphc | --skiphardwarecheck )
if [ "$2" != "" ]; then
SKIP_HARDWARE_CHECK=$2
shift
fi
;;

-? | -h | --help )
echo " Usage $0 [PARAMETER] [[PARAMETER], ...]"
echo " Parameters:"
Expand All @@ -60,6 +67,10 @@ if [ -z "${LOCAL_SCRIPTS}" ]; then
LOCAL_SCRIPTS="false";
fi

if [ -z "${SKIP_HARDWARE_CHECK}" ]; then
SKIP_HARDWARE_CHECK="false";
fi

if [ $(dpkg-query -W -f='${Status}' curl 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
apt-get update;
apt-get install -yq curl;
Expand Down
31 changes: 31 additions & 0 deletions build/install/OneClickInstall/install-Debian/tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,37 @@ command_exists () {
type "$1" &> /dev/null;
}

check_hardware () {
DISK_REQUIREMENTS=40960;
MEMORY_REQUIREMENTS=5500;
CORE_REQUIREMENTS=2;

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;
fi

TOTAL_MEMORY=$(free -m | 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;
fi

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;
fi
}

if [ "$SKIP_HARDWARE_CHECK" != "true" ]; then
check_hardware
fi

ARCH="$(dpkg --print-architecture)"
if [ "$ARCH" != "amd64" ]; then
echo "ONLYOFFICE ${product^^} doesn't support architecture '$ARCH'"
Expand Down
13 changes: 13 additions & 0 deletions build/install/OneClickInstall/install-RedHat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ while [ "$1" != "" ]; do
fi
;;

-skiphc | --skiphardwarecheck )
if [ "$2" != "" ]; then
SKIP_HARDWARE_CHECK=$2
shift
fi
;;

-? | -h | --help )
echo " Usage $0 [PARAMETER] [[PARAMETER], ...]"
echo " Parameters:"
Expand All @@ -69,6 +76,10 @@ if [ -z "${LOCAL_SCRIPTS}" ]; then
LOCAL_SCRIPTS="false";
fi

if [ -z "${SKIP_HARDWARE_CHECK}" ]; then
SKIP_HARDWARE_CHECK="false";
fi

cat > /etc/yum.repos.d/onlyoffice.repo <<END
[onlyoffice]
name=onlyoffice repo
Expand All @@ -91,11 +102,13 @@ END
DOWNLOAD_URL_PREFIX="https://raw.githubusercontent.com/ONLYOFFICE/${product}/${GIT_BRANCH}/build/install/OneClickInstall/install-RedHat"

if [ "$LOCAL_SCRIPTS" = "true" ]; then
source install-RedHat/tools.sh
source install-RedHat/bootstrap.sh
source install-RedHat/check-ports.sh
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)
Expand Down
34 changes: 34 additions & 0 deletions build/install/OneClickInstall/install-RedHat/tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

set -e

check_hardware () {
DISK_REQUIREMENTS=40960;
MEMORY_REQUIREMENTS=5500;
CORE_REQUIREMENTS=2;

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;
fi

TOTAL_MEMORY=$(free -m | 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;
fi

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;
fi
}

if [ "$SKIP_HARDWARE_CHECK" != "true" ]; then
check_hardware
fi

0 comments on commit eca872c

Please sign in to comment.