From b770733d5ff3189cbc351cf27c56c7405546c698 Mon Sep 17 00:00:00 2001 From: Evgeniy Antonyuk Date: Thu, 14 Dec 2023 19:15:52 +0700 Subject: [PATCH 1/4] Add systemd service dependencies (#102) --- install/common/systemd/build.sh | 20 ++++++++++++++++++++ install/deb/debian/rules | 2 +- install/rpm/SPECS/build.spec | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/install/common/systemd/build.sh b/install/common/systemd/build.sh index 5249ee2a40..192fc00197 100644 --- a/install/common/systemd/build.sh +++ b/install/common/systemd/build.sh @@ -13,10 +13,18 @@ while [ "$1" != "" ]; do shift fi ;; + + -pm | --packagemanager ) + if [ "$2" != "" ]; then + PACKAGE_MANAGER=$2 + shift + fi + ;; -? | -h | --help ) echo " Usage: bash build.sh [PARAMETER] [[PARAMETER], ...]" echo " Parameters:" + echo " -pm, --packagemanager dependencies for package manager" echo " -bp, --buildpath output path" echo " -?, -h, --help this help" echo " Examples" @@ -64,6 +72,11 @@ SERVICE_NAME=( ) reassign_values (){ + if [[ "${PACKAGE_MANAGER}" = "deb" ]]; then + DEPENDENCY_LIST="mysql.service redis-server.service rabbitmq-server.service" + else + DEPENDENCY_LIST="mysqld.service redis.service rabbitmq-server.service" + fi case $1 in api ) SERVICE_PORT="5000" @@ -79,6 +92,7 @@ reassign_values (){ SERVICE_PORT="9899" WORK_DIR="${BASE_DIR}/services/ASC.Socket.IO/" EXEC_FILE="server.js" + DEPENDENCY_LIST="" ;; studio-notify ) SERVICE_PORT="5006" @@ -106,6 +120,7 @@ reassign_values (){ WORK_DIR="${BASE_DIR}/products/ASC.Files/service/" EXEC_FILE="ASC.Files.Service.dll" CORE_EVENT_BUS=" --core:eventBus:subscriptionClientName=asc_event_bus_files_service_queue" + DEPENDENCY_LIST="${DEPENDENCY_LIST} elasticsearch.service" ;; studio ) SERVICE_PORT="5003" @@ -122,6 +137,7 @@ reassign_values (){ SERVICE_PORT="9834" WORK_DIR="${BASE_DIR}/services/ASC.SsoAuth/" EXEC_FILE="app.js" + DEPENDENCY_LIST="" ;; clear-events ) SERVICE_PORT="5027" @@ -138,6 +154,7 @@ reassign_values (){ SERVICE_PORT="5013" WORK_DIR="${BASE_DIR}/products/ASC.Files/editor/" EXEC_FILE="server.js" + DEPENDENCY_LIST="" ;; migration-runner ) WORK_DIR="${BASE_DIR}/services/ASC.Migration.Runner/" @@ -147,11 +164,13 @@ reassign_values (){ SERVICE_PORT="5011" WORK_DIR="${BASE_DIR}/products/ASC.Login/login/" EXEC_FILE="server.js" + DEPENDENCY_LIST="openresty.service" ;; healthchecks ) SERVICE_PORT="5033" WORK_DIR="${BASE_DIR}/services/ASC.Web.HealthChecks.UI/" EXEC_FILE="ASC.Web.HealthChecks.UI.dll" + DEPENDENCY_LIST="" ;; esac SERVICE_NAME="$1" @@ -173,6 +192,7 @@ reassign_values (){ } write_to_file () { + [[ -n ${DEPENDENCY_LIST} ]] && sed -e "s_\(After=.*\)_\1 ${DEPENDENCY_LIST}_" -e "/After=/a Wants=${DEPENDENCY_LIST}" -i $BUILD_PATH/${PRODUCT}-${SERVICE_NAME[$i]}.service sed -i -e 's#${SERVICE_NAME}#'$SERVICE_NAME'#g' -e 's#${WORK_DIR}#'$WORK_DIR'#g' -e "s#\${RESTART}#$RESTART#g" \ -e "s#\${EXEC_START}#$EXEC_START#g" -e "s#\${SERVICE_TYPE}#$SERVICE_TYPE#g" $BUILD_PATH/${PRODUCT}-${SERVICE_NAME[$i]}.service } diff --git a/install/deb/debian/rules b/install/deb/debian/rules index eec4a14cd4..1179259936 100755 --- a/install/deb/debian/rules +++ b/install/deb/debian/rules @@ -28,7 +28,7 @@ override_dh_auto_configure: override_dh_auto_build: cd ${SRC_PATH}/${SCRIPT_PATH}/systemd; \ - bash build.sh -bp "${CURRENT_PATH}/debian/"; \ + bash build.sh -pm "deb" -bp "${CURRENT_PATH}/debian/"; \ cd ${SRC_PATH}/${SCRIPT_PATH}; \ bash build-frontend.sh -sp ${SRC_PATH} -di "false"; \ bash build-backend.sh -sp ${SRC_PATH}; \ diff --git a/install/rpm/SPECS/build.spec b/install/rpm/SPECS/build.spec index 912280cbc4..8ede5fb2c0 100644 --- a/install/rpm/SPECS/build.spec +++ b/install/rpm/SPECS/build.spec @@ -2,7 +2,7 @@ cd %{_builddir}/buildtools -bash install/common/systemd/build.sh +bash install/common/systemd/build.sh -pm "rpm" bash install/common/build-frontend.sh --srcpath %{_builddir} -di "false" bash install/common/build-backend.sh --srcpath %{_builddir} From f1c00eb8df081306240e41f7b9b32267dbe3bc32 Mon Sep 17 00:00:00 2001 From: Evgeniy Antonyuk Date: Mon, 4 Dec 2023 17:54:11 +0700 Subject: [PATCH 2/4] Fix systemd file location detection for rpm (#94) --- install/common/product-ssl-setup | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install/common/product-ssl-setup b/install/common/product-ssl-setup index d3a6913399..4e35612a00 100644 --- a/install/common/product-ssl-setup +++ b/install/common/product-ssl-setup @@ -94,7 +94,8 @@ if [ -f "${CERTIFICATE_FILE}" ]; then if [ -f "${PRIVATEKEY_FILE}" ]; then cp -f ${OPENRESTY}/onlyoffice-proxy-ssl.conf.template ${OPENRESTY}/onlyoffice-proxy.conf - ENVIRONMENT=$(grep -oP 'ENVIRONMENT=\K.*' $(dirname $(dpkg-query -L ${PRODUCT}-api | grep systemd/system/))/${PRODUCT}-api.service) + PACKAGE_FILE_CHECKER=$(command -v dpkg-query &> /dev/null && echo "dpkg-query -L" || echo "rpm -ql") + ENVIRONMENT=$(grep -oP 'ENVIRONMENT=\K.*' $(dirname $(${PACKAGE_FILE_CHECKER} ${PRODUCT}-api | grep systemd/system/))/${PRODUCT}-api.service) sed -i "s/\(\"portal\":\).*/\1 \"https:\/\/${DOMAIN}\"/" /etc/onlyoffice/docspace/appsettings.$ENVIRONMENT.json sed -i "s~\(ssl_certificate \).*;~\1${CERTIFICATE_FILE};~g" ${OPENRESTY}/onlyoffice-proxy.conf sed -i "s~\(ssl_certificate_key \).*;~\1${PRIVATEKEY_FILE};~g" ${OPENRESTY}/onlyoffice-proxy.conf From 7e84f75fb56b6499e745ac9e210c4f7996c0f045 Mon Sep 17 00:00:00 2001 From: Nasrullo Nurullaev <61620246+nasrullonurullaev@users.noreply.github.com> Date: Tue, 19 Dec 2023 14:52:37 +0500 Subject: [PATCH 3/4] Fix issue with SSL after updating DocSpace (#108) * Fix issue with SSL after updating DocSpace * Add variable declaration --- install/win/DocSpace.aip | 2 +- install/win/utils.vbs | 49 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/install/win/DocSpace.aip b/install/win/DocSpace.aip index 668889b710..7abdbdc0b1 100644 --- a/install/win/DocSpace.aip +++ b/install/win/DocSpace.aip @@ -1012,7 +1012,7 @@ - + diff --git a/install/win/utils.vbs b/install/win/utils.vbs index 7a02458a5c..d7fe3cae8b 100644 --- a/install/win/utils.vbs +++ b/install/win/utils.vbs @@ -478,13 +478,26 @@ End Function Function MoveNginxConfigs On Error Resume Next - Dim objFSO, sourceFolder, targetFolder, nginxFolder + Dim objFSO, objShell, sourceFolder, targetFolder, nginxFolder, configFile, configSslFile, sslScriptPath, sslCertPath, sslCertKeyPath, psCommand ' Define source and target paths Set objFSO = CreateObject("Scripting.FileSystemObject") + Set objShell = CreateObject("WScript.Shell") sourceFolder = Session.Property("APPDIR") & "nginx\conf" targetFolder = "C:\OpenResty\conf" nginxFolder = Session.Property("APPDIR") & "nginx" + configSslFile = targetFolder & "\onlyoffice-proxy-ssl.conf.tmpl" + configFile = targetFolder & "\onlyoffice-proxy.conf" + sslScriptPath = Session.Property("APPDIR") & "sbin\docspace-ssl-setup.ps1" + + ' Read content and extract SSL certificate and key paths if it exists + If objFSO.FileExists(configFile) Then + content = ReadFile(configFile, objFSO) + sslCertPath = ExtractPath(content, "ssl_certificate\s+(.*?);", objFSO) + sslCertKeyPath = ExtractPath(content, "ssl_certificate_key\s+(.*?);", objFSO) + Else + WScript.Echo "Configuration file not found!" + End If ' Check if source folder exists If objFSO.FolderExists(sourceFolder) Then @@ -504,7 +517,41 @@ Function MoveNginxConfigs WScript.Echo "Source folder does not exist." End If + ' If SSL path variables are present, set the SSL paths + If objFSO.FileExists(configSslFile) And ((Len(Trim(sslCertPath)) > 0) And (Len(Trim(sslCertKeyPath)) > 0)) Then + psCommand = "powershell -File """ & sslScriptPath & """ -f """ & sslCertPath & """ """ & sslCertKeyPath & """" + objShell.Run psCommand, 0, True + Else + WScript.Echo "Source file not found." + End If + Set objFSO = Nothing + Set objShell = Nothing +End Function + +Function ReadFile(filePath, objFSO) + Dim objFile + If objFSO.FileExists(filePath) Then + Set objFile = objFSO.OpenTextFile(filePath, 1) + ReadFile = objFile.ReadAll + objFile.Close + Else + WScript.Echo "File not found: " & filePath + End If +End Function + +Function ExtractPath(content, pattern, objFSO) + Dim regex, match + Set regex = New RegExp + regex.Pattern = pattern + + Set match = regex.Execute(content) + If match.Count > 0 Then + ExtractPath = match(0).Submatches(0) + Else + WScript.Echo "Path not found in the content." + ExtractPath = Null + End If End Function Sub CopyFolderContents(sourceFolder, targetFolder, objFSO) From 64687d0960e0c7d6c07d60dab038d9cc5cabaa84 Mon Sep 17 00:00:00 2001 From: Iskandar Kurbonov <116521281+IskandarKurbonov@users.noreply.github.com> Date: Tue, 19 Dec 2023 17:42:05 +0300 Subject: [PATCH 4/4] gh-action: Add OCI scripts ci installation check (#109) * Add files for install OneClickInstall with Vagrant * Delete one matrix and add true for execute --- .github/workflows/ci-oci-install.yml | 146 +++++++++++ tests/vagrant/Vagrantfile | 22 ++ tests/vagrant/install.sh | 357 +++++++++++++++++++++++++++ 3 files changed, 525 insertions(+) create mode 100644 .github/workflows/ci-oci-install.yml create mode 100644 tests/vagrant/Vagrantfile create mode 100644 tests/vagrant/install.sh diff --git a/.github/workflows/ci-oci-install.yml b/.github/workflows/ci-oci-install.yml new file mode 100644 index 0000000000..c929faae7c --- /dev/null +++ b/.github/workflows/ci-oci-install.yml @@ -0,0 +1,146 @@ +name: Install OneClickInstall DocSpace + +on: + pull_request: + types: [opened, reopened, synchronize] + paths: + - 'install/OneClickInstall/**' + + schedule: + - cron: '00 20 * * 6' # At 23:00 on Saturday. + + workflow_dispatch: + inputs: + centos7: + type: boolean + description: 'CentOS 7' + default: true + centos8s: + type: boolean + description: 'CentOS 8 Stream' + default: true + centos9s: + type: boolean + description: 'CentOS 9 Stream' + default: true + debian10: + type: boolean + description: 'Debian 10' + default: true + debian11: + type: boolean + description: 'Debian 11' + default: true + debian12: + type: boolean + description: 'Debian 12' + default: true + ubuntu1804: + type: boolean + description: 'Ubuntu 18.04' + default: true + ubuntu2004: + type: boolean + description: 'Ubuntu 20.04' + default: true + ubuntu2204: + type: boolean + description: 'Ubuntu 22.04' + default: true + +jobs: + prepare: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + + - name: Set matrix names + id: set-matrix + run: | + matrix=$(echo '{ + "include": [ + {"execute": '${{ github.event.inputs.centos7 || true }}', "name": "CentOS7", "os": "centos7", "distr": "generic"}, + {"execute": '${{ github.event.inputs.centos8s || true }}', "name": "CentOS8S", "os": "centos8s", "distr": "generic"}, + {"execute": '${{ github.event.inputs.centos9s || true }}', "name": "CentOS9S", "os": "centos9s", "distr": "generic"}, + {"execute": '${{ github.event.inputs.debian10 || true }}', "name": "Debian10", "os": "debian10", "distr": "generic"}, + {"execute": '${{ github.event.inputs.debian11 || true }}', "name": "Debian11", "os": "debian11", "distr": "generic"}, + {"execute": '${{ github.event.inputs.debian12 || true }}', "name": "Debian12", "os": "debian12", "distr": "generic"}, + {"execute": '${{ github.event.inputs.ubuntu1804 || true }}', "name": "Ubuntu18.04", "os": "ubuntu1804", "distr": "generic"}, + {"execute": '${{ github.event.inputs.ubuntu2004 || true }}', "name": "Ubuntu20.04", "os": "ubuntu2004", "distr": "generic"}, + {"execute": '${{ github.event.inputs.ubuntu2204 || true }}', "name": "Ubuntu22.04", "os": "ubuntu2204", "distr": "generic"} + ] + }' | jq -c '{include: [.include[] | select(.execute == true)]}') + echo "matrix=${matrix}" >> $GITHUB_OUTPUT + + vagrant-up: + name: "Test DocSpace with ${{ matrix.name}}" + runs-on: ubuntu-22.04 + needs: prepare + strategy: + fail-fast: false + matrix: ${{fromJSON(needs.prepare.outputs.matrix)}} + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python 3. + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Get update and install vagrant + run: | + set -eux + sudo apt update -y + sudo apt install vagrant virtualbox -y + + - name: "Test production scripts with ${{matrix.name}}" + if: ${{ github.event_name == 'schedule' }} + uses: nick-fields/retry@v2 + with: + max_attempts: 2 + timeout_minutes: 40 + retry_on: error + command: | + set -eux + cd tests/vagrant + TEST_CASE='--production-install' \ + DISTR='${{ matrix.distr }}' \ + OS='${{ matrix.os }}' \ + DOWNLOAD_SCRIPT='-ds true' \ + RAM='5100' \ + CPU='3' \ + ARGUMENTS="-arg '--skiphardwarecheck true --makeswap false'" \ + vagrant up + on_retry_command: | + echo "RUN CLEAN UP: Destroy vagrant and one more try" + cd tests/vagrant + sleep 10 + vagrant destroy --force + + - name: "Test Local scripts with ${{matrix.name}}" + if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} + uses: nick-fields/retry@v2 + with: + max_attempts: 2 + timeout_minutes: 40 + retry_on: error + command: | + set -eux + cd tests/vagrant + TEST_CASE='--local-install' \ + DISTR='${{ matrix.distr }}' \ + OS='${{matrix.os}}' \ + RAM='5100' \ + CPU='3' \ + DOWNLOAD_SCRIPT='-ds false' \ + TEST_REPO='-tr true' \ + ARGUMENTS="-arg '--skiphardwarecheck true --makeswap false --localscripts true'" \ + vagrant up + on_retry_command: | + echo "RUN CLEAN UP: Destroy vagrant and one more try" + cd tests/vagrant + sleep 10 + vagrant destroy --force diff --git a/tests/vagrant/Vagrantfile b/tests/vagrant/Vagrantfile new file mode 100644 index 0000000000..98c7b371e3 --- /dev/null +++ b/tests/vagrant/Vagrantfile @@ -0,0 +1,22 @@ +Vagrant.configure("2") do |config| + config.vm.box = "#{ENV['DISTR']}/#{ENV['OS']}" + + config.vm.provider "virtualbox" do |v| + v.customize ["modifyvm", :id, "--memory", "#{ENV['RAM']}"] #<= total RAM. + v.customize ["modifyvm", :id, "--cpus", "#{ENV['CPU']}"] #<= total CPU. + v.customize ["modifyvm", :id, "--ioapic", "on"] + end + + config.vm.define 'ubuntu' + + config.vm.hostname = "host4test" + + if ENV['TEST_CASE'] != '--production-install' + config.vm.provision "file", source: "../../../DocSpace-buildtools/install/OneClickInstall/.", destination: "/tmp/docspace/" + end + + config.vm.provision "shell", path: './install.sh', :args => "#{ENV['DOWNLOAD_SCRIPT']} #{ENV['TEST_REPO']} #{ENV['ARGUMENTS']}" + + # Prevent SharedFoldersEnableSymlinksCreate errors + config.vm.synced_folder ".", "/vagrant", disabled: true +end diff --git a/tests/vagrant/install.sh b/tests/vagrant/install.sh new file mode 100644 index 0000000000..c5d766f268 --- /dev/null +++ b/tests/vagrant/install.sh @@ -0,0 +1,357 @@ +#!/bin/bash + +set -e + +while [ "$1" != "" ]; do + case $1 in + + -ds | --download-scripts ) + if [ "$2" != "" ]; then + DOWNLOAD_SCRIPTS=$2 + shift + fi + ;; + + -arg | --arguments ) + if [ "$2" != "" ]; then + ARGUMENTS=$2 + shift + fi + ;; + + + -pi | --production-install ) + if [ "$2" != "" ]; then + PRODUCTION_INSTALL=$2 + shift + fi + ;; + + -li | --local-install ) + if [ "$2" != "" ]; then + LOCAL_INSTALL=$2 + shift + fi + ;; + + -lu | --local-update ) + if [ "$2" != "" ]; then + LOCAL_UPDATE=$2 + shift + fi + ;; + + -tr | --test-repo ) + if [ "$2" != "" ]; then + TEST_REPO_ENABLE=$2 + shift + fi + ;; + + + esac + shift +done + +export TERM=xterm-256color^M + +SERVICES_SYSTEMD=( + "docspace-api.service" + "docspace-doceditor.service" + "docspace-studio-notify.service" + "docspace-files.service" + "docspace-notify.service" + "docspace-studio.service" + "docspace-backup-background.service" + "docspace-files-services.service" + "docspace-people-server.service" + "docspace-backup.service" + "docspace-healthchecks.service" + "docspace-socket.service" + "docspace-clear-events.service" + "docspace-login.service" + "docspace-ssoauth.service" + "ds-converter.service" + "ds-docservice.service" + "ds-metrics.service") + +function common::get_colors() { + COLOR_BLUE=$'\e[34m' + COLOR_GREEN=$'\e[32m' + COLOR_RED=$'\e[31m' + COLOR_RESET=$'\e[0m' + COLOR_YELLOW=$'\e[33m' + export COLOR_BLUE + export COLOR_GREEN + export COLOR_RED + export COLOR_RESET + export COLOR_YELLOW +} + +############################################################################################# +# Checking available resources for a virtual machine +# Globals: +# None +# Arguments: +# None +# Outputs: +# None +############################################################################################# +function check_hw() { + local FREE_RAM=$(free -h) + local FREE_CPU=$(nproc) + echo "${COLOR_RED} ${FREE_RAM} ${COLOR_RESET}" + echo "${COLOR_RED} ${FREE_CPU} ${COLOR_RESET}" +} + + +############################################################################################# +# Prepare vagrant boxes like: set hostname/remove postfix for DEB distributions +# Globals: +# None +# Arguments: +# None +# Outputs: +# ☑ PREPAVE_VM: **** +############################################################################################# +function prepare_vm() { + + if [ -f /etc/lsb-release ] ; then + DIST=`cat /etc/lsb-release | grep '^DISTRIB_ID' | awk -F= '{ print $2 }'` + REV=`cat /etc/lsb-release | grep '^DISTRIB_RELEASE' | awk -F= '{ print $2 }'` + DISTRIB_CODENAME=`cat /etc/lsb-release | grep '^DISTRIB_CODENAME' | awk -F= '{ print $2 }'` + DISTRIB_RELEASE=`cat /etc/lsb-release | grep '^DISTRIB_RELEASE' | awk -F= '{ print $2 }'` + elif [ -f /etc/lsb_release ] || [ -f /usr/bin/lsb_release ] ; then + DIST=`lsb_release -a 2>&1 | grep 'Distributor ID:' | awk -F ":" '{print $2 }'` + REV=`lsb_release -a 2>&1 | grep 'Release:' | awk -F ":" '{print $2 }'` + DISTRIB_CODENAME=`lsb_release -a 2>&1 | grep 'Codename:' | awk -F ":" '{print $2 }'` + DISTRIB_RELEASE=`lsb_release -a 2>&1 | grep 'Release:' | awk -F ":" '{print $2 }'` + elif [ -f /etc/os-release ] ; then + DISTRIB_CODENAME=$(grep "VERSION=" /etc/os-release |awk -F= {' print $2'}|sed s/\"//g |sed s/[0-9]//g | sed s/\)$//g |sed s/\(//g | tr -d '[:space:]') + DISTRIB_RELEASE=$(grep "VERSION_ID=" /etc/os-release |awk -F= {' print $2'}|sed s/\"//g |sed s/[0-9]//g | sed s/\)$//g |sed s/\(//g | tr -d '[:space:]') + fi + + DIST=`echo "$DIST" | tr '[:upper:]' '[:lower:]' | xargs`; + DISTRIB_CODENAME=`echo "$DISTRIB_CODENAME" | tr '[:upper:]' '[:lower:]' | xargs`; + REV=`echo "$REV" | xargs`; + + if [ ! -f /etc/centos-release ]; then + if [ "${DIST}" = "debian" ]; then + if [ "${DISTRIB_CODENAME}" == "bookworm" ]; then + apt-get update -y + apt install -y curl gnupg + fi + + apt-get remove postfix -y + echo "${COLOR_GREEN}☑ PREPAVE_VM: Postfix was removed${COLOR_RESET}" + fi + + if [ "${TEST_REPO_ENABLE}" == 'true' ]; then + mkdir -p -m 700 $HOME/.gnupg + echo "deb [signed-by=/usr/share/keyrings/onlyoffice.gpg] https://nexus.onlyoffice.com/repository/4testing-debian stable main" | sudo tee /etc/apt/sources.list.d/onlyoffice4testing.list + curl -fsSL https://download.onlyoffice.com/GPG-KEY-ONLYOFFICE | gpg --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/onlyoffice.gpg --import + chmod 644 /usr/share/keyrings/onlyoffice.gpg + fi + fi + + if [ -f /etc/centos-release ]; then + if [ "${TEST_REPO_ENABLE}" == 'true' ]; then + cat > /etc/yum.repos.d/onlyoffice4testing.repo <