Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring OCI code #279

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 40 additions & 101 deletions install/OneClickInstall/docspace-install.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

#
# (c) Copyright Ascensio System SIA 2021
# (c) Copyright Ascensio System SIA 2024
#
# This program is a free software product. You can redistribute it and/or
# modify it under the terms of the GNU Affero General Public License (AGPL)
Expand Down Expand Up @@ -40,35 +40,15 @@ FILE_NAME="$(basename "$0")"

while [ "$1" != "" ]; do
case $1 in
-ls | --localscripts )
if [ "$2" == "true" ] || [ "$2" == "false" ]; then
PARAMETERS="$PARAMETERS ${1}";
LOCAL_SCRIPTS=$2
shift
fi
;;

-gb | --gitbranch )
if [ "$2" != "" ]; then
PARAMETERS="$PARAMETERS ${1}";
GIT_BRANCH=$2
shift
fi
;;

docker )
DOCKER="true";
shift && continue
;;

package )
DOCKER="false";
shift && continue
;;
-ls | --localscripts ) [ "$2" == "true" -o "$2" == "false" ] && { PARAMETERS+=" $1"; LOCAL_SCRIPTS=$2; shift; } ;;
-gb | --gitbranch ) [ -n "$2" ] && { PARAMETERS+=" $1"; GIT_BRANCH=$2; shift; } ;;
docker ) DOCKER="true"; shift && continue ;;
package ) 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' to install Docker version of application."
echo "Run '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;
fi
Expand All @@ -80,10 +60,7 @@ while [ "$1" != "" ]; do
done

root_checking () {
if [ ! $( id -u ) -eq 0 ]; then
echo "To perform this action you must be logged in with root rights"
exit 1;
fi
[ "$(id -u)" -eq 0 ] || { echo "To perform this action you must be logged in with root rights"; exit 1; }
}

command_exists () {
Expand All @@ -98,91 +75,53 @@ install_curl () {
yum -y install curl
fi

if ! command_exists curl; then
echo "command curl not found"
exit 1;
fi
command_exists curl || { echo "Command curl not found."; exit 1; }
}

read_installation_method () {
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";
;;

n|N )
DOCKER="false";
;;

c|C )
exit 0;
;;

* )
echo "Please, enter Y, N or C to cancel";
;;
esac

if [ "$DOCKER" == "" ]; then
read_installation_method;
fi
read_installation_method() {
echo "Select 'Y' to install ${product_sysname^^} $product using Docker (recommended)."
echo "Select 'N' to install it using RPM/DEB packages."
while true; do
read -p "Install with Docker [Y/N/C]? " choice
case "${choice,,}" in
y | yes) DOCKER="true"; break ;;
n | no) DOCKER="false"; break ;;
c | cancel) exit 0 ;;
*) echo "Please, enter Y, N, or C to cancel." ;;
esac
done
}

root_checking

if ! command_exists curl ; then
install_curl;
fi
command_exists curl || install_curl

if command_exists docker &> /dev/null && docker ps -a --format '{{.Names}}' | grep -q "${product_sysname}-api"; then
if command_exists docker && docker ps -a --format '{{.Names}}' | grep -q "${product_sysname}-api"; then
DOCKER="true"
elif command_exists apt-get &> /dev/null && dpkg -s ${product}-api >/dev/null 2>&1; then
elif command_exists dpkg && 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
elif command_exists rpm && rpm -q ${product}-api >/dev/null 2>&1; then
DOCKER="false"
fi

if [ -z "$DOCKER" ]; then
read_installation_method;
fi

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
[ -z "$DOCKER" ] && read_installation_method

DOWNLOAD_URL_PREFIX="https://download.${product_sysname}.com/${product}"
[ -n "$GIT_BRANCH" ] && DOWNLOAD_URL_PREFIX="https://raw.githubusercontent.com/${product_sysname^^}/${product}-buildtools/${GIT_BRANCH}/install/OneClickInstall"

if [ "$DOCKER" == "true" ]; then
if [ "$LOCAL_SCRIPTS" == "true" ]; then
bash install-Docker.sh ${PARAMETERS} || EXIT_CODE=$?
else
curl -s -O ${DOWNLOAD_URL_PREFIX}/install-Docker.sh
bash install-Docker.sh ${PARAMETERS} || EXIT_CODE=$?
rm install-Docker.sh
fi
SCRIPT_NAME="install-Docker.sh"
elif [ -f /etc/redhat-release ]; then
SCRIPT_NAME="install-RedHat.sh"
elif [ -f /etc/debian_version ]; then
SCRIPT_NAME="install-Debian.sh"
else
if [ -f /etc/redhat-release ] ; then
if [ "$LOCAL_SCRIPTS" == "true" ]; then
bash install-RedHat.sh ${PARAMETERS} || EXIT_CODE=$?
else
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=$?
else
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;
fi
echo "Not supported OS"
exit 1
fi

[ "$LOCAL_SCRIPTS" != "true" ] && curl -s -O ${DOWNLOAD_URL_PREFIX}/${SCRIPT_NAME}
bash ${SCRIPT_NAME} ${PARAMETERS} || EXIT_CODE=$?
[ "$LOCAL_SCRIPTS" != "true" ] && rm ${SCRIPT_NAME}

exit ${EXIT_CODE:-0}
132 changes: 20 additions & 112 deletions install/OneClickInstall/install-Debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,93 +17,19 @@ INSTALL_FLUENT_BIT="true"

while [ "$1" != "" ]; do
case $1 in

-u | --update )
if [ "$2" != "" ]; then
UPDATE=$2
shift
fi
;;

-je | --jwtenabled )
if [ "$2" != "" ]; then
DS_JWT_ENABLED=$2
shift
fi
;;

-jh | --jwtheader )
if [ "$2" != "" ]; then
DS_JWT_HEADER=$2
shift
fi
;;

-js | --jwtsecret )
if [ "$2" != "" ]; then
DS_JWT_SECRET=$2
shift
fi
;;

-gb | --gitbranch )
if [ "$2" != "" ]; then
PARAMETERS="$PARAMETERS ${1}";
GIT_BRANCH=$2
shift
fi
;;

-ifb | --installfluentbit )
if [ "$2" != "" ]; then
INSTALL_FLUENT_BIT=$2
shift
fi
;;

-du | --dashboadrsusername )
if [ "$2" != "" ]; then
DASHBOARDS_USERNAME=$2
shift
fi
;;

-dp | --dashboadrspassword )
if [ "$2" != "" ]; then
DASHBOARDS_PASSWORD=$2
shift
fi
;;

-ls | --localscripts )
if [ "$2" != "" ]; then
LOCAL_SCRIPTS=$2
shift
fi
;;

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

-it | --installation_type )
if [ "$2" != "" ]; then
INSTALLATION_TYPE=$(echo "$2" | awk '{print toupper($0)}');
shift
fi
;;

-ms | --makeswap )
if [ "$2" != "" ]; then
MAKESWAP=$2
shift
fi
;;

-? | -h | --help )
-je | --jwtenabled ) [ -n "$2" ] && DS_JWT_ENABLED=$2 && shift ;;
-jh | --jwtheader ) [ -n "$2" ] && DS_JWT_HEADER=$2 && shift ;;
-js | --jwtsecret ) [ -n "$2" ] && DS_JWT_SECRET=$2 && shift ;;
-gb | --gitbranch ) [ -n "$2" ] && GIT_BRANCH=$2 && shift ;;
-du | --dashboadrsusername ) [ -n "$2" ] && DASHBOARDS_USERNAME=$2 && shift ;;
-dp | --dashboadrspassword ) [ -n "$2" ] && DASHBOARDS_PASSWORD=$2 && shift ;;
-it | --installation_type ) [ -n "$2" ] && INSTALLATION_TYPE=${2^^} && shift ;;
-u | --update ) [ "$2" == "true" -o "$2" == "false" ] && UPDATE=$2 && shift ;;
-ifb | --installfluentbit ) [ "$2" == "true" -o "$2" == "false" ] && INSTALL_FLUENT_BIT=$2 && shift ;;
-ls | --localscripts ) [ "$2" == "true" -o "$2" == "false" ] && LOCAL_SCRIPTS=$2 && shift ;;
-skiphc | --skiphardwarecheck ) [ "$2" == "true" -o "$2" == "false" ] && SKIP_HARDWARE_CHECK=$2 && shift ;;
-ms | --makeswap ) [ "$2" == "true" -o "$2" == "false" ] && MAKESWAP=$2 && shift ;;
-? | -h | --help )
echo " Usage $0 [PARAMETER] [[PARAMETER], ...]"
echo " Parameters:"
echo " -it, --installation_type installation type (community|enterprise)"
Expand All @@ -121,39 +47,21 @@ while [ "$1" != "" ]; do
echo
exit 0
;;

esac
shift
done

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

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

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

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;
fi
dpkg -l | grep -q "^ii curl" || apt-get install -yq curl

if [ -z $GIT_BRANCH ]; then
DOWNLOAD_URL_PREFIX="https://download.onlyoffice.com/${product}/install-Debian"
else
DOWNLOAD_URL_PREFIX="https://raw.githubusercontent.com/ONLYOFFICE/${product}-buildtools/${GIT_BRANCH}/install/OneClickInstall/install-Debian"
fi
DOWNLOAD_URL_PREFIX="https://download.${product_sysname}.com/${product}/install-Debian"
[ -n "$GIT_BRANCH" ] && DOWNLOAD_URL_PREFIX="https://raw.githubusercontent.com/${product_sysname^^}/${product}-buildtools/${GIT_BRANCH}/install/OneClickInstall/install-Debian"

if [ "${LOCAL_SCRIPTS}" == "true" ]; then
source install-Debian/bootstrap.sh
else
source <(curl ${DOWNLOAD_URL_PREFIX}/bootstrap.sh)
fi
[[ "${LOCAL_SCRIPTS}" == "true" ]] && source install-Debian/bootstrap.sh || source <(curl ${DOWNLOAD_URL_PREFIX}/bootstrap.sh)

# add onlyoffice repo
mkdir -p -m 700 $HOME/.gnupg
Expand Down
Loading