From 1cfe84b8b80051ea495fe8d88176fc0559c4052e Mon Sep 17 00:00:00 2001 From: jdoubleu Date: Fri, 19 Mar 2021 14:20:52 +0100 Subject: [PATCH 1/3] Fix automatic port detection for database (#341) --- run-document-server.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-document-server.sh b/run-document-server.sh index 626b72a..ff05fd4 100755 --- a/run-document-server.sh +++ b/run-document-server.sh @@ -103,6 +103,7 @@ read_setting(){ METRICS_PREFIX="${METRICS_PREFIX:-.ds}" DB_HOST=${DB_HOST:-${POSTGRESQL_SERVER_HOST:-$(${JSON} services.CoAuthoring.sql.dbHost)}} + DB_TYPE=${DB_TYPE:-$(${JSON} services.CoAuthoring.sql.type)} case $DB_TYPE in "postgres") DB_PORT=${DB_PORT:-"5432"} @@ -121,7 +122,6 @@ read_setting(){ 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_URI=${AMQP_URI:-${AMQP_SERVER_URL:-${RABBITMQ_SERVER_URL}}} From f2c708cff295ebaba2c0c4c7873269fd9812b2f0 Mon Sep 17 00:00:00 2001 From: Roman Demidov Date: Wed, 14 Apr 2021 17:10:38 +0300 Subject: [PATCH 2/3] Reset database tables on update (#351) * Reset database tables on update * Add changes * Add changes * Add changes * Add changes * Add changes * Add changes --- run-document-server.sh | 56 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/run-document-server.sh b/run-document-server.sh index ff05fd4..2457304 100755 --- a/run-document-server.sh +++ b/run-document-server.sh @@ -11,16 +11,32 @@ shopt -s globstar APP_DIR="/var/www/${COMPANY_NAME}/documentserver" DATA_DIR="/var/www/${COMPANY_NAME}/Data" +PRIVATE_DATA_DIR="${DATA_DIR}/.private" +DS_RELEASE_DATE="${PRIVATE_DATA_DIR}/ds_release_date" LOG_DIR="/var/log/${COMPANY_NAME}" DS_LOG_DIR="${LOG_DIR}/documentserver" LIB_DIR="/var/lib/${COMPANY_NAME}" DS_LIB_DIR="${LIB_DIR}/documentserver" CONF_DIR="/etc/${COMPANY_NAME}/documentserver" +IS_UPGRADE="false" ONLYOFFICE_DATA_CONTAINER=${ONLYOFFICE_DATA_CONTAINER:-false} ONLYOFFICE_DATA_CONTAINER_HOST=${ONLYOFFICE_DATA_CONTAINER_HOST:-localhost} ONLYOFFICE_DATA_CONTAINER_PORT=80 +RELEASE_DATE="$(stat -c="%y" ${APP_DIR}/server/DocService/docservice | sed -r 's/=([0-9]+)-([0-9]+)-([0-9]+) ([0-9:.+ ]+)/\1-\2-\3/')"; +if [ -f ${DS_RELEASE_DATE} ]; then + PREV_RELEASE_DATE=$(head -n 1 ${DS_RELEASE_DATE}) +else + PREV_RELEASE_DATE="0" +fi + +if [ "${RELEASE_DATE}" != "${PREV_RELEASE_DATE}" ]; then + if [ ${ONLYOFFICE_DATA_CONTAINER} != "true" ]; then + IS_UPGRADE="true"; + fi +fi + SSL_CERTIFICATES_DIR="${DATA_DIR}/certs" if [[ -z $SSL_CERTIFICATE_PATH ]] && [[ -f ${SSL_CERTIFICATES_DIR}/onlyoffice.crt ]]; then SSL_CERTIFICATE_PATH=${SSL_CERTIFICATES_DIR}/onlyoffice.crt @@ -327,6 +343,36 @@ create_db_tbl() { esac } +upgrade_db_tbl() { + case $DB_TYPE in + "postgres") + upgrade_postgresql_tbl + ;; + "mariadb"|"mysql") + upgrade_mysql_tbl + ;; + esac +} + +upgrade_postgresql_tbl() { + if [ -n "$DB_PWD" ]; then + export PGPASSWORD=$DB_PWD + fi + + PSQL="psql -q -h$DB_HOST -p$DB_PORT -d$DB_NAME -U$DB_USER -w" + + $PSQL -f "$APP_DIR/server/schema/postgresql/removetbl.sql" + $PSQL -f "$APP_DIR/server/schema/postgresql/createdb.sql" +} + +upgrade_mysql_tbl() { + CONNECTION_PARAMS="-h$DB_HOST -P$DB_PORT -u$DB_USER -p$DB_PWD -w" + MYSQL="mysql -q $CONNECTION_PARAMS" + + $MYSQL $DB_NAME < "$APP_DIR/server/schema/mysql/removetbl.sql" >/dev/null 2>&1 + $MYSQL $DB_NAME < "$APP_DIR/server/schema/mysql/createdb.sql" >/dev/null 2>&1 +} + create_postgresql_tbl() { if [ -n "$DB_PWD" ]; then export PGPASSWORD=$DB_PWD @@ -423,6 +469,11 @@ update_logrotate_settings(){ sed 's|\(^su\b\).*|\1 root root|' -i /etc/logrotate.conf } +update_release_date(){ + mkdir -p ${PRIVATE_DATA_DIR} + echo ${RELEASE_DATE} > ${DS_RELEASE_DATE} +} + # create base folders for i in converter docservice spellchecker metrics; do mkdir -p "${DS_LOG_DIR}/$i" @@ -527,6 +578,11 @@ if [ ${ONLYOFFICE_DATA_CONTAINER} != "true" ]; then waiting_for_redis fi + if [ "${IS_UPGRADE}" = "true" ]; then + upgrade_db_tbl + update_release_date + fi + update_nginx_settings update_supervisor_settings From 67df6448583bebded58e0667331fbbc55660911d Mon Sep 17 00:00:00 2001 From: Pavel Lobashov Date: Thu, 29 Apr 2021 12:14:31 +0300 Subject: [PATCH 3/3] Precise info about table existance (#355) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e821381..8398984 100644 --- a/README.md +++ b/README.md @@ -178,7 +178,7 @@ Below is the complete list of parameters that can be set using environment varia - **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_NAME**: The name of a database to use. Should be existing on container startup. - **DB_USER**: The new user name with superuser permissions for the database account. - **DB_PWD**: The password set for the database account. - **AMQP_URI**: The [AMQP URI](https://www.rabbitmq.com/uri-spec.html "RabbitMQ URI Specification") to connect to message broker server.