From 8940c0312a359a476e06d83d7839d21308d856d6 Mon Sep 17 00:00:00 2001 From: Sergey Kirichenko Date: Tue, 29 Mar 2022 15:39:54 +0300 Subject: [PATCH 1/3] Add feature for building images for different architecture (#600) * Fix config * del services, add migration env * Fix build * Fix sed * Fix * Delete commented code --- build/install/common/publish-backend.sh | 4 - build/install/docker/.env | 9 +- build/install/docker/Dockerfile.app | 54 ++------- build/install/docker/appserver.yml | 39 +----- build/install/docker/build.yml | 32 +---- .../docker/config/onlyoffice.upgradev110.sql | 112 ------------------ .../docker/config/onlyoffice.upgradev111.sql | 19 --- .../docker/config/onlyoffice.upgradev115.sql | 39 ------ build/install/docker/db.yml | 9 +- build/install/docker/docker-entrypoint.sh | 3 + 10 files changed, 19 insertions(+), 301 deletions(-) delete mode 100644 build/install/docker/config/onlyoffice.upgradev110.sql delete mode 100644 build/install/docker/config/onlyoffice.upgradev111.sql delete mode 100644 build/install/docker/config/onlyoffice.upgradev115.sql diff --git a/build/install/common/publish-backend.sh b/build/install/common/publish-backend.sh index 9e5dc9ccaf..64afc5cc7c 100644 --- a/build/install/common/publish-backend.sh +++ b/build/install/common/publish-backend.sh @@ -56,12 +56,8 @@ while [ "$1" != "" ]; do done # Array of names server in directory products -servers_products_name_backend=(ASC.CRM) servers_products_name_backend+=(ASC.Files) servers_products_name_backend+=(ASC.People) -servers_products_name_backend+=(ASC.Projects) -servers_products_name_backend+=(ASC.Calendar) -servers_products_name_backend+=(ASC.Mail) # Publish server backend products for i in ${!servers_products_name_backend[@]}; do diff --git a/build/install/docker/.env b/build/install/docker/.env index a826b52101..7f7c941349 100644 --- a/build/install/docker/.env +++ b/build/install/docker/.env @@ -44,20 +44,17 @@ MYSQL_USER=${PRODUCT}_user MYSQL_PASSWORD=${PRODUCT}_pass MYSQL_HOST=${CONTAINER_PREFIX}mysql-server + DATABASE_MIGRATION=false # service host # API_SYSTEM_HOST=${CONTAINER_PREFIX}api-system BACKUP_HOST=${CONTAINER_PREFIX}backup - CALENDAR_HOST=${CONTAINER_PREFIX}calendar - CRM_HOST=${CONTAINER_PREFIX}crm STORAGE_ENCRYPTION_HOST=${CONTAINER_PREFIX}storage-encryption FILES_HOST=${CONTAINER_PREFIX}files FILES_SERVICES_HOST=${CONTAINER_PREFIX}files-services - MAIL_HOST=${CONTAINER_PREFIX}mail STORAGE_MIGRATION_HOST=${CONTAINER_PREFIX}storage-migration NOTIFY_HOST=${CONTAINER_PREFIX}notify PEOPLE_SERVER_HOST=${CONTAINER_PREFIX}people-server - PROJECTS_SERVER_HOST=${CONTAINER_PREFIX}projects-server SOCKET_HOST=${CONTAINER_PREFIX}socket STUDIO_NOTIFY_HOST=${CONTAINER_PREFIX}studio-notify TELEGRAM_SERVICE_HOST=${CONTAINER_PREFIX}telegram-service @@ -71,16 +68,12 @@ # proxy upstream environment # SERVICE_API_SYSTEM=${API_SYSTEM_HOST}:${SERVICE_PORT} SERVICE_BACKUP=${BACKUP_HOST}:${SERVICE_PORT} - SERVICE_CRM=${CRM_HOST}:${SERVICE_PORT} - SERVICE_CALENDAR=${CALENDAR_HOST}:${SERVICE_PORT} SERVICE_STORAGE_ENCRYPTION=${STORAGE_ENCRYPTION_HOST}:${SERVICE_PORT} SERVICE_FILES=${FILES_HOST}:${SERVICE_PORT} SERVICE_FILES_SERVICES=${FILES_SERVICES_HOST}:${SERVICE_PORT} - SERVICE_MAIL=${MAIL_HOST}:${SERVICE_PORT} SERVICE_STORAGE_MIGRATION=${STORAGE_MIGRATION_HOST}:${SERVICE_PORT} SERVICE_NOTIFY=${NOTIFY_HOST}:${SERVICE_PORT} SERVICE_PEOPLE_SERVER=${PEOPLE_SERVER_HOST}:${SERVICE_PORT} - SERVICE_PROJECTS_SERVER=${PROJECTS_SERVER_HOST}:${SERVICE_PORT} SERVICE_SOCKET=${SOCKET_HOST}:9899 SERVICE_STUDIO_NOTIFY=${STUDIO_NOTIFY_HOST}:${SERVICE_PORT} SERVICE_TELEGRAM_SERVICE=${TELEGRAM_SERVICE_HOST}:${SERVICE_PORT} diff --git a/build/install/docker/Dockerfile.app b/build/install/docker/Dockerfile.app index a1e976ef43..451a0fffdf 100644 --- a/build/install/docker/Dockerfile.app +++ b/build/install/docker/Dockerfile.app @@ -1,10 +1,12 @@ ### STAGE 1: Base image ###### ARG SRC_PATH=/app/onlyoffice/src ARG BUILD_PATH=/var/www -ARG REPO_TAG=5.0.202-focal-amd64 -ARG REPO=mcr.microsoft.com/dotnet/sdk +ARG REPO_SDK=mcr.microsoft.com/dotnet/sdk +ARG REPO_SDK_TAG=6.0 +ARG REPO_RUN=mcr.microsoft.com/dotnet/aspnet +ARG REPO_RUN_TAG=6.0 -FROM $REPO:$REPO_TAG AS base +FROM $REPO_SDK:$REPO_SDK_TAG AS base ARG RELEASE_DATE="2016-06-21" ARG DEBIAN_FRONTEND=noninteractive ARG PRODUCT_VERSION=0.0.0 @@ -67,7 +69,7 @@ COPY config/mysql/conf.d/mysql.cnf /etc/mysql/conf.d/mysql.cnf RUN rm -rf /var/lib/apt/lists/* ### STAGE 2: Build ### -FROM mcr.microsoft.com/dotnet/aspnet:5.0.4-focal-amd64 as builder +FROM $REPO_RUN:$REPO_RUN_TAG as builder ARG BUILD_PATH ENV BUILD_PATH=${BUILD_PATH} @@ -159,24 +161,6 @@ COPY --from=base --chown=onlyoffice:onlyoffice ${BUILD_PATH}/services/ASC.Data.B CMD ["ASC.Data.Backup.dll", "ASC.Data.Backup", "core:products:folder=/var/www/products/", "core:products:subfolder=server"] -## ASC.Calendar ## -FROM builder AS calendar -WORKDIR ${BUILD_PATH}/products/ASC.Calendar/server/ - -COPY --chown=onlyoffice:onlyoffice docker-entrypoint.sh . -COPY --from=base --chown=onlyoffice:onlyoffice ${BUILD_PATH}/products/ASC.Calendar/server/ . - -CMD ["ASC.Calendar.dll", "ASC.Calendar"] - -## ASC.CRM ## -FROM builder AS crm -WORKDIR ${BUILD_PATH}/products/ASC.CRM/server/ - -COPY --chown=onlyoffice:onlyoffice docker-entrypoint.sh . -COPY --from=base --chown=onlyoffice:onlyoffice ${BUILD_PATH}/products/ASC.CRM/server/ . - -CMD ["ASC.CRM.dll", "ASC.CRM"] - ## ASC.Data.Storage.Encryption ## FROM builder AS data_storage_encryption WORKDIR ${BUILD_PATH}/services/storage.encryption/ @@ -204,15 +188,6 @@ COPY --from=base --chown=onlyoffice:onlyoffice ${BUILD_PATH}/services/ASC.Files. CMD ["ASC.Files.Service.dll", "ASC.Files.Service", "core:products:folder=/var/www/products/", "core:products:subfolder=server", "disable_elastic=true"] -## ASC.Mail ## -FROM builder AS mail -WORKDIR ${BUILD_PATH}/products/ASC.Mail/server/ - -COPY --chown=onlyoffice:onlyoffice docker-entrypoint.sh . -COPY --from=base --chown=onlyoffice:onlyoffice ${BUILD_PATH}/products/ASC.Mail/server/ . - -CMD ["ASC.Mail.dll", "ASC.Mail"] - ## ASC.Data.Storage.Migration ## FROM builder AS data_storage_migration WORKDIR ${BUILD_PATH}/services/storage.migration/service/ @@ -240,15 +215,6 @@ COPY --from=base --chown=onlyoffice:onlyoffice ${BUILD_PATH}/products/ASC.People CMD ["ASC.People.dll", "ASC.People"] -## ASC.Projects ## -FROM builder AS projects_server -WORKDIR ${BUILD_PATH}/products/ASC.Projects/server/ - -COPY --chown=onlyoffice:onlyoffice docker-entrypoint.sh . -COPY --from=base --chown=onlyoffice:onlyoffice ${BUILD_PATH}/products/ASC.Projects/server/ . - -CMD ["ASC.Projects.dll", "ASC.Projects"] - ## ASC.Socket.IO.Svc ## FROM builder AS socket WORKDIR ${BUILD_PATH}/services/socket.io.svc/ @@ -339,10 +305,10 @@ RUN mkdir -p /app/appserver/ASC.Files/server && \ COPY bin-share-docker-entrypoint.sh /app/docker-entrypoint.sh COPY --from=base /var/www/products/ASC.Files/server/ /app/appserver/ASC.Files/server/ COPY --from=base /var/www/products/ASC.People/server/ /app/appserver/ASC.People/server/ -COPY --from=base /var/www/products/ASC.CRM/server/ /app/appserver/ASC.CRM/server/ -COPY --from=base /var/www/products/ASC.Projects/server/ /app/appserver/ASC.Projects/server/ -COPY --from=base /var/www/products/ASC.Calendar/server/ /app/appserver/ASC.Calendar/server/ -COPY --from=base /var/www/products/ASC.Mail/server/ /app/appserver/ASC.Mail/server/ +# COPY --from=base /var/www/products/ASC.CRM/server/ /app/appserver/ASC.CRM/server/ +# COPY --from=base /var/www/products/ASC.Projects/server/ /app/appserver/ASC.Projects/server/ +# COPY --from=base /var/www/products/ASC.Calendar/server/ /app/appserver/ASC.Calendar/server/ +# COPY --from=base /var/www/products/ASC.Mail/server/ /app/appserver/ASC.Mail/server/ ENTRYPOINT ["./app/docker-entrypoint.sh"] ## image for k8s wait-bin-share ## diff --git a/build/install/docker/appserver.yml b/build/install/docker/appserver.yml index d2ef54a492..172e407351 100644 --- a/build/install/docker/appserver.yml +++ b/build/install/docker/appserver.yml @@ -1,4 +1,4 @@ -version: "3.6" +version: "3.8" x-service: &x-service-base container_name: base @@ -11,6 +11,7 @@ x-service: MYSQL_DATABASE: ${MYSQL_DATABASE} MYSQL_USER: ${MYSQL_USER} MYSQL_PASSWORD: ${MYSQL_PASSWORD} + DATABASE_MIGRATION: ${DATABASE_MIGRATION} APP_DOTNET_ENV: ${APP_DOTNET_ENV} APP_CORE_BASE_DOMAIN: ${APP_CORE_BASE_DOMAIN} APP_CORE_MACHINEKEY: ${APP_CORE_MACHINEKEY} @@ -26,10 +27,6 @@ x-service: - app_data:/app/onlyoffice/data - files_data:/var/www/products/ASC.Files/server/ - people_data:/var/www/products/ASC.People/server/ - - crm_data:/var/www/products/ASC.CRM/server/ - - project_data:/var/www/products/ASC.Projects/server/ - - calendar_data:/var/www/products/ASC.Calendar/server/ - - mail_data:/var/www/products/ASC.Mail/server/ services: onlyoffice-elasticsearch: @@ -63,16 +60,6 @@ services: image: "${REPO}/${STATUS}appserver-backup:${DOCKER_TAG}" container_name: ${BACKUP_HOST} - onlyoffice-calendar: - <<: *x-service-base - image: "${REPO}/${STATUS}appserver-calendar:${DOCKER_TAG}" - container_name: ${CALENDAR_HOST} - - onlyoffice-crm: - <<: *x-service-base - image: "${REPO}/${STATUS}appserver-crm:${DOCKER_TAG}" - container_name: ${CRM_HOST} - onlyoffice-storage-encryption: <<: *x-service-base image: "${REPO}/${STATUS}appserver-storage-encryption:${DOCKER_TAG}" @@ -88,11 +75,6 @@ services: image: "${REPO}/${STATUS}appserver-files-services:${DOCKER_TAG}" container_name: ${FILES_SERVICES_HOST} - onlyoffice-mail: - <<: *x-service-base - image: "${REPO}/${STATUS}appserver-mail:${DOCKER_TAG}" - container_name: ${MAIL_HOST} - onlyoffice-storage-migration: <<: *x-service-base image: "${REPO}/${STATUS}appserver-storage-migration:${DOCKER_TAG}" @@ -103,11 +85,6 @@ services: image: "${REPO}/${STATUS}appserver-people-server:${DOCKER_TAG}" container_name: ${PEOPLE_SERVER_HOST} - onlyoffice-projects-server: - <<: *x-service-base - image: "${REPO}/${STATUS}appserver-projects-server:${DOCKER_TAG}" - container_name: ${PROJECTS_SERVER_HOST} - onlyoffice-socket: <<: *x-service-base image: "${REPO}/${STATUS}appserver-socket:${DOCKER_TAG}" @@ -173,15 +150,11 @@ services: depends_on: - onlyoffice-api-system - onlyoffice-backup - - onlyoffice-calendar - - onlyoffice-crm - onlyoffice-storage-encryption - onlyoffice-files - onlyoffice-files-services - - onlyoffice-mail - onlyoffice-storage-migration - onlyoffice-people-server - - onlyoffice-projects-server - onlyoffice-socket - onlyoffice-studio-notify - onlyoffice-telegram-service @@ -193,16 +166,12 @@ services: environment: - SERVICE_API_SYSTEM=${SERVICE_API_SYSTEM} - SERVICE_BACKUP=${SERVICE_BACKUP} - - SERVICE_CALENDAR=${SERVICE_CALENDAR} - - SERVICE_CRM=${SERVICE_CRM} - SERVICE_STORAGE_ENCRYPTION=${SERVICE_STORAGE_ENCRYPTION} - SERVICE_FILES=${SERVICE_FILES} - SERVICE_FILES_SERVICES=${SERVICE_FILES_SERVICES} - - SERVICE_MAIL=${SERVICE_MAIL} - SERVICE_STORAGE_MIGRATION=${SERVICE_STORAGE_MIGRATION} - SERVICE_NOTIFY=${SERVICE_NOTIFY} - SERVICE_PEOPLE_SERVER=${SERVICE_PEOPLE_SERVER} - - SERVICE_PROJECTS_SERVER=${SERVICE_PROJECTS_SERVER} - SERVICE_SOCKET=${SERVICE_SOCKET} - SERVICE_STUDIO_NOTIFY=${SERVICE_STUDIO_NOTIFY} - SERVICE_TELEGRAM_SERVICE=${SERVICE_TELEGRAM_SERVICE} @@ -227,7 +196,3 @@ volumes: app_data: files_data: people_data: - crm_data: - project_data: - calendar_data: - mail_data: diff --git a/build/install/docker/build.yml b/build/install/docker/build.yml index 444d3a49ea..9f8862841d 100644 --- a/build/install/docker/build.yml +++ b/build/install/docker/build.yml @@ -1,4 +1,4 @@ -version: "3.6" +version: "3.8" services: onlyoffice-api-system: @@ -14,21 +14,7 @@ services: dockerfile: "${DOCKERFILE}" target: backup image: "${REPO}/${STATUS}appserver-backup:${DOCKER_TAG}" - - onlyoffice-calendar: - build: - context: ./ - dockerfile: "${DOCKERFILE}" - target: calendar - image: "${REPO}/${STATUS}appserver-calendar:${DOCKER_TAG}" - - onlyoffice-crm: - build: - context: ./ - dockerfile: "${DOCKERFILE}" - target: crm - image: "${REPO}/${STATUS}appserver-crm:${DOCKER_TAG}" - + onlyoffice-storage-encryption: build: context: ./ @@ -50,13 +36,6 @@ services: target: files_services image: "${REPO}/${STATUS}appserver-files-services:${DOCKER_TAG}" - onlyoffice-mail: - build: - context: ./ - dockerfile: "${DOCKERFILE}" - target: mail - image: "${REPO}/${STATUS}appserver-mail:${DOCKER_TAG}" - onlyoffice-storage-migration: build: context: ./ @@ -77,13 +56,6 @@ services: dockerfile: "${DOCKERFILE}" target: people_server image: "${REPO}/${STATUS}appserver-people-server:${DOCKER_TAG}" - - onlyoffice-projects-server: - build: - context: ./ - dockerfile: "${DOCKERFILE}" - target: projects_server - image: "${REPO}/${STATUS}appserver-projects-server:${DOCKER_TAG}" onlyoffice-socket: build: diff --git a/build/install/docker/config/onlyoffice.upgradev110.sql b/build/install/docker/config/onlyoffice.upgradev110.sql deleted file mode 100644 index d6b610266f..0000000000 --- a/build/install/docker/config/onlyoffice.upgradev110.sql +++ /dev/null @@ -1,112 +0,0 @@ -DELIMITER DLM00 - -DROP PROCEDURE IF EXISTS upgrade110 DLM00 - -CREATE PROCEDURE upgrade110() -BEGIN - - IF (SELECT DATA_TYPE FROM information_schema.`COLUMNS` WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'crm_invoice_item' AND COLUMN_NAME = 'quantity') <> 'decimal' THEN - ALTER TABLE `crm_invoice_item` CHANGE COLUMN `quantity` `quantity` DECIMAL(10,2) NOT NULL DEFAULT '0.00' AFTER `price`; - END IF; - - IF (SELECT DATA_TYPE FROM information_schema.`COLUMNS` WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'crm_invoice_item' AND COLUMN_NAME = 'stock_quantity') <> 'decimal' THEN - ALTER TABLE `crm_invoice_item` CHANGE COLUMN `stock_quantity` `stock_quantity` DECIMAL(10,2) NOT NULL DEFAULT '0.00' AFTER `quantity`; - END IF; - - IF (SELECT DATA_TYPE FROM information_schema.`COLUMNS` WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'crm_invoice_line' AND COLUMN_NAME = 'quantity') <> 'decimal' THEN - ALTER TABLE `crm_invoice_line` CHANGE COLUMN `quantity` `quantity` DECIMAL(10,2) NOT NULL DEFAULT '0.00' AFTER `description`; - END IF; - - IF (SELECT DATA_TYPE FROM information_schema.`COLUMNS` WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'crm_invoice_line' AND COLUMN_NAME = 'discount') <> 'decimal' THEN - ALTER TABLE `crm_invoice_line` CHANGE COLUMN `discount` `discount` DECIMAL(10,2) NOT NULL DEFAULT '0.00' AFTER `price`; - END IF; - - IF EXISTS(SELECT * FROM information_schema.`COLUMNS` WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'crm_invoice_item' AND COLUMN_NAME = 'quantity') THEN - ALTER TABLE `crm_invoice_item` DROP COLUMN `quantity`; - END IF; - - IF NOT EXISTS(SELECT * FROM information_schema.`COLUMNS` WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'notify_queue' AND COLUMN_NAME = 'auto_submitted') THEN - ALTER TABLE `notify_queue` ADD COLUMN `auto_submitted` VARCHAR(64) NULL DEFAULT NULL AFTER `attachments`; - END IF; - - IF NOT EXISTS(SELECT * FROM information_schema.`COLUMNS` WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'core_usersecurity' AND COLUMN_NAME = 'LastModified') THEN - ALTER TABLE `core_usersecurity` ADD COLUMN `LastModified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP() ON UPDATE CURRENT_TIMESTAMP() AFTER `pwdhashsha512`; - END IF; - - UPDATE `tenants_quota` SET `features` = 'domain,audit,controlpanel,healthcheck,ldap,sso,whitelabel,branding,ssbranding,update,support,portals:10000,discencryption,privacyroom' WHERE `tenant` = -1 and `name` NOT LIKE '%saas%'; - UPDATE `tenants_quota` SET `features` = 'docs,domain,audit,controlpanel,healthcheck,ldap,sso,whitelabel,branding,ssbranding,update,support,portals:10000,discencryption,privacyroom' WHERE tenant = -1000; - - CREATE TABLE IF NOT EXISTS `telegram_users` ( - `portal_user_id` VARCHAR(38) NOT NULL, - `tenant_id` INT(11) NOT NULL, - `telegram_user_id` INT(11) NOT NULL, - PRIMARY KEY (`tenant_id`, `portal_user_id`), - INDEX `tgId` (`telegram_user_id`) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - - UPDATE `res_data` - SET `textValue` = REPLACE(`textValue`, 'products/crm/default', 'Products/CRM/Default') - WHERE `fileid` = (SELECT `id` FROM `res_files` WHERE `resName` = 'CRMPatternResource.resx'); - - UPDATE `res_data` - SET `textValue` = REPLACE(`textValue`, 'products/crm/deals', 'Products/CRM/Deals') - WHERE `fileid` = (SELECT `id` FROM `res_files` WHERE `resName` = 'CRMPatternResource.resx'); - - UPDATE `res_data` - SET `textValue` = REPLACE(`textValue`, 'products/crm/tasks', 'Products/CRM/Tasks') - WHERE `fileid` = (SELECT `id` FROM `res_files` WHERE `resName` = 'CRMPatternResource.resx'); - - UPDATE `res_data` - SET `textValue` = REPLACE(`textValue`, 'products/crm', 'Products/CRM') - WHERE `fileid` = (SELECT `id` FROM `res_files` WHERE `resName` = 'CRMPatternResource.resx'); - - UPDATE `res_data` - SET `textValue` = REPLACE(`textValue`, 'products/projects/messages', 'Products/Projects/Messages') - WHERE `fileid` = (SELECT `id` FROM `res_files` WHERE `resName` = 'PatternResource.resx'); - - UPDATE `res_data` - SET `textValue` = REPLACE(`textValue`, 'products/projects/tasks', 'Products/Projects/Tasks') - WHERE `fileid` = (SELECT `id` FROM `res_files` WHERE `resName` = 'PatternResource.resx'); - - UPDATE `res_data` - SET `textValue` = REPLACE(`textValue`, 'products/projects/projects', 'Products/Projects/Projects') - WHERE `fileid` = (SELECT `id` FROM `res_files` WHERE `resName` = 'PatternResource.resx'); - - UPDATE `res_data` - SET `textValue` = REPLACE(`textValue`, 'products/projects/milestones', 'Products/Projects/Milestones') - WHERE `fileid` = (SELECT `id` FROM `res_files` WHERE `resName` = 'PatternResource.resx'); - - UPDATE `res_data` - SET `textValue` = REPLACE(`textValue`, 'products/projects', 'Products/Projects') - WHERE `fileid` = (SELECT `id` FROM `res_files` WHERE `resName` = 'PatternResource.resx'); - - UPDATE `res_data` - SET `textValue` = REPLACE(`textValue`, 'products/files', 'Products/Files') - WHERE `fileid` = (SELECT `id` FROM `res_files` WHERE `resName` = 'FilesPatternResource.resx'); - - UPDATE `res_data` - SET `textValue` = REPLACE(`textValue`, 'products/files', 'Products/Files') - WHERE `fileid` = (SELECT `id` FROM `res_files` WHERE `resName` = 'WebstudioNotifyPatternResource.resx'); - - UPDATE `res_data` - SET `textValue` = REPLACE(`textValue`, 'products/projects', 'Products/Projects') - WHERE `fileid` = (SELECT `id` FROM `res_files` WHERE `resName` = 'WebstudioNotifyPatternResource.resx'); - - UPDATE `res_data` - SET `textValue` = REPLACE(`textValue`, 'products/community', 'Products/Community') - WHERE `fileid` = (SELECT `id` FROM `res_files` WHERE `resName` = 'WebstudioNotifyPatternResource.resx'); - - UPDATE `res_data` - SET `textValue` = REPLACE(`textValue`, 'products/crm', 'Products/CRM') - WHERE `fileid` = (SELECT `id` FROM `res_files` WHERE `resName` = 'WebstudioNotifyPatternResource.resx'); - - UPDATE `core_settings` - SET `value`=0xF547048A4865171587D9CEBC8A496C601D96031F2C1C3E9160353942EE765DACD316F4B5F42892436FC4A21B9A6DF8FFD3BC4036B47E3A5A1B4C881B26609869FEBB6848BD88C02EEAC6A4CCB3E8F404290812F0E6E124A552BE81A58C64BB8BD3C9A8C0EDE1F9421281DE0C7AF82733A4BCE515E85694C4DDA78E22652BA2891FCE9578F97285A81E12FEDF5D6558611E3AA3E03EADDCAA98287C64A5510757A881B00C3345E6FC1E22B607CA2D753C63F1ED94C92366DBA0E4C2E6DB16F44A8AB091007AA7505D17E41530643C1FFAE822F8F99FD2E30C0DEF82DF65C43324507F3E5C68E4C5E22BE8A40C24423485 - WHERE `tenant`=-1 AND `id`='CompanyWhiteLabelSettings'; - -END DLM00 - -CALL upgrade110() DLM00 - -DELIMITER ; diff --git a/build/install/docker/config/onlyoffice.upgradev111.sql b/build/install/docker/config/onlyoffice.upgradev111.sql deleted file mode 100644 index 32931d2104..0000000000 --- a/build/install/docker/config/onlyoffice.upgradev111.sql +++ /dev/null @@ -1,19 +0,0 @@ -DELIMITER DLM00 - -DROP PROCEDURE IF EXISTS upgrade111 DLM00 - -CREATE PROCEDURE upgrade111() -BEGIN - - IF NOT EXISTS(SELECT * FROM information_schema.`COLUMNS` WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'files_file' AND COLUMN_NAME = 'thumb') THEN - ALTER TABLE `files_file` ADD COLUMN `thumb` INT(1) NOT NULL DEFAULT '0' AFTER `forcesave`; - END IF; - - ALTER TABLE `files_thirdparty_account` CHANGE COLUMN `password` `password` VARCHAR(512) NOT NULL AFTER `user_name`; - - -END DLM00 - -CALL upgrade111() DLM00 - -DELIMITER ; diff --git a/build/install/docker/config/onlyoffice.upgradev115.sql b/build/install/docker/config/onlyoffice.upgradev115.sql deleted file mode 100644 index 2b4a35e559..0000000000 --- a/build/install/docker/config/onlyoffice.upgradev115.sql +++ /dev/null @@ -1,39 +0,0 @@ -DELIMITER DLM00 - -DROP PROCEDURE IF EXISTS upgrade115 DLM00 - -CREATE PROCEDURE upgrade115() -BEGIN - - INSERT IGNORE INTO `files_converts` (`input`, `output`) VALUES ('.fb2', '.docx'); - INSERT IGNORE INTO `files_converts` (`input`, `output`) VALUES ('.fb2', '.odt'); - INSERT IGNORE INTO `files_converts` (`input`, `output`) VALUES ('.fb2', '.pdf'); - INSERT IGNORE INTO `files_converts` (`input`, `output`) VALUES ('.fb2', '.rtf'); - INSERT IGNORE INTO `files_converts` (`input`, `output`) VALUES ('.fb2', '.txt'); - - IF NOT EXISTS(SELECT * FROM information_schema.`COLUMNS` WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'calendar_events' AND COLUMN_NAME = 'time_zone') THEN - ALTER TABLE `calendar_events` ADD COLUMN `time_zone` VARCHAR(255) NULL DEFAULT NULL AFTER `status`; - END IF; - - IF NOT EXISTS(SELECT * FROM information_schema.`COLUMNS` WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'backup_backup' AND COLUMN_NAME = 'hash') THEN - ALTER TABLE `backup_backup` ADD COLUMN `hash` char(64) NOT NULL AFTER `storage_params`; - END IF; - - IF EXISTS(SELECT * FROM information_schema.`COLUMNS` WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'tenants_tariff' AND COLUMN_NAME = 'tariff_key') THEN - ALTER TABLE `tenants_tariff` DROP COLUMN `tariff_key`; - END IF; - - IF NOT EXISTS(SELECT * FROM information_schema.`COLUMNS` WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'tenants_tariff' AND COLUMN_NAME = 'quantity') THEN - ALTER TABLE `tenants_tariff` ADD COLUMN `quantity` int(10) NOT NULL DEFAULT 1 AFTER `stamp`; - END IF; - - INSERT IGNORE INTO `crm_currency_info` (`resource_key`, `abbreviation`, `symbol`, `culture_name`, `is_convertable`, `is_basic`) values ('Currency_MongolianTugrik', 'MNT', '₮', 'MN', 0, 0); - - UPDATE `tenants_quota` SET `features` = 'docs,domain,audit,controlpanel,healthcheck,ldap,sso,whitelabel,branding,ssbranding,update,support,portals:10000,discencryption,privacyroom,restore,contentsearch' WHERE tenant = -1000; - UPDATE `tenants_quota` SET `features` = 'domain,audit,controlpanel,healthcheck,ldap,sso,whitelabel,branding,ssbranding,update,support,portals:10000,discencryption,privacyroom,restore,contentsearch' WHERE `tenant` = -1 and `name` NOT LIKE '%saas%'; - -END DLM00 - -CALL upgrade115() DLM00 - -DELIMITER ; diff --git a/build/install/docker/db.yml b/build/install/docker/db.yml index 15dd9289f5..b17ca23295 100644 --- a/build/install/docker/db.yml +++ b/build/install/docker/db.yml @@ -1,4 +1,4 @@ -version: "3.6" +version: "3.8" services: @@ -22,13 +22,6 @@ services: volumes: - mysql_data:/var/lib/mysql - ./config/mysql/conf.d/:/etc/mysql/conf.d - - ./config/createdb.sql:/docker-entrypoint-initdb.d/01_createdb.sql - - ./config/onlyoffice.sql:/docker-entrypoint-initdb.d/02_onlyoffice.sql - - ./config/onlyoffice.data.sql:/docker-entrypoint-initdb.d/03_onlyoffice.data.sql - - ./config/onlyoffice.resources.sql:/docker-entrypoint-initdb.d/04_onlyoffice.resources.sql - - ./config/onlyoffice.upgradev110.sql:/docker-entrypoint-initdb.d/05_onlyoffice.upgradev110.sql - - ./config/onlyoffice.upgradev111.sql:/docker-entrypoint-initdb.d/06_onlyoffice.upgradev111.sql - - ./config/onlyoffice.upgradev115.sql:/docker-entrypoint-initdb.d/07_onlyoffice.upgradev115.sql networks: - ${NETWORK_NAME} tmpfs: /var/log/mysql/ diff --git a/build/install/docker/docker-entrypoint.sh b/build/install/docker/docker-entrypoint.sh index 3e6bcbb6f1..ffa6ff1e79 100755 --- a/build/install/docker/docker-entrypoint.sh +++ b/build/install/docker/docker-entrypoint.sh @@ -50,6 +50,8 @@ ELK_HOST=${ELK_HOST:-"${PRODUCT}-elasticsearch"} ELK_PORT=${ELK_PORT:-"9200"} ELK_THREADS=${ELK_THREADS:-"1"} +DATABASE_MIGRATION=${DATABASE_MIGRATION:-"false"} + KAFKA_HOST=${KAFKA_HOST:-"kafka"}":9092" APP_STORAGE_ROOT=${APP_STORAGE_ROOT:-"${BASE_DIR}/data/"} @@ -62,6 +64,7 @@ sed -i "s!\"internal\".*,!\"internal\": \"${DOCUMENT_SERVER_URL_INTERNAL}\",!g" sed -i "s!\"portal\".*!\"portal\": \"${APP_URL_PORTAL}\",!g" ${PATH_TO_CONF}/appsettings.${APP_DOTNET_ENV}.json sed -i "0,/\"value\"/s!\"value\".*,!\"value\": \"${DOCUMENT_SERVER_JWT_SECRET}\",!" ${PATH_TO_CONF}/appsettings.${APP_DOTNET_ENV}.json sed -i "s!\"header\".*!\"header\": \"${DOCUMENT_SERVER_JWT_HEADER}\"!" ${PATH_TO_CONF}/appsettings.${APP_DOTNET_ENV}.json +sed -i "s!\"core\".*{!\"migration\": {\n\"enabled\": \"${DATABASE_MIGRATION}\"\n},\n\"core\": {!g" ${PATH_TO_CONF}/appsettings.${APP_DOTNET_ENV}.json sed -i "s!\"Scheme\".*!\"Scheme\": \"${ELK_SHEME}\",!g" ${PATH_TO_CONF}/elastic.json sed -i "s!\"Host\".*!\"Host\": \"${ELK_HOST}\",!g" ${PATH_TO_CONF}/elastic.json From 83ba7b188223f72d5633a8dafd21e11c0ab19ff3 Mon Sep 17 00:00:00 2001 From: Eugene Kozyrev <67453079+EugeneKozyrev@users.noreply.github.com> Date: Fri, 1 Apr 2022 16:43:34 +0300 Subject: [PATCH 2/3] Add Windows installation files (#601) * Add installation files * Add DB migration * Add deleting publish directory and back files * Edit typo in DATABASE_MIGRATION property * Delete sql scripts downloading --- build/install/win/Apache Kafka.aip | 229 ++++++ build/install/win/Apache ZooKeeper.aip | 160 +++++ build/install/win/AppServer.aip | 676 ++++++++++++++++++ .../win/MySQL Server Installer Runner.iss | 16 + build/install/win/backend-build.bat | 31 + build/install/win/build-batch.bat | 77 ++ build/install/win/build-download-prereq.ps1 | 59 ++ build/install/win/frontend-build.bat | 13 + build/install/win/frontend-copy.bat | 26 + build/install/win/nginx.conf | 85 +++ build/install/win/publish-script.bat | 54 ++ build/install/win/tools/kafka.xml | 15 + build/install/win/tools/proxy.xml | 14 + build/install/win/tools/zookeeper.xml | 15 + build/install/win/utils.vbs | 479 +++++++++++++ 15 files changed, 1949 insertions(+) create mode 100644 build/install/win/Apache Kafka.aip create mode 100644 build/install/win/Apache ZooKeeper.aip create mode 100644 build/install/win/AppServer.aip create mode 100644 build/install/win/MySQL Server Installer Runner.iss create mode 100644 build/install/win/backend-build.bat create mode 100644 build/install/win/build-batch.bat create mode 100644 build/install/win/build-download-prereq.ps1 create mode 100644 build/install/win/frontend-build.bat create mode 100644 build/install/win/frontend-copy.bat create mode 100644 build/install/win/nginx.conf create mode 100644 build/install/win/publish-script.bat create mode 100644 build/install/win/tools/kafka.xml create mode 100644 build/install/win/tools/proxy.xml create mode 100644 build/install/win/tools/zookeeper.xml create mode 100644 build/install/win/utils.vbs diff --git a/build/install/win/Apache Kafka.aip b/build/install/win/Apache Kafka.aip new file mode 100644 index 0000000000..58d6315394 --- /dev/null +++ b/build/install/win/Apache Kafka.aip @@ -0,0 +1,229 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/install/win/Apache ZooKeeper.aip b/build/install/win/Apache ZooKeeper.aip new file mode 100644 index 0000000000..264faa65a4 --- /dev/null +++ b/build/install/win/Apache ZooKeeper.aip @@ -0,0 +1,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/install/win/AppServer.aip b/build/install/win/AppServer.aip new file mode 100644 index 0000000000..b6ff919de0 --- /dev/null +++ b/build/install/win/AppServer.aip @@ -0,0 +1,676 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/install/win/MySQL Server Installer Runner.iss b/build/install/win/MySQL Server Installer Runner.iss new file mode 100644 index 0000000000..91a3eabf93 --- /dev/null +++ b/build/install/win/MySQL Server Installer Runner.iss @@ -0,0 +1,16 @@ +[Setup] +AppName=MySQL Installer Runner +AppVersion=0.1.0 +AppCopyright= Ascensio System SIA 2019. All rights reserved +AppPublisher=Ascensio System SIA +AppPublisherURL=https://www.onlyoffice.com/ +VersionInfoVersion=0.1.0 +DefaultDirName={pf}\MySQL Installer Runner +DefaultGroupName=MySQL Installer Runner +CreateUninstallRegKey=no +Uninstallable=no +OutputBaseFilename="MySQL Installer Runner" +OutputDir=/ + +[Run] +Filename: "{pf}\MySQL\MySQL Installer for Windows\MySQLInstallerConsole.exe"; Parameters: "community install server;{param:MYSQL_VERSION|5.7.25};X64:*:servertype=Server;passwd={param:PASSWORD_PROP} -silent"; Flags: runhidden \ No newline at end of file diff --git a/build/install/win/backend-build.bat b/build/install/win/backend-build.bat new file mode 100644 index 0000000000..f30c9733ca --- /dev/null +++ b/build/install/win/backend-build.bat @@ -0,0 +1,31 @@ +@echo off +echo +echo ##################### +echo # build backend # +echo ##################### + +pushd %~1 + + call dotnet build ASC.Web.sln + + echo "== Build ASC.Thumbnails ==" + pushd common\ASC.Thumbnails + call yarn install --frozen-lockfile + popd + + echo "== Build ASC.UrlShortener ==" + pushd common\ASC.UrlShortener + call yarn install --frozen-lockfile + popd + + echo "== Build ASC.Socket.IO ==" + pushd common\ASC.Socket.IO + call yarn install --frozen-lockfile + popd + + echo "== Build ASC.SsoAuth ==" + pushd common\ASC.SsoAuth + call yarn install --frozen-lockfile + popd + +popd diff --git a/build/install/win/build-batch.bat b/build/install/win/build-batch.bat new file mode 100644 index 0000000000..e3bbbf6f2d --- /dev/null +++ b/build/install/win/build-batch.bat @@ -0,0 +1,77 @@ +REM echo ######## Extracting and preparing files to build ######## +%sevenzip% x build\install\win\nginx-1.21.1.zip -o"build\install\win\Files" -y +xcopy "build\install\win\Files\nginx-1.21.1" "build\install\win\Files\nginx" /s /y /b /i +rmdir build\install\win\Files\nginx-1.21.1 /s /q +rmdir build\install\win\kafka-zookeeper /s /q +md build\install\win\kafka-zookeeper +md build\install\win\Files\nginx\temp +md build\install\win\Files\nginx\logs +%tar% -xvf build\install\win\apache-zookeeper-3.7.0-bin.tar.gz -C build\install\win\kafka-zookeeper +%tar% -xvf build\install\win\kafka_2.12-2.8.0.tgz -C build\install\win\kafka-zookeeper +ren build\install\win\kafka-zookeeper\apache-zookeeper-3.7.0-bin zookeeper +ren build\install\win\kafka-zookeeper\kafka_2.12-2.8.0 kafka +md build\install\win\kafka-zookeeper\kafka\tools +md build\install\win\Files\tools +copy build\install\win\WinSW.NET4new.exe "build\install\win\kafka-zookeeper\kafka\tools\kafka.exe" /y +copy build\install\win\WinSW.NET4new.exe "build\install\win\kafka-zookeeper\kafka\tools\zookeeper.exe" /y +copy build\install\win\tools\zookeeper.xml "build\install\win\kafka-zookeeper\kafka\tools\zookeeper.xml" /y +copy build\install\win\tools\kafka.xml "build\install\win\kafka-zookeeper\kafka\tools\kafka.xml" /y +del /f /q build\install\win\apache-zookeeper-3.7.0-bin.* +del /f /q build\install\win\kafka_2.12-2.8.0.* +copy build\install\win\WinSW.NET4.exe "build\install\win\Files\tools\proxy.exe" /y +copy build\install\win\tools\proxy.xml "build\install\win\Files\tools\proxy.xml" /y +copy "build\install\win\nginx.conf" "build\install\win\Files\nginx\conf\nginx.conf" /y +copy "build\install\win\kafka-zookeeper\zookeeper\conf\zoo_sample.cfg" "build\install\win\kafka-zookeeper\zookeeper\conf\zoo.cfg" /y +del /f /q "build\install\win\kafka-zookeeper\zookeeper\conf\zoo_sample.cfg" +rmdir build\install\win\publish /s /q + +REM echo ######## Edit zookeeper/kafka cfg and proprties files ######## +%sed% -i "s/\(dataDir\).*/\1=.\/..\/zookeeper\/Data/g" build/install/win/kafka-zookeeper/zookeeper/conf/zoo.cfg +%sed% -i "s/\(log.dirs\)=.*/\1=kafka-logs/g" build/install/win/kafka-zookeeper/kafka/config/server.properties +%sed% -i "s/\(zookeeper.connect\)=.*/\1=localhost:2181/g" build/install/win/kafka-zookeeper/kafka/config/server.properties +%sed% -i "s/\(clientPort\)=.*/\1=2181/g" build/install/win/kafka-zookeeper/kafka/config/zookeeper.properties +%sed% -i "s/\(dataDir\).*/\1=.\/..\/zookeeper\/Data/g" build/install/win/kafka-zookeeper/kafka/config/zookeeper.properties +%sed% -i "s/\(bootstrap.servers\)=.*/\1=localhost:9092/g" build/install/win/kafka-zookeeper/kafka/config/consumer.properties +%sed% -i "s/\(bootstrap.servers\)=.*/\1=localhost:9092/g" build/install/win/kafka-zookeeper/kafka/config/connect-standalone.properties +%sed% -i "s/\(offset.storage.file.filename\)=.*/\1=kafka-offsets/g" build/install/win/kafka-zookeeper/kafka/config/connect-standalone.properties +%sed% -i "s/\(logger.kafka.controller\)=.*,/\1=INFO,/g" build/install/win/kafka-zookeeper/kafka/config/log4j.properties +%sed% -i "s/\(logger.state.change.logger\)=.*,/\1=INFO,/g" build/install/win/kafka-zookeeper/kafka/config/log4j.properties +echo log4j.logger.kafka.producer.async.DefaultEventHandler=INFO, kafkaAppender >> build/install/win/kafka-zookeeper/kafka/config/log4j.properties +echo exit /b 1 >> build/install/win/kafka-zookeeper/kafka/bin/windows/zookeeper-server-start.bat +echo exit /b 1 >> build/install/win/kafka-zookeeper/kafka/bin/windows/kafka-server-start.bat + +REM echo ######## Edit nginx conf files ######## +%sed% -i "s!#rewrite!rewrite!g" build/install/win/Files/nginx/conf/onlyoffice.conf +%sed% -i "s!/etc/nginx/includes!includes!g" build/install/win/Files/nginx/conf/onlyoffice.conf +%sed% -i "s!/var/www!..!g" build/install/win/Files/nginx/conf/onlyoffice-*.conf +%sed% -i "s!/var/www!..!g" build/install/win/Files/nginx/conf/includes/onlyoffice-*.conf + +REM echo ######## Edit json files ######## +%sed% -i "s!\(\"machinekey\":\).\".*\"!\1 \"1123askdasjklasbnd\"!g" build/install/win/Files/config/appsettings*.json +%sed% -i "s!\(\"folder\":\).\".*\"!\1 \"{APPDIRCONF}products\"!g" build/install/win/Files/config/appsettings*.json +%sed% -i "s!\(\"path\":\).\".*\"!\1 \"{APPDIRCONF}services\/ASC.Socket.IO\/service\"!g" build/install/win/Files/config/socket*.json +%sed% -i "s!\(\"path\":\).\".*\"!\1 \"{APPDIRCONF}services\/ASC.Thumbnails\/service\"!g" build/install/win/Files/config/thumb*.json +%sed% -i "s!\(\"path\":\).\".*\"!\1 \"{APPDIRCONF}services\/ASC.UrlShortener\/service\/index.js\"!g" build/install/win/Files/config/urlshortener*.json +%sed% -i "s!\(\"path\":\).\".*\"!\1 \"{APPDIRCONF}services\/ASC.SsoAuth\/service\"!g" build/install/win/Files/config/ssoauth*.json +%sed% -i "s!\(\"path\":\).\".*\"!\1 \"{APPDIRCONF}services\/ASC.UrlShortener\/service\/index.js\"!g" build/install/win/Files/config/appsettings.services.json +%sed% -i "s!\(\"log\":\).\".*\"!\1 \"{APPDIRCONF}Logs\/urlshortener.log\"!g" build/install/win/Files/config/appsettings.services.json + +REM echo ######## Delete temp files ######## +del /f /q build\install\win\Files\config\sed* +del /f /q build\install\win\Files\nginx\conf\sed* +del /f /q build\install\win\Files\nginx\conf\includes\sed* +del /f /q build\install\win\kafka-zookeeper\zookeeper\conf\sed* +del /f /q build\install\win\kafka-zookeeper\kafka\config\sed* +del /f /q build\install\win\*.back.* + +REM echo ######## Build kafka/zookeeper ######## +%AdvancedInstaller% /rebuild "build\install\win\Apache ZooKeeper.aip" +copy "build\install\win\publish\Apache ZooKeeper.msi" "build\install\win\Apache ZooKeeper.msi" /y +%AdvancedInstaller% /rebuild "build\install\win\Apache Kafka.aip" +copy "build\install\win\publish\Apache Kafka.msi" "build\install\win\Apache Kafka.msi" /y + +REM echo ######## Build MySQL Server Installer ######## +iscc "build\install\win\MySQL Server Installer Runner.iss" + +REM echo ######## Build AppServer package ######## +%AdvancedInstaller% /rebuild build\install\win\AppServer.aip diff --git a/build/install/win/build-download-prereq.ps1 b/build/install/win/build-download-prereq.ps1 new file mode 100644 index 0000000000..72938e97aa --- /dev/null +++ b/build/install/win/build-download-prereq.ps1 @@ -0,0 +1,59 @@ +$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12,Tls13' +[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols + +# Function 'DownloadComponents' downloads some components that need on build satge +# +# It gets two parameters list of maps and download path +# +# The map consists of: download_allways ($true/$false) - should this component should download every time +# name - name of the dowmloaded component +# link - component download link + +function DownloadComponents { + + param ( $prereq_list, $path ) + + ForEach ( $item in $prereq_list ) { + $url = $item.link + $output = $path + $item.name + + if( $item.download_allways ){ + [system.console]::WriteLine("Downloading $url") + Invoke-WebRequest -Uri $url -OutFile $output + } else { + if(![System.IO.File]::Exists($output)){ + [system.console]::WriteLine("Downloading $url") + Invoke-WebRequest -Uri $url -OutFile $output + } + } + } +} + +$path_prereq = "${pwd}\build\install\win\" + +$prerequisites = @( + @{ + download_allways = $false; + name = "nginx-1.21.1.zip"; + link = "https://nginx.org/download/nginx-1.21.1.zip"; + } + + @{ + download_allways = $false; + name = "apache-zookeeper-3.7.0-bin.tar.gz"; + link = "https://dlcdn.apache.org/zookeeper/zookeeper-3.7.0/apache-zookeeper-3.7.0-bin.tar.gz"; + } + @{ + download_allways = $false; + name = "kafka_2.12-2.8.0.tgz"; + link = "https://archive.apache.org/dist/kafka/2.8.0/kafka_2.12-2.8.0.tgz"; + } + + @{ + download_allways = $false; + name = "WinSW.NET4new.exe"; + link = "https://github.com/winsw/winsw/releases/download/v2.11.0/WinSW.NET4.exe"; + } +) + +DownloadComponents $prerequisites $path_prereq diff --git a/build/install/win/frontend-build.bat b/build/install/win/frontend-build.bat new file mode 100644 index 0000000000..5719cddbab --- /dev/null +++ b/build/install/win/frontend-build.bat @@ -0,0 +1,13 @@ +@echo off +echo +echo ###################### +echo # build frontend # +echo ###################### + +pushd %~1 + + call yarn install + call yarn build + call yarn deploy + +popd diff --git a/build/install/win/frontend-copy.bat b/build/install/win/frontend-copy.bat new file mode 100644 index 0000000000..4703698f89 --- /dev/null +++ b/build/install/win/frontend-copy.bat @@ -0,0 +1,26 @@ +@echo off +echo +echo ##################### +echo # frontend copy # +echo ##################### + +set FirstArg=%~s1 + +set SecondArg=%~s2 + +if defined SecondArg ( + set PathToRepository=%FirstArg% + set PathToAppFolder=%SecondArg% +) else ( + set PathToRepository=%FirstArg% + set PathToAppFolder=%FirstArg%\publish +) + +xcopy "%PathToRepository%\build\deploy\public" "%PathToAppFolder%\public" /s /y /b /i +xcopy "%PathToRepository%\build\deploy\studio\client" "%PathToAppFolder%\studio\client" /s /y /b /i +xcopy "%PathToRepository%\build\deploy\studio\login" "%PathToAppFolder%\studio\login" /s /y /b /i +xcopy "%PathToRepository%\build\deploy\products\ASC.Files\client" "%PathToAppFolder%\products\ASC.Files\client" /s /y /b /i +xcopy "%PathToRepository%\build\deploy\products\ASC.Files\editor" "%PathToAppFolder%\products\ASC.Files\editor" /s /y /b /i +xcopy "%PathToRepository%\build\deploy\products\ASC.People\client" "%PathToAppFolder%\products\ASC.People\client" /s /y /b /i +xcopy "%PathToRepository%\config\nginx" "%PathToAppFolder%\nginx\conf" /s /y /b /i +xcopy "%PathToRepository%\config\*" "%PathToAppFolder%\config" /y /b /i diff --git a/build/install/win/nginx.conf b/build/install/win/nginx.conf new file mode 100644 index 0000000000..e345859092 --- /dev/null +++ b/build/install/win/nginx.conf @@ -0,0 +1,85 @@ + +#user nobody; +worker_processes 1; + +#error_log logs/error.log; +#error_log logs/error.log notice; +#error_log logs/error.log info; + +#pid logs/nginx.pid; + + +events { + worker_connections 1024; +} + + + +http { + include mime.types; + default_type application/octet-stream; + + #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + # '$status $body_bytes_sent "$http_referer" ' + # '"$http_user_agent" "$http_x_forwarded_for"'; + + #access_log logs/access.log main; + + sendfile on; + #tcp_nopush on; + + #keepalive_timeout 0; + keepalive_timeout 65; + + #gzip on; + + server { + + set $public_root ../public; + listen 80; + server_name localhost; + + #charset koi8-r; + + #access_log logs/host.access.log main; + + location / { + root html; + index index.html index.htm; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } + } + + include onlyoffice.conf; + include onlyoffice-*.conf; + + # HTTPS server + # + #server { + # listen 443 ssl; + # server_name localhost; + + # ssl_certificate cert.pem; + # ssl_certificate_key cert.key; + + # ssl_session_cache shared:SSL:1m; + # ssl_session_timeout 5m; + + # ssl_ciphers HIGH:!aNULL:!MD5; + # ssl_prefer_server_ciphers on; + + # location / { + # root html; + # index index.html index.htm; + # } + #} + +} diff --git a/build/install/win/publish-script.bat b/build/install/win/publish-script.bat new file mode 100644 index 0000000000..462d4af518 --- /dev/null +++ b/build/install/win/publish-script.bat @@ -0,0 +1,54 @@ +@echo off +echo +echo ##################### +echo # publish backend # +echo ##################### + +set FirstArg=%~s1 + +set SecondArg=%~s2 + +if defined SecondArg ( + set PathToRepository=%FirstArg% + set PathToAppFolder=%SecondArg% +) else ( + set PathToRepository=%FirstArg% + set PathToAppFolder=%FirstArg%\publish +) + +rem publish in directory 'products' +REM dotnet publish "%PathToRepository%\products\ASC.Calendar\server\ASC.Calendar.csproj" -c Release --self-contained false -o "%PathToAppFolder%\products\ASC.Calendar\server" +REM dotnet publish "%PathToRepository%\products\ASC.CRM\server\ASC.CRM.csproj" -c Release --self-contained false -o "%PathToAppFolder%\products\ASC.CRM\server" +dotnet publish "%PathToRepository%\products\ASC.Files\server\ASC.Files.csproj" -c Release --self-contained false -o "%PathToAppFolder%\products\ASC.Files\server" +REM dotnet publish "%PathToRepository%\products\ASC.Mail\server\ASC.Mail.csproj" -c Release --self-contained false -o "%PathToAppFolder%\products\ASC.Mail\server" +dotnet publish "%PathToRepository%\products\ASC.People\server\ASC.People.csproj" -c Release --self-contained false -o "%PathToAppFolder%\products\ASC.People\server" +REM dotnet publish "%PathToRepository%\products\ASC.Projects\server\ASC.Projects.csproj" -c Release --self-contained false -o "%PathToAppFolder%\products\ASC.Projects\server" + +rem publish in directory 'services' +dotnet publish "%PathToRepository%\common\services\ASC.ApiSystem\ASC.ApiSystem.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.ApiSystem\service" +dotnet publish "%PathToRepository%\common\services\ASC.Data.Backup\ASC.Data.Backup.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.Data.Backup\service" +dotnet publish "%PathToRepository%\common\services\ASC.Data.Storage.Encryption\ASC.Data.Storage.Encryption.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.Data.Storage.Encryption\service" +dotnet publish "%PathToRepository%\products\ASC.Files\service\ASC.Files.Service.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.Files.Service\service" +dotnet publish "%PathToRepository%\common\services\ASC.Data.Storage.Migration\ASC.Data.Storage.Migration.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.Data.Storage.Migration\service" +dotnet publish "%PathToRepository%\common\services\ASC.Notify\ASC.Notify.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.Notify\service" +dotnet publish "%PathToRepository%\common\services\ASC.Socket.IO.Svc\ASC.Socket.IO.Svc.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.Socket.IO.Svc\service" +dotnet publish "%PathToRepository%\common\services\ASC.Studio.Notify\ASC.Studio.Notify.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.Studio.Notify\service" +dotnet publish "%PathToRepository%\common\services\ASC.TelegramService\ASC.TelegramService.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.TelegramService\service" +dotnet publish "%PathToRepository%\common\services\ASC.Thumbnails.Svc\ASC.Thumbnails.Svc.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.Thumbnails.Svc\service" +dotnet publish "%PathToRepository%\common\services\ASC.UrlShortener.Svc\ASC.UrlShortener.Svc.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.UrlShortener.Svc\service" +dotnet publish "%PathToRepository%\web\ASC.Web.Api\ASC.Web.Api.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.Web.Api\service" +dotnet publish "%PathToRepository%\web\ASC.Web.Studio\ASC.Web.Studio.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.Web.Studio\service" +dotnet publish "%PathToRepository%\common\services\ASC.SsoAuth.Svc\ASC.SsoAuth.Svc.csproj" -c Release --self-contained false -o "%PathToAppFolder%\services\ASC.SsoAuth.Svc\service" + +rem Publish backend services (Nodejs) +mkdir "%PathToAppFolder%\services\ASC.Thumbnails\service" +xcopy "%PathToRepository%\common\ASC.Thumbnails" "%PathToAppFolder%\services\ASC.Thumbnails\service" /s /y /b /i + +mkdir "%PathToAppFolder%\services\ASC.UrlShortener\service" +xcopy "%PathToRepository%\common\ASC.UrlShortener" "%PathToAppFolder%\services\ASC.UrlShortener\service" /s /y /b /i + +mkdir "%PathToAppFolder%\services\ASC.Socket.IO\service" +xcopy "%PathToRepository%\common\ASC.Socket.IO" "%PathToAppFolder%\services\ASC.Socket.IO\service" /s /y /b /i + +mkdir "%PathToAppFolder%\services\ASC.SsoAuth\service" +xcopy "%PathToRepository%\common\ASC.SsoAuth" "%PathToAppFolder%\services\ASC.SsoAuth\service" /s /y /b /i diff --git a/build/install/win/tools/kafka.xml b/build/install/win/tools/kafka.xml new file mode 100644 index 0000000000..5667b177a4 --- /dev/null +++ b/build/install/win/tools/kafka.xml @@ -0,0 +1,15 @@ + + kafka + kafka + This service runs kafka + RealTime + Automatic + + {WindowsVolume}Apache\kafka\bin\windows\kafka-server-start.bat + {WindowsVolume}Apache\kafka\config\server.properties + {WindowsVolume}Apache\kafka + + 10240 + 8 + + \ No newline at end of file diff --git a/build/install/win/tools/proxy.xml b/build/install/win/tools/proxy.xml new file mode 100644 index 0000000000..239991977a --- /dev/null +++ b/build/install/win/tools/proxy.xml @@ -0,0 +1,14 @@ + + proxy + proxy + Proxy service + RealTime + Automatic + + "{APPDIR}nginx\nginx.exe" + {APPDIR}nginx + + 10240 + 8 + + \ No newline at end of file diff --git a/build/install/win/tools/zookeeper.xml b/build/install/win/tools/zookeeper.xml new file mode 100644 index 0000000000..9a8d0a8f3d --- /dev/null +++ b/build/install/win/tools/zookeeper.xml @@ -0,0 +1,15 @@ + + zookeeper + zookeeper + This service runs zookeeper + RealTime + Automatic + + {WindowsVolume}Apache\kafka\bin\windows\zookeeper-server-start.bat + {WindowsVolume}Apache\kafka\config\zookeeper.properties + {WindowsVolume}Apache\kafka + + 10240 + 8 + + \ No newline at end of file diff --git a/build/install/win/utils.vbs b/build/install/win/utils.vbs new file mode 100644 index 0000000000..7f3954a4e7 --- /dev/null +++ b/build/install/win/utils.vbs @@ -0,0 +1,479 @@ +Function MySQLConfigure + On Error Resume Next + + Dim installed, service + + Const HKLM = &H80000002 + Set registry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") + registry.EnumKey HKLM, "SOFTWARE\ODBC\ODBCINST.INI", keys + If Not IsNull(keys) Then + For Each key In keys + If InStr(1, key, "MySQL ODBC", 1) <> 0 And InStr(1, key, "ANSI", 1) = 0 Then + mysqlDriver = key + End If + Next + End If + + If mysqlDriver = "" Then + registry.EnumKey HKLM, "SOFTWARE\WOW6432Node\ODBC\ODBCINST.INI", keys + If Not IsNull(keys) Then + For Each key In keys + If InStr(1, key, "MySQL ODBC", 1) <> 0 And InStr(1, key, "ANSI", 1) = 0 Then + mysqlDriver = key + End If + Next + End If + End If + + Session.Property("MYSQLODBCDRIVER") = mysqlDriver + + Set shell = CreateObject("WScript.Shell") + dbname = Session.Property("DATABASE_PROP") + dbpass = Session.Property("PASSWORD_PROP") + + Err.Clear + installDir = shell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\MySQL AB\MySQL Server 8.0\Location") + dataDir = shell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\MySQL AB\MySQL Server 8.0\DataLocation") + + Call WriteToLog("MySQLConfigure: installDir " & installDir) + Call WriteToLog("MySQLConfigure: dataDir " & dataDir) + + + If Err.Number <> 0 Then + Err.Clear + installDir = shell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\MySQL AB\MySQL Server 8.0\Location") + dataDir = shell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\MySQL AB\MySQL Server 8.0\DataLocation") + End If + + Call WriteToLog("MySQLConfigure: installDir " & installDir) + Call WriteToLog("MySQLConfigure: dataDir " & dataDir) + + + If Err.Number = 0 Then + Set wmiService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") + Set service = wmiService.Get("Win32_Service.Name='MySQL80'") + + If Err.Number <> 0 Then + WScript.Echo "MySQL80 service doesn't exists." + Wscript.Quit 1 + End If + + If service.Started Then + shell.Run """" & installDir & "bin\mysqladmin"" -u root password " & dbpass, 0, true + shell.Run """" & installDir & "bin\mysql"" -u root -p" & dbpass & " -e ""ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY " & "'" & dbpass & "';""", 0, true + End If + + Set filesys = CreateObject("Scripting.FileSystemObject") + + WriteIni filesys.BuildPath(dataDir, "my.ini"), "mysqld", "sql-mode", "NO_ENGINE_SUBSTITUTION" + WriteIni filesys.BuildPath(dataDir, "my.ini"), "mysqld", "max_connections", "1000" + WriteIni filesys.BuildPath(dataDir, "my.ini"), "mysqld", "max_allowed_packet", "1048576000" + WriteIni filesys.BuildPath(dataDir, "my.ini"), "mysqld", "group_concat_max_len", "2048" + WriteIni filesys.BuildPath(dataDir, "my.ini"), "mysqld", "character_set_server", "utf8" + WriteIni filesys.BuildPath(dataDir, "my.ini"), "mysqld", "collation_server", "utf8_general_ci" + WriteIni filesys.BuildPath(dataDir, "my.ini"), "mysqld", "default-authentication-plugin", "mysql_native_password" + + Call WriteToLog("MySQLConfigure: WriteIni Path" & filesys.BuildPath(dataDir, "my.ini")) + + End If +End Function + +Function WriteToLog(ByVal var) + + Const MsgType = &H04000000 + Set rec = Installer.CreateRecord(1) + + rec.StringData(1) = CStr(var) + Session.Message MsgType, rec + WriteToLog = 0 + +End Function + +Function ElasticSearchSetup + On Error Resume Next + + Dim ShellCommand + Dim APP_INDEX_DIR + + Const ForReading = 1 + Const ForWriting = 2 + + Set Shell = CreateObject("WScript.Shell") + Set objFSO = CreateObject("Scripting.FileSystemObject") + + APP_INDEX_DIR = Session.Property("APPDIR") & "Data\Index\v7.13.1\" + + If Not fso.FolderExists(APP_INDEX_DIR) Then + Session.Property("NEED_REINDEX_ELASTICSEARCH") = "TRUE" + End If + + Call Shell.Run("%COMSPEC% /c mkdir """ & Session.Property("APPDIR") & "Data\Index\v7.13.1\""",0,true) + Call Shell.Run("%COMSPEC% /c mkdir """ & Session.Property("APPDIR") & "Logs\""",0,true) + + Set objFile = objFSO.OpenTextFile(Session.Property("CommonAppDataFolder") & "Elastic\Elasticsearch\config\elasticsearch.yml", ForReading) + + fileContent = objFile.ReadAll + + objFile.Close + + Set oRE = New RegExp + oRE.Global = True + + If InStrRev(fileContent, "indices.fielddata.cache.size") = 0 Then + fileContent = fileContent & Chr(13) & Chr(10) & "indices.fielddata.cache.size: 30%" + Else + oRE.Pattern = "indices.fielddata.cache.size:.*" + fileContent = oRE.Replace(fileContent, "indices.fielddata.cache.size: 30%") + End if + + If InStrRev(fileContent, "indices.memory.index_buffer_size") = 0 Then + fileContent = fileContent & Chr(13) & Chr(10) & "indices.memory.index_buffer_size: 30%" + Else + oRE.Pattern = "indices.memory.index_buffer_size:.*" + fileContent = oRE.Replace(fileContent, "indices.memory.index_buffer_size: 30%") + End if + + If InStrRev(fileContent, "http.max_content_length") <> 0 Then + oRE.Pattern = "http.max_content_length:.*" + fileContent = oRE.Replace(fileContent, " ") + End if + + If InStrRev(fileContent, "thread_pool.index.queue_size") <> 0 Then + oRE.Pattern = "thread_pool.index.queue_size:.*" + fileContent = oRE.Replace(fileContent, " ") + End if + + If InStrRev(fileContent, "thread_pool.index.size") <> 0 Then + oRE.Pattern = "thread_pool.index.size:.*" + fileContent = oRE.Replace(fileContent, " ") + End if + + If InStrRev(fileContent, "thread_pool.write.queue_size") <> 0 Then + oRE.Pattern = "thread_pool.write.queue_size:.*" + fileContent = oRE.Replace(fileContent, " ") + End if + + If InStrRev(fileContent, "thread_pool.write.size") <> 0 Then + oRE.Pattern = "thread_pool.write.size:.*" + fileContent = oRE.Replace(fileContent, " ") + End if + + oRE.Pattern = "path.data:.*" + fileContent = oRE.Replace(fileContent, "path.data: " & Session.Property("APPDIR") & "Data\Index\v7.13.1\") + + oRE.Pattern = "path.logs:.*" + fileContent = oRE.Replace(fileContent, "path.logs: " & Session.Property("APPDIR") & "Logs\") + + Call WriteToLog("ElasticSearchSetup: New config:" & fileContent) + Call WriteToLog("ElasticSearchSetup: CommonAppDataFolder :" & Session.Property("CommonAppDataFolder") & "Elastic\Elasticsearch\data") + + Set objFile = objFSO.OpenTextFile(Session.Property("CommonAppDataFolder") & "Elastic\Elasticsearch\config\elasticsearch.yml", ForWriting) + + objFile.WriteLine fileContent + + objFile.Close + + Set objFile = objFSO.OpenTextFile(Session.Property("CommonAppDataFolder") & "Elastic\Elasticsearch\config\jvm.options", ForReading) + + fileContent = objFile.ReadAll + + objFile.Close + + If InStrRev(fileContent, "-XX:+HeapDumpOnOutOfMemoryError") <> 0 Then + oRE.Pattern = "-XX:+HeapDumpOnOutOfMemoryError" + fileContent = oRE.Replace(fileContent, " ") + End if + + If InStrRev(fileContent, "-Xms") <> 0 Then + oRE.Pattern = "-Xms.*" + fileContent = oRE.Replace(fileContent, "-Xms4g") + ElseIf InStrRev(fileContent, "-Xms4g") <> 0 Then + fileContent = fileContent & Chr(13) & Chr(10) & "-Xms4g" + End if + + If InStrRev(fileContent, "-Xmx") <> 0 Then + oRE.Pattern = "-Xmx.*" + fileContent = oRE.Replace(fileContent, "-Xmx4g") + ElseIf InStrRev(fileContent, "-Xmx4g") <> 0 Then + fileContent = fileContent & Chr(13) & Chr(10) & "-Xmx4g" + End if + + Set objFile = objFSO.OpenTextFile(Session.Property("CommonAppDataFolder") & "Elastic\Elasticsearch\config\jvm.options", ForWriting) + + objFile.WriteLine fileContent + + objFile.Close + + Set Shell = Nothing + +End Function + +Function ElasticSearchInstallPlugin + On Error Resume Next + + Dim Shell + + Set Shell = CreateObject("WScript.Shell") + + ShellInstallCommand = """C:\Program Files\Elastic\Elasticsearch\7.13.1\bin\elasticsearch-plugin""" & " install -b -s ingest-attachment""" + ShellRemoveCommand = """C:\Program Files\Elastic\Elasticsearch\7.13.1\bin\elasticsearch-plugin""" & " remove -s ingest-attachment""" + + Call Shell.Run("cmd /C " & """" & ShellRemoveCommand & """",0,true) + Call Shell.Run("cmd /C " & """" & ShellInstallCommand & """",0,true) + + Set Shell = Nothing + +End Function + +Function TestSqlConnection + On Error Resume Next + + Const HKLM = &H80000002 + Dim ErrorText + Dim Pos, keys, mysqlDriver + Dim registry + + TestSqlConnection = 0 + Session.Property("SqlConnectionError") = "" + + Set registry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") + registry.EnumKey HKLM, "SOFTWARE\ODBC\ODBCINST.INI", keys + If Not IsNull(keys) Then + For Each key In keys + If InStr(1, key, "MySQL ODBC", 1) <> 0 And InStr(1, key, "ANSI", 1) = 0 Then + mysqlDriver = key + End If + Next + End If + + If mysqlDriver = "" Then + registry.EnumKey HKLM, "SOFTWARE\WOW6432Node\ODBC\ODBCINST.INI", keys + If Not IsNull(keys) Then + For Each key In keys + If InStr(1, key, "MySQL ODBC", 1) <> 0 And InStr(1, key, "ANSI", 1) = 0 Then + mysqlDriver = key + End If + Next + End If + End If + + Session.Property("MYSQLODBCDRIVER") = mysqlDriver + + Set ConnectionObject = CreateObject("ADODB.Connection") + ConnectionObject.Open "Driver={" & mysqlDriver & "};Server=" & Session.Property("SERVER_PROP") & ";Port=" & Session.Property("PORT_PROP") & ";Uid=" & Session.Property("USERNAME_PROP") & ";Pwd=" & Session.Property("PASSWORD_PROP") + + If Err.Number <> 0 Then + ErrorText = Err.Description + Pos = InStrRev( ErrorText, "]" ) + If 0 < Pos Then + ErrorText = Right( ErrorText, Len( ErrorText ) - Pos ) + End If + Session.Property("SqlConnectionError") = ErrorText + End If + + Set ConnectionObject = Nothing +End Function + +Function ReadIni( myFilePath, mySection, myKey ) + ' This function returns a value read from an INI file + ' + ' Arguments: + ' myFilePath [string] the (path and) file name of the INI file + ' mySection [string] the section in the INI file to be searched + ' myKey [string] the key whose value is to be returned + ' + ' Returns: + ' the [string] value for the specified key in the specified section + ' + ' CAVEAT: Will return a space if key exists but value is blank + ' + ' Written by Keith Lacelle + ' Modified by Denis St-Pierre and Rob van der Woude + + Const ForReading = 1 + Const ForWriting = 2 + Const ForAppending = 8 + + Dim intEqualPos + Dim objFSO, objIniFile + Dim strFilePath, strKey, strLeftString, strLine, strSection + + Set objFSO = CreateObject( "Scripting.FileSystemObject" ) + + ReadIni = "" + strFilePath = Trim( myFilePath ) + strSection = Trim( mySection ) + strKey = Trim( myKey ) + + If objFSO.FileExists( strFilePath ) Then + Set objIniFile = objFSO.OpenTextFile( strFilePath, ForReading, False ) + Do While objIniFile.AtEndOfStream = False + strLine = Trim( objIniFile.ReadLine ) + + ' Check if section is found in the current line + If LCase( strLine ) = "[" & LCase( strSection ) & "]" Then + strLine = Trim( objIniFile.ReadLine ) + + ' Parse lines until the next section is reached + Do While Left( strLine, 1 ) <> "[" + ' Find position of equal sign in the line + intEqualPos = InStr( 1, strLine, "=", 1 ) + If intEqualPos > 0 Then + strLeftString = Trim( Left( strLine, intEqualPos - 1 ) ) + ' Check if item is found in the current line + If LCase( strLeftString ) = LCase( strKey ) Then + ReadIni = Trim( Mid( strLine, intEqualPos + 1 ) ) + ' In case the item exists but value is blank + If ReadIni = "" Then + ReadIni = " " + End If + ' Abort loop when item is found + Exit Do + End If + End If + + ' Abort if the end of the INI file is reached + If objIniFile.AtEndOfStream Then Exit Do + + ' Continue with next line + strLine = Trim( objIniFile.ReadLine ) + Loop + Exit Do + End If + Loop + objIniFile.Close + Else + WScript.Echo strFilePath & " doesn't exists. Exiting..." + Wscript.Quit 1 + End If +End Function + +Sub WriteIni( myFilePath, mySection, myKey, myValue ) + ' This subroutine writes a value to an INI file + ' + ' Arguments: + ' myFilePath [string] the (path and) file name of the INI file + ' mySection [string] the section in the INI file to be searched + ' myKey [string] the key whose value is to be written + ' myValue [string] the value to be written (myKey will be + ' deleted if myValue is ) + ' + ' Returns: + ' N/A + ' + ' CAVEAT: WriteIni function needs ReadIni function to run + ' + ' Written by Keith Lacelle + ' Modified by Denis St-Pierre, Johan Pol and Rob van der Woude + + Const ForReading = 1 + Const ForWriting = 2 + Const ForAppending = 8 + + Dim blnInSection, blnKeyExists, blnSectionExists, blnWritten + Dim intEqualPos + Dim objFSO, objNewIni, objOrgIni, wshShell + Dim strFilePath, strFolderPath, strKey, strLeftString + Dim strLine, strSection, strTempDir, strTempFile, strValue + + strFilePath = Trim( myFilePath ) + strSection = Trim( mySection ) + strKey = Trim( myKey ) + strValue = Trim( myValue ) + + Set objFSO = CreateObject( "Scripting.FileSystemObject" ) + Set wshShell = CreateObject( "WScript.Shell" ) + + strTempDir = wshShell.ExpandEnvironmentStrings( "%TEMP%" ) + strTempFile = objFSO.BuildPath( strTempDir, objFSO.GetTempName ) + + Set objOrgIni = objFSO.OpenTextFile( strFilePath, ForReading, True ) + Set objNewIni = objFSO.CreateTextFile( strTempFile, False, False ) + + blnInSection = False + blnSectionExists = False + ' Check if the specified key already exists + blnKeyExists = ( ReadIni( strFilePath, strSection, strKey ) <> "" ) + blnWritten = False + + ' Check if path to INI file exists, quit if not + strFolderPath = Mid( strFilePath, 1, InStrRev( strFilePath, "\" ) ) + If Not objFSO.FolderExists ( strFolderPath ) Then + WScript.Echo "Error: WriteIni failed, folder path (" _ + & strFolderPath & ") to ini file " _ + & strFilePath & " not found!" + Set objOrgIni = Nothing + Set objNewIni = Nothing + Set objFSO = Nothing + WScript.Quit 1 + End If + + While objOrgIni.AtEndOfStream = False + strLine = Trim( objOrgIni.ReadLine ) + If blnWritten = False Then + If LCase( strLine ) = "[" & LCase( strSection ) & "]" Then + blnSectionExists = True + blnInSection = True + ElseIf InStr( strLine, "[" ) = 1 Then + blnInSection = False + End If + End If + + If blnInSection Then + If blnKeyExists Then + intEqualPos = InStr( 1, strLine, "=", vbTextCompare ) + If intEqualPos > 0 Then + strLeftString = Trim( Left( strLine, intEqualPos - 1 ) ) + If LCase( strLeftString ) = LCase( strKey ) Then + ' Only write the key if the value isn't empty + ' Modification by Johan Pol + If strValue <> "" Then + objNewIni.WriteLine strKey & "=" & strValue + End If + blnWritten = True + blnInSection = False + End If + End If + If Not blnWritten Then + objNewIni.WriteLine strLine + End If + Else + objNewIni.WriteLine strLine + ' Only write the key if the value isn't empty + ' Modification by Johan Pol + If strValue <> "" Then + objNewIni.WriteLine strKey & "=" & strValue + End If + blnWritten = True + blnInSection = False + End If + Else + objNewIni.WriteLine strLine + End If + Wend + + If blnSectionExists = False Then ' section doesn't exist + objNewIni.WriteLine + objNewIni.WriteLine "[" & strSection & "]" + ' Only write the key if the value isn't empty + ' Modification by Johan Pol + If strValue <> "" Then + objNewIni.WriteLine strKey & "=" & strValue + End If + End If + + objOrgIni.Close + objNewIni.Close + + ' Delete old INI file + objFSO.DeleteFile strFilePath, True + ' Rename new INI file + objFSO.CopyFile strTempFile, strFilePath, True + + objFSO.DeleteFile strTempFile, True + + Set objOrgIni = Nothing + Set objNewIni = Nothing + Set objFSO = Nothing + Set wshShell = Nothing +End Sub From 49abfdf84a1b752d967b70d2d0a7480a60d4d637 Mon Sep 17 00:00:00 2001 From: pavelbannov Date: Tue, 5 Apr 2022 12:07:46 +0300 Subject: [PATCH 3/3] fix docxf templates --- products/ASC.Files/Server/ASC.Files.csproj | 174 ++++++++++++++++++++- 1 file changed, 168 insertions(+), 6 deletions(-) diff --git a/products/ASC.Files/Server/ASC.Files.csproj b/products/ASC.Files/Server/ASC.Files.csproj index ee4c730114..4f2c62bef6 100644 --- a/products/ASC.Files/Server/ASC.Files.csproj +++ b/products/ASC.Files/Server/ASC.Files.csproj @@ -32,9 +32,15 @@ Always + + Always + Always + + Always + Always @@ -50,9 +56,15 @@ Always + + Always + Always + + Always + Always @@ -68,9 +80,15 @@ Always + + Always + Always + + Always + Always @@ -86,9 +104,15 @@ Always + + Always + Always + + Always + Always @@ -104,9 +128,15 @@ Always + + Always + Always + + Always + Always @@ -122,9 +152,15 @@ Always + + Always + Always + + Always + Always @@ -140,9 +176,15 @@ Always + + Always + Always + + Always + Always @@ -158,9 +200,15 @@ Always + + Always + Always + + Always + Always @@ -176,9 +224,15 @@ Always + + Always + Always + + Always + Always @@ -194,9 +248,15 @@ Always + + Always + Always + + Always + Always @@ -212,9 +272,15 @@ Always + + Always + Always + + Always + Always @@ -230,9 +296,15 @@ Always + + Always + Always + + Always + Always @@ -248,9 +320,15 @@ Always + + Always + Always + + Always + Always @@ -266,9 +344,15 @@ Always + + Always + Always + + Always + Always @@ -284,9 +368,15 @@ Always + + Always + Always + + Always + Always @@ -302,9 +392,15 @@ Always + + Always + Always + + Always + Always @@ -320,9 +416,15 @@ Always + + Always + Always + + Always + Always @@ -338,9 +440,15 @@ Always + + Always + Always + + Always + Always @@ -356,9 +464,15 @@ Always + + Always + Always + + Always + Always @@ -374,9 +488,15 @@ Always + + Always + Always + + Always + Always @@ -389,12 +509,42 @@ Always + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + Always + + Always + Always + + Always + Always @@ -408,29 +558,41 @@ Always - PreserveNewest + Always + + + Always - PreserveNewest + Always + + + Always - PreserveNewest + Always - PreserveNewest + Always - PreserveNewest + Always - PreserveNewest + Always Always + + Always + Always + + Always + Always