Skip to content

Commit

Permalink
Fix cosmetic issues in OCI scripts (#136)
Browse files Browse the repository at this point in the history
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/DocSpace-buildtools/pulls/136
Co-authored-by: Vladimir Ischenko <[email protected]>
Co-committed-by: Vladimir Ischenko <[email protected]>
  • Loading branch information
isboston authored and evgeniy-antonyuk committed Jan 13, 2025
1 parent f95f9a8 commit 392d18e
Show file tree
Hide file tree
Showing 16 changed files with 253 additions and 252 deletions.
48 changes: 24 additions & 24 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 [ ! $( 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 () {
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down
22 changes: 11 additions & 11 deletions install/OneClickInstall/install-Debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -55,7 +55,7 @@ while [ "$1" != "" ]; do

-gb | --gitbranch )
if [ "$2" != "" ]; then
PARAMETERS="$PARAMETERS ${1}";
PARAMETERS="$PARAMETERS ${1}"
GIT_BRANCH=$2
shift
fi
Expand Down Expand Up @@ -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
;;
Expand All @@ -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)"
Expand All @@ -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
Expand Down
16 changes: 8 additions & 8 deletions install/OneClickInstall/install-Debian/check-ports.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 11 additions & 11 deletions install/OneClickInstall/install-Debian/install-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
cat<<EOF
#######################################
# INSTALL APP
# INSTALL APP
#######################################
EOF
Expand All @@ -18,28 +18,28 @@ case "${INSTALLATION_TYPE}" in
esac

if [ "$UPDATE" = "true" ] && [ "$DOCUMENT_SERVER_INSTALLED" = "true" ]; then
ds_pkg_installed_name=$(dpkg -l | grep ${package_sysname}-documentserver | tail -n1 | awk '{print $2}');
ds_pkg_installed_name=$(dpkg -l | grep ${package_sysname}-documentserver | tail -n1 | awk '{print $2}')
if [ -n "${ds_pkg_installed_name}" ] && [ "${ds_pkg_installed_name}" != "${ds_pkg_name}" ]; then
debconf-get-selections | grep ^${ds_pkg_installed_name} | sed s/${ds_pkg_installed_name}/${ds_pkg_name}/g | debconf-set-selections
DEBIAN_FRONTEND=noninteractive apt-get purge -yq ${ds_pkg_installed_name}
apt-get install -yq ${ds_pkg_name}
RECONFIGURE_PRODUCT="true"
else
apt-get install -y --only-upgrade ${ds_pkg_name};
apt-get install -y --only-upgrade ${ds_pkg_name}
fi
fi

if [ "$DOCUMENT_SERVER_INSTALLED" = "false" ]; then
DS_PORT=${DS_PORT:-8083};
DS_PORT=${DS_PORT:-8083}

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

DS_JWT_ENABLED=${DS_JWT_ENABLED:-true};
DS_JWT_SECRET=${DS_JWT_SECRET:-$(cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 32)};
DS_JWT_HEADER=${DS_JWT_HEADER:-AuthorizationJwt};
DS_JWT_ENABLED=${DS_JWT_ENABLED:-true}
DS_JWT_SECRET=${DS_JWT_SECRET:-$(cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 32)}
DS_JWT_HEADER=${DS_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}';\""
Expand Down
4 changes: 2 additions & 2 deletions install/OneClickInstall/install-Debian/install-preq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,6 @@ fi
# disable apparmor for mysql
if which apparmor_parser && [ ! -f /etc/apparmor.d/disable/usr.sbin.mysqld ] && [ -f /etc/apparmor.d/disable/usr.sbin.mysqld ]; then
ln -sf /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/;
apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld;
ln -sf /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
fi
32 changes: 16 additions & 16 deletions install/OneClickInstall/install-Debian/tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
set -e

make_swap () {
DISK_REQUIREMENTS=6144; #6Gb free space
MEMORY_REQUIREMENTS=12000; #RAM ~12Gb
SWAPFILE="/${product}_swapfile";
DISK_REQUIREMENTS=6144 #6Gb free space
MEMORY_REQUIREMENTS=12000 #RAM ~12Gb
SWAPFILE="/${product}_swapfile"

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
touch "${SWAPFILE}"
Expand Down Expand Up @@ -48,29 +48,29 @@ hold_package_version() {
}

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
}

Expand All @@ -81,7 +81,7 @@ fi
ARCH="$(dpkg --print-architecture)"
if [ "$ARCH" != "amd64" ]; then
echo "ONLYOFFICE ${product^^} doesn't support architecture '$ARCH'"
exit;
exit
fi

REV=`cat /etc/debian_version`
Expand Down
3 changes: 2 additions & 1 deletion install/OneClickInstall/install-Debian/uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,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"
"$( [ "$UNINSTALL_DEPENDENCIES" = true ] && echo "and all dependencies" ) \e[32mcompleted.\e[0m"

Loading

0 comments on commit 392d18e

Please sign in to comment.