Skip to content

Commit

Permalink
Test OCI
Browse files Browse the repository at this point in the history
  • Loading branch information
isboston committed Jan 24, 2025
1 parent 0613e90 commit 08cb7a2
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 56 deletions.
69 changes: 34 additions & 35 deletions install/OneClickInstall/docspace-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,63 +31,63 @@
# 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
;;

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

"-?" | -h | --help )
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 () {
Expand All @@ -100,89 +100,88 @@ 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
DOCKER="false"
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"
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

Expand Down
42 changes: 21 additions & 21 deletions install/OneClickInstall/install-RedHat/tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
}

Expand All @@ -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"}
Expand All @@ -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
Expand Down

0 comments on commit 08cb7a2

Please sign in to comment.