From 7d1606bc9516f383f05691ff10083620876171a4 Mon Sep 17 00:00:00 2001 From: Semyon Bezrukov Date: Tue, 29 Oct 2019 12:42:43 +0300 Subject: [PATCH 1/4] Add support of MySQL DBMS (#188) * Add support of MySQL database --- .travis.yml | 44 ++++++++++++++ Dockerfile | 1 + README.md | 11 ++-- docker-compose.yml | 9 +-- run-document-server.sh | 97 ++++++++++++++++++++++-------- activemq.yml => tests/activemq.yml | 8 +-- tests/defaults.env | 40 ++++++++++++ tests/mysql.yml | 35 +++++++++++ tests/postgres-old.yml | 32 ++++++++++ tests/postgres.yml | 33 ++++++++++ tests/test.sh | 37 ++++++++++++ 11 files changed, 310 insertions(+), 37 deletions(-) create mode 100644 .travis.yml rename activemq.yml => tests/activemq.yml (75%) create mode 100644 tests/defaults.env create mode 100644 tests/mysql.yml create mode 100644 tests/postgres-old.yml create mode 100644 tests/postgres.yml create mode 100755 tests/test.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..5877421 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,44 @@ +language: generic + +dist: trusty + +env: + # postgresql + - config: postgres.yml + + # custom values + - config: postgres.yml + DB_NAME: mydb + DB_USER: myuser + DB_PWD: password + POSTGRES_DB: mydb + POSTGRES_USER: myuser + + # deprecated variables + - config: postgres-old.yml + POSTGRESQL_SERVER_HOST: onlyoffice-postgresql + POSTGRESQL_SERVER_PORT: 5432 + POSTGRESQL_SERVER_DB_NAME: onlyoffice + POSTGRESQL_SERVER_USER: onlyoffice + POSTGRESQL_SERVER_PASS: onlyoffice + + # mysql + - config: mysql.yml + DB_TYPE: mysql + DB_HOST: onlyoffice-mysql + DB_PORT: 3306 + + # activemq + - config: activemq.yml + AMQP_SERVER_TYPE: activemq + AMQP_SERVER_URL: amqp://guest:guest@onlyoffice-activemq + +services: + - docker + +script: + # Go to tests dir + - cd ${PWD}/tests + + # Run test. + - ./test.sh diff --git a/Dockerfile b/Dockerfile index 038c756..0c3fb85 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,6 +27,7 @@ RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d && \ libxml2 \ libxss1 \ libxtst6 \ + mysql-client \ nano \ net-tools \ netcat \ diff --git a/README.md b/README.md index c921efb..eec79bc 100644 --- a/README.md +++ b/README.md @@ -162,11 +162,12 @@ Below is the complete list of parameters that can be set using environment varia - **SSL_KEY_PATH**: The path to the SSL certificate's private key. Defaults to `/var/www/onlyoffice/Data/certs/onlyoffice.key`. - **SSL_DHPARAM_PATH**: The path to the Diffie-Hellman parameter. Defaults to `/var/www/onlyoffice/Data/certs/dhparam.pem`. - **SSL_VERIFY_CLIENT**: Enable verification of client certificates using the `CA_CERTIFICATES_PATH` file. Defaults to `false` -- **POSTGRESQL_SERVER_HOST**: The IP address or the name of the host where the PostgreSQL server is running. -- **POSTGRESQL_SERVER_PORT**: The PostgreSQL server port number. -- **POSTGRESQL_SERVER_DB_NAME**: The name of a PostgreSQL database to be created on the image startup. -- **POSTGRESQL_SERVER_USER**: The new user name with superuser permissions for the PostgreSQL account. -- **POSTGRESQL_SERVER_PASS**: The password set for the PostgreSQL account. +- **DB_TYPE**: The database type. Supported values are `postgres`, `mariadb` or `mysql`. Defaults to `postgres`. +- **DB_HOST**: The IP address or the name of the host where the database server is running. +- **DB_PORT**: The database server port number. +- **DB_NAME**: The name of a database to be created on the image startup. +- **DB_USER**: The new user name with superuser permissions for the database account. +- **DB_PWD**: The password set for the database account. - **AMQP_SERVER_URL**: The [AMQP URL](http://www.rabbitmq.com/uri-spec.html "RabbitMQ URI Specification") to connect to message broker server. - **AMQP_SERVER_TYPE**: The message broker type. Supported values are `rabbitmq` or `activemq`. Defaults to `rabbitmq`. - **REDIS_SERVER_HOST**: The IP address or the name of the host where the Redis server is running. diff --git a/docker-compose.yml b/docker-compose.yml index 0cc4cf8..3df7230 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,10 +5,11 @@ services: image: onlyoffice/documentserver:latest environment: - ONLYOFFICE_DATA_CONTAINER=true - - POSTGRESQL_SERVER_HOST=onlyoffice-postgresql - - POSTGRESQL_SERVER_PORT=5432 - - POSTGRESQL_SERVER_DB_NAME=onlyoffice - - POSTGRESQL_SERVER_USER=onlyoffice + - DB_TYPE=postgres + - DB_HOST=onlyoffice-postgresql + - DB_PORT=5432 + - DB_NAME=onlyoffice + - DB_USER=onlyoffice - AMQP_SERVER_URL=amqp://guest:guest@onlyoffice-rabbitmq - REDIS_SERVER_HOST=onlyoffice-redis - REDIS_SERVER_PORT=6379 diff --git a/run-document-server.sh b/run-document-server.sh index c46c6b0..3e3bb2b 100755 --- a/run-document-server.sh +++ b/run-document-server.sh @@ -57,11 +57,32 @@ PGDATA=${PG_ROOT}/${PG_VERSION}/${PG_NAME} PG_NEW_CLUSTER=false read_setting(){ - POSTGRESQL_SERVER_HOST=${POSTGRESQL_SERVER_HOST:-$(${JSON} services.CoAuthoring.sql.dbHost)} - POSTGRESQL_SERVER_PORT=${POSTGRESQL_SERVER_PORT:-5432} - POSTGRESQL_SERVER_DB_NAME=${POSTGRESQL_SERVER_DB_NAME:-$(${JSON} services.CoAuthoring.sql.dbName)} - POSTGRESQL_SERVER_USER=${POSTGRESQL_SERVER_USER:-$(${JSON} services.CoAuthoring.sql.dbUser)} - POSTGRESQL_SERVER_PASS=${POSTGRESQL_SERVER_PASS:-$(${JSON} services.CoAuthoring.sql.dbPass)} + deprecated_var POSTGRESQL_SERVER_HOST DB_HOST + deprecated_var POSTGRESQL_SERVER_PORT DB_PORT + deprecated_var POSTGRESQL_SERVER_DB_NAME DB_NAME + deprecated_var POSTGRESQL_SERVER_USER DB_USER + deprecated_var POSTGRESQL_SERVER_PASS DB_PWD + + DB_HOST=${DB_HOST:-${POSTGRESQL_SERVER_HOST:-$(${JSON} services.CoAuthoring.sql.dbHost)}} + case $DB_TYPE in + "postgres") + DB_PORT=${DB_PORT:-"5432"} + ;; + "mariadb"|"mysql") + DB_PORT=${DB_PORT:-"3306"} + ;; + "") + DB_PORT=${DB_PORT:-${POSTGRESQL_SERVER_PORT:-$(${JSON} services.CoAuthoring.sql.dbPort)}} + ;; + *) + echo "ERROR: unknown database type" + exit 1 + ;; + esac + DB_NAME=${DB_NAME:-${POSTGRESQL_SERVER_DB_NAME:-$(${JSON} services.CoAuthoring.sql.dbName)}} + DB_USER=${DB_USER:-${POSTGRESQL_SERVER_USER:-$(${JSON} services.CoAuthoring.sql.dbUser)}} + DB_PWD=${DB_PWD:-${POSTGRESQL_SERVER_PASS:-$(${JSON} services.CoAuthoring.sql.dbPass)}} + DB_TYPE=${DB_TYPE:-$(${JSON} services.CoAuthoring.sql.type)} RABBITMQ_SERVER_URL=${RABBITMQ_SERVER_URL:-$(${JSON} rabbitmq.url)} AMQP_SERVER_URL=${AMQP_SERVER_URL:-${RABBITMQ_SERVER_URL}} @@ -74,6 +95,12 @@ read_setting(){ DS_LOG_LEVEL=${DS_LOG_LEVEL:-$(${JSON_LOG} categories.default.level)} } +deprecated_var() { + if [[ -n ${!1} ]]; then + echo "Variable $1 is deprecated. Use $2 instead." + fi +} + parse_rabbitmq_url(){ local amqp=$1 @@ -123,8 +150,8 @@ waiting_for_connection(){ done } -waiting_for_postgresql(){ - waiting_for_connection ${POSTGRESQL_SERVER_HOST} ${POSTGRESQL_SERVER_PORT} +waiting_for_db(){ + waiting_for_connection $DB_HOST $DB_PORT } waiting_for_amqp(){ @@ -137,12 +164,13 @@ waiting_for_redis(){ waiting_for_datacontainer(){ waiting_for_connection ${ONLYOFFICE_DATA_CONTAINER_HOST} ${ONLYOFFICE_DATA_CONTAINER_PORT} } -update_postgresql_settings(){ - ${JSON} -I -e "this.services.CoAuthoring.sql.dbHost = '${POSTGRESQL_SERVER_HOST}'" - ${JSON} -I -e "this.services.CoAuthoring.sql.dbPort = '${POSTGRESQL_SERVER_PORT}'" - ${JSON} -I -e "this.services.CoAuthoring.sql.dbName = '${POSTGRESQL_SERVER_DB_NAME}'" - ${JSON} -I -e "this.services.CoAuthoring.sql.dbUser = '${POSTGRESQL_SERVER_USER}'" - ${JSON} -I -e "this.services.CoAuthoring.sql.dbPass = '${POSTGRESQL_SERVER_PASS}'" +update_db_settings(){ + ${JSON} -I -e "this.services.CoAuthoring.sql.type = '${DB_TYPE}'" + ${JSON} -I -e "this.services.CoAuthoring.sql.dbHost = '${DB_HOST}'" + ${JSON} -I -e "this.services.CoAuthoring.sql.dbPort = '${DB_PORT}'" + ${JSON} -I -e "this.services.CoAuthoring.sql.dbName = '${DB_NAME}'" + ${JSON} -I -e "this.services.CoAuthoring.sql.dbUser = '${DB_USER}'" + ${JSON} -I -e "this.services.CoAuthoring.sql.dbPass = '${DB_PWD}'" } update_rabbitmq_setting(){ @@ -232,10 +260,21 @@ create_postgresql_db(){ sudo -u postgres psql -c "GRANT ALL privileges ON DATABASE onlyoffice TO onlyoffice;" } -create_postgresql_tbl(){ - CONNECTION_PARAMS="-h${POSTGRESQL_SERVER_HOST} -p${POSTGRESQL_SERVER_PORT} -U${POSTGRESQL_SERVER_USER} -w" - if [ -n "${POSTGRESQL_SERVER_PASS}" ]; then - export PGPASSWORD=${POSTGRESQL_SERVER_PASS} +create_db_tbl() { + case $DB_TYPE in + "postgres") + create_postgresql_tbl + ;; + "mariadb"|"mysql") + create_mysql_tbl + ;; + esac +} + +create_postgresql_tbl() { + CONNECTION_PARAMS="-h$DB_HOST -p$DB_PORT -U$DB_USER -w" + if [ -n "$DB_PWD" ]; then + export PGPASSWORD=$DB_PWD fi PSQL="psql -q $CONNECTION_PARAMS" @@ -243,10 +282,20 @@ create_postgresql_tbl(){ # Create db on remote server if $PSQL -lt | cut -d\| -f 1 | grep -qw | grep 0; then - $CREATEDB $POSTGRESQL_SERVER_DB_NAME + $CREATEDB $DB_NAME fi - $PSQL -d "${POSTGRESQL_SERVER_DB_NAME}" -f "${APP_DIR}/server/schema/postgresql/createdb.sql" + $PSQL -d "$DB_NAME" -f "$APP_DIR/server/schema/postgresql/createdb.sql" +} + +create_mysql_tbl() { + CONNECTION_PARAMS="-h$DB_HOST -P$DB_PORT -u$DB_USER -p$DB_PWD -w" + MYSQL="mysql -q $CONNECTION_PARAMS" + + # Create db on remote server + $MYSQL -e "CREATE DATABASE IF NOT EXISTS $DB_NAME DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;" >/dev/null 2>&1 + + $MYSQL $DB_NAME < "$APP_DIR/server/schema/mysql/createdb.sql" >/dev/null 2>&1 } update_nginx_settings(){ @@ -340,10 +389,10 @@ if [ ${ONLYOFFICE_DATA_CONTAINER_HOST} = "localhost" ]; then update_jwt_settings # update settings by env variables - if [ ${POSTGRESQL_SERVER_HOST} != "localhost" ]; then - update_postgresql_settings - waiting_for_postgresql - create_postgresql_tbl + if [ $DB_HOST != "localhost" ]; then + update_db_settings + waiting_for_db + create_db_tbl else # change rights for postgres directory chown -R postgres:postgres ${PG_ROOT} @@ -390,7 +439,7 @@ if [ ${PG_NEW_CLUSTER} = "true" ]; then fi if [ ${ONLYOFFICE_DATA_CONTAINER} != "true" ]; then - waiting_for_postgresql + waiting_for_db waiting_for_amqp waiting_for_redis diff --git a/activemq.yml b/tests/activemq.yml similarity index 75% rename from activemq.yml rename to tests/activemq.yml index f6a5fed..14c3884 100644 --- a/activemq.yml +++ b/tests/activemq.yml @@ -4,8 +4,8 @@ services: container_name: onlyoffice-documentserver image: onlyoffice/4testing-documentserver-ie:latest environment: - - AMQP_SERVER_URL=amqp://guest:guest@onlyoffice-activemq - - AMQP_SERVER_TYPE=activemq + - AMQP_SERVER_TYPE + - AMQP_SERVER_URL stdin_open: true restart: always ports: @@ -18,8 +18,8 @@ services: container_name: onlyoffice-activemq image: webcenter/activemq:5.14.3 environment: - - ACTIVEMQ_USERS_guest=guest - - ACTIVEMQ_GROUPS_owners=guest + - ACTIVEMQ_USERS_guest + - ACTIVEMQ_GROUPS_owners restart: always networks: - onlyoffice diff --git a/tests/defaults.env b/tests/defaults.env new file mode 100644 index 0000000..664f342 --- /dev/null +++ b/tests/defaults.env @@ -0,0 +1,40 @@ +# DocumentServer Container +ONLYOFFICE_DATA_CONTAINER=true +DB_TYPE=postgres +DB_HOST=onlyoffice-postgresql +DB_PORT=5432 +DB_NAME=onlyoffice +DB_USER=onlyoffice +DB_PWD=onlyoffice +AMQP_SERVER_TYPE=rabbitmq +AMQP_SERVER_URL=amqp://guest:guest@onlyoffice-rabbitmq +REDIS_SERVER_HOST=onlyoffice-redis +REDIS_SERVER_PORT=6379 +JWT_ENABLED=true +JWT_SECRET=secret +JWT_HEADER=Authorization + +ONLYOFFICE_DATA_CONTAINER_HOST=onlyoffice-documentserver-data +BALANCE=uri depth 3 +EXCLUDE_PORTS=443 +HTTP_CHECK=GET /healthcheck +EXTRA_SETTINGS=http-check expect string true +FORCE_SSL=true + +# HAProxy Container +MODE=http +CERT_FOLDER=/certs/ + +# ActiveMQ Container +ACTIVEMQ_USERS_guest=guest +ACTIVEMQ_GROUPS_owners=guest + +# Postgres Container +POSTGRES_DB=onlyoffice +POSTGRES_USER=onlyoffice + +# MySQL Container +MYSQL_DATABASE=onlyoffice +MYSQL_USER=onlyoffice +MYSQL_PASSWORD=onlyoffice +MYSQL_ALLOW_EMPTY_PASSWORD=yes \ No newline at end of file diff --git a/tests/mysql.yml b/tests/mysql.yml new file mode 100644 index 0000000..9a4155f --- /dev/null +++ b/tests/mysql.yml @@ -0,0 +1,35 @@ +version: '2' +services: + onlyoffice-documentserver: + container_name: onlyoffice-documentserver + image: onlyoffice/4testing-documentserver-ie:latest + depends_on: + - onlyoffice-mysql + environment: + - DB_TYPE + - DB_HOST + - DB_PORT + - DB_NAME + - DB_USER + - DB_PWD + stdin_open: true + restart: always + ports: + - '80:80' + + onlyoffice-mysql: + container_name: onlyoffice-mysql + image: mysql:5.7 + environment: + - MYSQL_DATABASE + - MYSQL_USER + - MYSQL_PASSWORD + - MYSQL_ALLOW_EMPTY_PASSWORD + restart: always + volumes: + - mysql_data:/var/lib/mysql + expose: + - '3306' + +volumes: + mysql_data: diff --git a/tests/postgres-old.yml b/tests/postgres-old.yml new file mode 100644 index 0000000..4385562 --- /dev/null +++ b/tests/postgres-old.yml @@ -0,0 +1,32 @@ +version: '2' +services: + onlyoffice-documentserver: + container_name: onlyoffice-documentserver + image: onlyoffice/4testing-documentserver-ie:latest + depends_on: + - onlyoffice-postgresql + environment: + - POSTGRESQL_SERVER_HOST + - POSTGRESQL_SERVER_PORT + - POSTGRESQL_SERVER_DB_NAME + - POSTGRESQL_SERVER_USER + - POSTGRESQL_SERVER_PASS + stdin_open: true + restart: always + ports: + - '80:80' + + onlyoffice-postgresql: + container_name: onlyoffice-postgresql + image: postgres:9.5 + environment: + - POSTGRES_DB + - POSTGRES_USER + restart: always + expose: + - '5432' + volumes: + - postgresql_data:/var/lib/postgresql + +volumes: + postgresql_data: diff --git a/tests/postgres.yml b/tests/postgres.yml new file mode 100644 index 0000000..0c5c39d --- /dev/null +++ b/tests/postgres.yml @@ -0,0 +1,33 @@ +version: '2' +services: + onlyoffice-documentserver: + container_name: onlyoffice-documentserver + image: onlyoffice/4testing-documentserver-ie:latest + depends_on: + - onlyoffice-postgresql + environment: + - DB_TYPE + - DB_HOST + - DB_PORT + - DB_NAME + - DB_USER + - DB_PWD + stdin_open: true + restart: always + ports: + - '80:80' + + onlyoffice-postgresql: + container_name: onlyoffice-postgresql + image: postgres:9.5 + environment: + - POSTGRES_DB + - POSTGRES_USER + restart: always + expose: + - '5432' + volumes: + - postgresql_data:/var/lib/postgresql + +volumes: + postgresql_data: diff --git a/tests/test.sh b/tests/test.sh new file mode 100755 index 0000000..49d57c3 --- /dev/null +++ b/tests/test.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# Check if the yml exists +if [[ ! -f $config ]]; then + echo "File $config doesn't exist!" + exit 1 +fi + +env_file=defaults.env + +# Copy .env +if [[ -f $env_file ]]; then + cp $env_file .env +else + echo "File $env_file doesn't exist!" + exit 1 +fi + +# Run test environment +docker-compose -p ds -f $config up -d + +wakeup_timeout=30 + +# Get documentserver healthcheck status +echo "Wait for service wake up" +sleep $wakeup_timeout +healthcheck_res=$(wget --no-check-certificate -qO - localhost/healthcheck) + +# Fail if it isn't true +if [[ $healthcheck_res == "true" ]]; then + echo "Healthcheck passed." +else + echo "Healthcheck failed!" + exit 1 +fi + +docker-compose -p ds -f $config down From 18b8dbe4fe309e02f8af4032d1d4d82f8df03a6f Mon Sep 17 00:00:00 2001 From: Semyon Bezrukov Date: Tue, 26 Nov 2019 17:08:29 +0300 Subject: [PATCH 2/4] Fix RabbitMQ high CPU usage on idle VM (#193) --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 0c3fb85..efbef17 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,6 +43,7 @@ RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d && \ supervisor \ xvfb \ zlib1g && \ + echo "SERVER_ADDITIONAL_ERL_ARGS=\"+S 1:1\"" | tee -a /etc/rabbitmq/rabbitmq-env.conf && \ sudo -u postgres psql -c "CREATE DATABASE onlyoffice;" && \ sudo -u postgres psql -c "CREATE USER onlyoffice WITH password 'onlyoffice';" && \ sudo -u postgres psql -c "GRANT ALL privileges ON DATABASE onlyoffice TO onlyoffice;" && \ From b3055c362cfda49863b890f9acfefeaf568eceb7 Mon Sep 17 00:00:00 2001 From: Semyon Bezrukov Date: Wed, 27 Nov 2019 11:35:08 +0300 Subject: [PATCH 3/4] Add support JWT_IN_BODY param (#194) --- README.md | 1 + docker-compose.yml | 1 + run-document-server.sh | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/README.md b/README.md index eec79bc..bea73b9 100644 --- a/README.md +++ b/README.md @@ -177,6 +177,7 @@ Below is the complete list of parameters that can be set using environment varia - **JWT_ENABLED**: Specifies the enabling the JSON Web Token validation by the ONLYOFFICE Document Server. Defaults to `false`. - **JWT_SECRET**: Defines the secret key to validate the JSON Web Token in the request to the ONLYOFFICE Document Server. Defaults to `secret`. - **JWT_HEADER**: Defines the http header that will be used to send the JSON Web Token. Defaults to `Authorization`. +- **JWT_IN_BODY**: Specifies the enabling the token validation in the request body to the ONLYOFFICE Document Server. Defaults to `false`. ## Installing ONLYOFFICE Document Server integrated with Community and Mail Servers diff --git a/docker-compose.yml b/docker-compose.yml index 3df7230..6e73ff5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,6 +17,7 @@ services: #- JWT_ENABLED=true #- JWT_SECRET=secret #- JWT_HEADER=Authorization + #- JWT_IN_BODY=true stdin_open: true restart: always networks: diff --git a/run-document-server.sh b/run-document-server.sh index 3e3bb2b..436a017 100755 --- a/run-document-server.sh +++ b/run-document-server.sh @@ -38,6 +38,7 @@ NGINX_WORKER_CONNECTIONS=${NGINX_WORKER_CONNECTIONS:-$(ulimit -n)} JWT_ENABLED=${JWT_ENABLED:-false} JWT_SECRET=${JWT_SECRET:-secret} JWT_HEADER=${JWT_HEADER:-Authorization} +JWT_IN_BODY=${JWT_IN_BODY:-false} ONLYOFFICE_DEFAULT_CONFIG=${CONF_DIR}/local.json ONLYOFFICE_LOG4JS_CONFIG=${CONF_DIR}/log4js/production.json @@ -235,6 +236,9 @@ update_jwt_settings(){ ${JSON} -I -e "this.services.CoAuthoring.token.inbox.header = '${JWT_HEADER}'" ${JSON} -I -e "this.services.CoAuthoring.token.outbox.header = '${JWT_HEADER}'" + ${JSON} -I -e "this.services.CoAuthoring.token.inbox.inBody = '${JWT_IN_BODY}'" + ${JSON} -I -e "this.services.CoAuthoring.token.outbox.inBody = '${JWT_IN_BODY}'" + if [ -f "${ONLYOFFICE_EXAMPLE_CONFIG}" ] && [ "${JWT_ENABLED}" == "true" ]; then ${JSON_EXAMPLE} -I -e "this.server.token.enable = ${JWT_ENABLED}" ${JSON_EXAMPLE} -I -e "this.server.token.secret = '${JWT_SECRET}'" From f18d04f4067ab9711015e902de2221d6c32f83b3 Mon Sep 17 00:00:00 2001 From: Semyon Bezrukov Date: Thu, 28 Nov 2019 14:59:20 +0300 Subject: [PATCH 4/4] Fix commands on welcome page (#197) --- run-document-server.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/run-document-server.sh b/run-document-server.sh index 436a017..6cde63a 100755 --- a/run-document-server.sh +++ b/run-document-server.sh @@ -302,6 +302,19 @@ create_mysql_tbl() { $MYSQL $DB_NAME < "$APP_DIR/server/schema/mysql/createdb.sql" >/dev/null 2>&1 } +update_welcome_page() { + WELCOME_PAGE="${APP_DIR}-example/welcome/docker.html" + if [[ -e $WELCOME_PAGE ]]; then + DOCKER_CONTAINER_ID=$(basename $(cat /proc/1/cpuset)) + if [[ -x $(command -v docker) ]]; then + DOCKER_CONTAINER_NAME=$(docker inspect --format="{{.Name}}" $DOCKER_CONTAINER_ID) + sed 's/$(sudo docker ps -q)/'"${DOCKER_CONTAINER_NAME#/}"'/' -i $WELCOME_PAGE + else + sed 's/$(sudo docker ps -q)/'"${DOCKER_CONTAINER_ID::12}"'/' -i $WELCOME_PAGE + fi + fi +} + update_nginx_settings(){ # Set up nginx sed 's/^worker_processes.*/'"worker_processes ${NGINX_WORKER_PROCESSES};"'/' -i ${NGINX_CONFIG_PATH} @@ -388,6 +401,8 @@ if [ ${ONLYOFFICE_DATA_CONTAINER_HOST} = "localhost" ]; then read_setting + update_welcome_page + update_log_settings update_jwt_settings @@ -430,6 +445,8 @@ else # read settings after the data container in ready state # to prevent get unconfigureted data read_setting + + update_welcome_page fi #start needed local services