2015-04-17 15:25:41 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-04-21 12:14:26 +03:00
|
|
|
# Define '**' behavior explicitly
|
|
|
|
shopt -s globstar
|
|
|
|
|
2016-06-30 12:41:52 +03:00
|
|
|
APP_DIR="/var/www/onlyoffice/documentserver"
|
2015-04-17 15:25:41 +00:00
|
|
|
DATA_DIR="/var/www/onlyoffice/Data"
|
2017-11-10 15:10:52 +03:00
|
|
|
LOG_DIR="/var/log/onlyoffice"
|
|
|
|
DS_LOG_DIR="${LOG_DIR}/documentserver"
|
|
|
|
LIB_DIR="/var/lib/onlyoffice"
|
2017-05-17 17:41:13 +03:00
|
|
|
CONF_DIR="/etc/onlyoffice/documentserver"
|
2015-04-17 15:25:41 +00:00
|
|
|
|
2016-07-11 11:47:22 +03:00
|
|
|
ONLYOFFICE_DATA_CONTAINER=${ONLYOFFICE_DATA_CONTAINER:-false}
|
2016-07-20 18:56:20 +03:00
|
|
|
ONLYOFFICE_DATA_CONTAINER_HOST=${ONLYOFFICE_DATA_CONTAINER_HOST:-localhost}
|
|
|
|
ONLYOFFICE_DATA_CONTAINER_PORT=80
|
2015-04-17 15:25:41 +00:00
|
|
|
|
|
|
|
SSL_CERTIFICATES_DIR="${DATA_DIR}/certs"
|
|
|
|
SSL_CERTIFICATE_PATH=${SSL_CERTIFICATE_PATH:-${SSL_CERTIFICATES_DIR}/onlyoffice.crt}
|
|
|
|
SSL_KEY_PATH=${SSL_KEY_PATH:-${SSL_CERTIFICATES_DIR}/onlyoffice.key}
|
2016-06-30 12:41:52 +03:00
|
|
|
CA_CERTIFICATES_PATH=${CA_CERTIFICATES_PATH:-${SSL_CERTIFICATES_DIR}/ca-certificates.pem}
|
2015-04-17 15:25:41 +00:00
|
|
|
SSL_DHPARAM_PATH=${SSL_DHPARAM_PATH:-${SSL_CERTIFICATES_DIR}/dhparam.pem}
|
|
|
|
SSL_VERIFY_CLIENT=${SSL_VERIFY_CLIENT:-off}
|
|
|
|
ONLYOFFICE_HTTPS_HSTS_ENABLED=${ONLYOFFICE_HTTPS_HSTS_ENABLED:-true}
|
2017-05-12 16:51:22 +03:00
|
|
|
ONLYOFFICE_HTTPS_HSTS_MAXAGE=${ONLYOFFICE_HTTPS_HSTS_MAXAGE:-31536000}
|
2015-04-17 15:25:41 +00:00
|
|
|
SYSCONF_TEMPLATES_DIR="/app/onlyoffice/setup/config"
|
|
|
|
|
2017-01-24 19:34:20 +03:00
|
|
|
NGINX_CONFD_PATH="/etc/nginx/conf.d";
|
2017-11-29 12:52:57 +03:00
|
|
|
NGINX_ONLYOFFICE_PATH="${CONF_DIR}/nginx"
|
2018-10-16 12:22:18 +03:00
|
|
|
NGINX_ONLYOFFICE_CONF="${NGINX_ONLYOFFICE_PATH}/ds.conf"
|
2017-11-29 14:37:21 +03:00
|
|
|
NGINX_ONLYOFFICE_EXAMPLE_PATH="${CONF_DIR}-example/nginx"
|
2018-10-16 12:22:18 +03:00
|
|
|
NGINX_ONLYOFFICE_EXAMPLE_CONF="${NGINX_ONLYOFFICE_EXAMPLE_PATH}/includes/ds-example.conf"
|
2017-11-29 12:52:57 +03:00
|
|
|
|
2016-06-30 12:41:52 +03:00
|
|
|
NGINX_CONFIG_PATH="/etc/nginx/nginx.conf"
|
2017-09-20 17:25:38 +03:00
|
|
|
NGINX_WORKER_PROCESSES=${NGINX_WORKER_PROCESSES:-1}
|
2016-06-30 12:41:52 +03:00
|
|
|
NGINX_WORKER_CONNECTIONS=${NGINX_WORKER_CONNECTIONS:-$(ulimit -n)}
|
|
|
|
|
2017-09-01 16:59:34 +03:00
|
|
|
JWT_ENABLED=${JWT_ENABLED:-false}
|
|
|
|
JWT_SECRET=${JWT_SECRET:-secret}
|
|
|
|
JWT_HEADER=${JWT_HEADER:-Authorization}
|
|
|
|
|
2018-05-04 11:56:18 +03:00
|
|
|
ONLYOFFICE_DEFAULT_CONFIG=${CONF_DIR}/local.json
|
2017-05-17 17:41:13 +03:00
|
|
|
ONLYOFFICE_LOG4JS_CONFIG=${CONF_DIR}/log4js/production.json
|
2018-05-04 11:56:18 +03:00
|
|
|
ONLYOFFICE_EXAMPLE_CONFIG=${CONF_DIR}-example/local.json
|
2016-06-30 12:41:52 +03:00
|
|
|
|
2019-02-15 15:10:19 +03:00
|
|
|
JSON_BIN=${APP_DIR}/npm/node_modules/.bin/json
|
|
|
|
JSON="${JSON_BIN} -q -f ${ONLYOFFICE_DEFAULT_CONFIG}"
|
|
|
|
JSON_LOG="${JSON_BIN} -q -f ${ONLYOFFICE_LOG4JS_CONFIG}"
|
|
|
|
JSON_EXAMPLE="${JSON_BIN} -q -f ${ONLYOFFICE_EXAMPLE_CONFIG}"
|
2016-07-11 11:47:22 +03:00
|
|
|
|
2016-07-20 18:56:20 +03:00
|
|
|
LOCAL_SERVICES=()
|
2016-07-11 11:47:22 +03:00
|
|
|
|
2018-04-03 19:39:11 +03:00
|
|
|
PG_ROOT=/var/lib/postgresql
|
2017-12-12 17:02:14 +03:00
|
|
|
PG_VERSION=9.5
|
2017-04-24 20:02:01 +03:00
|
|
|
PG_NAME=main
|
2018-04-03 19:39:11 +03:00
|
|
|
PGDATA=${PG_ROOT}/${PG_VERSION}/${PG_NAME}
|
2017-04-24 20:02:01 +03:00
|
|
|
PG_NEW_CLUSTER=false
|
|
|
|
|
2016-07-20 18:56:20 +03:00
|
|
|
read_setting(){
|
2016-08-25 19:52:14 +03:00
|
|
|
POSTGRESQL_SERVER_HOST=${POSTGRESQL_SERVER_HOST:-$(${JSON} services.CoAuthoring.sql.dbHost)}
|
2018-05-04 11:56:18 +03:00
|
|
|
POSTGRESQL_SERVER_PORT=${POSTGRESQL_SERVER_PORT:-5432}
|
2016-08-25 19:52:14 +03:00
|
|
|
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)}
|
2016-07-11 11:47:22 +03:00
|
|
|
|
2016-12-09 15:50:07 +03:00
|
|
|
RABBITMQ_SERVER_URL=${RABBITMQ_SERVER_URL:-$(${JSON} rabbitmq.url)}
|
2019-01-28 15:47:32 +03:00
|
|
|
AMQP_SERVER_URL=${AMQP_SERVER_URL:-${RABBITMQ_SERVER_URL}}
|
2019-03-05 18:12:54 +03:00
|
|
|
AMQP_SERVER_TYPE=${AMQP_SERVER_TYPE:-rabbitmq}
|
2019-01-28 15:47:32 +03:00
|
|
|
parse_rabbitmq_url ${AMQP_SERVER_URL}
|
2016-07-20 18:56:20 +03:00
|
|
|
|
|
|
|
REDIS_SERVER_HOST=${REDIS_SERVER_HOST:-$(${JSON} services.CoAuthoring.redis.host)}
|
2018-05-04 11:56:18 +03:00
|
|
|
REDIS_SERVER_PORT=${REDIS_SERVER_PORT:-6379}
|
2017-05-17 17:41:13 +03:00
|
|
|
|
2018-11-15 12:11:08 +03:00
|
|
|
DS_LOG_LEVEL=${DS_LOG_LEVEL:-$(${JSON_LOG} categories.default.level)}
|
2016-07-20 18:56:20 +03:00
|
|
|
}
|
2016-07-11 11:47:22 +03:00
|
|
|
|
2016-12-09 15:50:07 +03:00
|
|
|
parse_rabbitmq_url(){
|
2019-01-28 15:47:32 +03:00
|
|
|
local amqp=$1
|
2016-12-09 15:50:07 +03:00
|
|
|
|
|
|
|
# extract the protocol
|
|
|
|
local proto="$(echo $amqp | grep :// | sed -e's,^\(.*://\).*,\1,g')"
|
|
|
|
# remove the protocol
|
|
|
|
local url="$(echo ${amqp/$proto/})"
|
|
|
|
|
|
|
|
# extract the user and password (if any)
|
|
|
|
local userpass="`echo $url | grep @ | cut -d@ -f1`"
|
|
|
|
local pass=`echo $userpass | grep : | cut -d: -f2`
|
|
|
|
|
|
|
|
local user
|
|
|
|
if [ -n "$pass" ]; then
|
|
|
|
user=`echo $userpass | grep : | cut -d: -f1`
|
|
|
|
else
|
|
|
|
user=$userpass
|
|
|
|
fi
|
|
|
|
|
|
|
|
# extract the host
|
|
|
|
local hostport="$(echo ${url/$userpass@/} | cut -d/ -f1)"
|
|
|
|
# by request - try to extract the port
|
|
|
|
local port="$(echo $hostport | sed -e 's,^.*:,:,g' -e 's,.*:\([0-9]*\).*,\1,g' -e 's,[^0-9],,g')"
|
|
|
|
|
|
|
|
local host
|
|
|
|
if [ -n "$port" ]; then
|
|
|
|
host=`echo $hostport | grep : | cut -d: -f1`
|
|
|
|
else
|
|
|
|
host=$hostport
|
|
|
|
port="5672"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# extract the path (if any)
|
|
|
|
local path="$(echo $url | grep / | cut -d/ -f2-)"
|
|
|
|
|
2019-01-28 15:47:32 +03:00
|
|
|
AMQP_SERVER_HOST=$host
|
|
|
|
AMQP_SERVER_USER=$user
|
|
|
|
AMQP_SERVER_PASS=$pass
|
|
|
|
AMQP_SERVER_PORT=$port
|
2016-12-09 15:50:07 +03:00
|
|
|
}
|
|
|
|
|
2016-07-11 11:47:22 +03:00
|
|
|
waiting_for_connection(){
|
|
|
|
until nc -z -w 3 "$1" "$2"; do
|
|
|
|
>&2 echo "Waiting for connection to the $1 host on port $2"
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2016-08-25 19:52:14 +03:00
|
|
|
waiting_for_postgresql(){
|
|
|
|
waiting_for_connection ${POSTGRESQL_SERVER_HOST} ${POSTGRESQL_SERVER_PORT}
|
2016-07-11 11:47:22 +03:00
|
|
|
}
|
|
|
|
|
2019-01-28 15:47:32 +03:00
|
|
|
waiting_for_amqp(){
|
|
|
|
waiting_for_connection ${AMQP_SERVER_HOST} ${AMQP_SERVER_PORT}
|
2016-07-11 11:47:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
waiting_for_redis(){
|
|
|
|
waiting_for_connection ${REDIS_SERVER_HOST} ${REDIS_SERVER_PORT}
|
|
|
|
}
|
2016-07-20 18:56:20 +03:00
|
|
|
waiting_for_datacontainer(){
|
|
|
|
waiting_for_connection ${ONLYOFFICE_DATA_CONTAINER_HOST} ${ONLYOFFICE_DATA_CONTAINER_PORT}
|
|
|
|
}
|
2016-08-25 19:52:14 +03:00
|
|
|
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}'"
|
2016-07-11 11:47:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
update_rabbitmq_setting(){
|
2019-03-05 18:12:54 +03:00
|
|
|
if [ "${AMQP_SERVER_TYPE}" == "rabbitmq" ]; then
|
2019-03-07 15:21:52 +03:00
|
|
|
${JSON} -I -e "if(this.queue===undefined)this.queue={};"
|
2019-03-06 12:30:54 +03:00
|
|
|
${JSON} -I -e "this.queue.type = 'rabbitmq'"
|
2019-05-29 15:34:58 +03:00
|
|
|
${JSON} -I -e "this.rabbitmq.url = '${AMQP_SERVER_URL}'"
|
2019-01-28 15:47:32 +03:00
|
|
|
fi
|
|
|
|
|
2019-03-05 18:12:54 +03:00
|
|
|
if [ "${AMQP_SERVER_TYPE}" == "activemq" ]; then
|
2019-03-07 15:21:52 +03:00
|
|
|
${JSON} -I -e "if(this.queue===undefined)this.queue={};"
|
2019-03-06 12:30:54 +03:00
|
|
|
${JSON} -I -e "this.queue.type = 'activemq'"
|
2019-01-28 15:47:32 +03:00
|
|
|
${JSON} -I -e "if(this.activemq===undefined)this.activemq={};"
|
|
|
|
${JSON} -I -e "if(this.activemq.connectOptions===undefined)this.activemq.connectOptions={};"
|
|
|
|
|
|
|
|
${JSON} -I -e "this.activemq.connectOptions.host = '${AMQP_SERVER_HOST}'"
|
|
|
|
|
|
|
|
if [ ! "${AMQP_SERVER_PORT}" == "" ]; then
|
|
|
|
${JSON} -I -e "this.activemq.connectOptions.port = '${AMQP_SERVER_PORT}'"
|
|
|
|
else
|
|
|
|
${JSON} -I -e "delete this.activemq.connectOptions.port"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! "${AMQP_SERVER_USER}" == "" ]; then
|
|
|
|
${JSON} -I -e "this.activemq.connectOptions.username = '${AMQP_SERVER_USER}'"
|
|
|
|
else
|
|
|
|
${JSON} -I -e "delete this.activemq.connectOptions.username"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! "${AMQP_SERVER_PASS}" == "" ]; then
|
|
|
|
${JSON} -I -e "this.activemq.connectOptions.password = '${AMQP_SERVER_PASS}'"
|
|
|
|
else
|
|
|
|
${JSON} -I -e "delete this.activemq.connectOptions.password"
|
|
|
|
fi
|
|
|
|
fi
|
2016-07-11 11:47:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
update_redis_settings(){
|
|
|
|
${JSON} -I -e "this.services.CoAuthoring.redis.host = '${REDIS_SERVER_HOST}'"
|
|
|
|
${JSON} -I -e "this.services.CoAuthoring.redis.port = '${REDIS_SERVER_PORT}'"
|
|
|
|
}
|
|
|
|
|
2017-09-01 16:59:34 +03:00
|
|
|
update_jwt_settings(){
|
|
|
|
if [ "${JWT_ENABLED}" == "true" ]; then
|
2018-07-19 16:20:20 +03:00
|
|
|
${JSON} -I -e "this.services.CoAuthoring.token.enable.browser = ${JWT_ENABLED}"
|
|
|
|
${JSON} -I -e "this.services.CoAuthoring.token.enable.request.inbox = ${JWT_ENABLED}"
|
|
|
|
${JSON} -I -e "this.services.CoAuthoring.token.enable.request.outbox = ${JWT_ENABLED}"
|
2017-09-01 16:59:34 +03:00
|
|
|
|
|
|
|
${JSON} -I -e "this.services.CoAuthoring.secret.inbox.string = '${JWT_SECRET}'"
|
|
|
|
${JSON} -I -e "this.services.CoAuthoring.secret.outbox.string = '${JWT_SECRET}'"
|
|
|
|
${JSON} -I -e "this.services.CoAuthoring.secret.session.string = '${JWT_SECRET}'"
|
|
|
|
|
|
|
|
${JSON} -I -e "this.services.CoAuthoring.token.inbox.header = '${JWT_HEADER}'"
|
|
|
|
${JSON} -I -e "this.services.CoAuthoring.token.outbox.header = '${JWT_HEADER}'"
|
2017-09-06 17:21:52 +03:00
|
|
|
|
2018-07-19 16:20:20 +03:00
|
|
|
if [ -f "${ONLYOFFICE_EXAMPLE_CONFIG}" ] && [ "${JWT_ENABLED}" == "true" ]; then
|
|
|
|
${JSON_EXAMPLE} -I -e "this.server.token.enable = ${JWT_ENABLED}"
|
2017-09-06 17:21:52 +03:00
|
|
|
${JSON_EXAMPLE} -I -e "this.server.token.secret = '${JWT_SECRET}'"
|
|
|
|
${JSON_EXAMPLE} -I -e "this.server.token.authorizationHeader = '${JWT_HEADER}'"
|
|
|
|
fi
|
2017-09-01 16:59:34 +03:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-04-24 20:02:01 +03:00
|
|
|
create_postgresql_cluster(){
|
|
|
|
local pg_conf_dir=/etc/postgresql/${PG_VERSION}/${PG_NAME}
|
|
|
|
local postgresql_conf=$pg_conf_dir/postgresql.conf
|
|
|
|
local hba_conf=$pg_conf_dir/pg_hba.conf
|
|
|
|
|
|
|
|
mv $postgresql_conf $postgresql_conf.backup
|
|
|
|
mv $hba_conf $hba_conf.backup
|
2017-05-17 16:35:54 +03:00
|
|
|
|
2017-04-24 20:02:01 +03:00
|
|
|
pg_createcluster ${PG_VERSION} ${PG_NAME}
|
|
|
|
}
|
|
|
|
|
2016-08-25 19:52:14 +03:00
|
|
|
create_postgresql_db(){
|
2017-04-24 20:02:01 +03:00
|
|
|
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;"
|
|
|
|
}
|
|
|
|
|
|
|
|
create_postgresql_tbl(){
|
2016-08-25 19:52:14 +03:00
|
|
|
CONNECTION_PARAMS="-h${POSTGRESQL_SERVER_HOST} -U${POSTGRESQL_SERVER_USER} -w"
|
|
|
|
if [ -n "${POSTGRESQL_SERVER_PASS}" ]; then
|
|
|
|
export PGPASSWORD=${POSTGRESQL_SERVER_PASS}
|
2016-07-11 11:47:22 +03:00
|
|
|
fi
|
2016-06-30 12:41:52 +03:00
|
|
|
|
2016-08-25 19:52:14 +03:00
|
|
|
PSQL="psql -q $CONNECTION_PARAMS"
|
|
|
|
CREATEDB="createdb $CONNECTION_PARAMS"
|
|
|
|
|
|
|
|
# Create db on remote server
|
|
|
|
if $PSQL -lt | cut -d\| -f 1 | grep -qw | grep 0; then
|
2018-11-06 17:16:29 +03:00
|
|
|
$CREATEDB $POSTGRESQL_SERVER_DB_NAME
|
2016-08-25 19:52:14 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
$PSQL -d "${POSTGRESQL_SERVER_DB_NAME}" -f "${APP_DIR}/server/schema/postgresql/createdb.sql"
|
|
|
|
}
|
2016-07-11 11:47:22 +03:00
|
|
|
|
2016-07-20 18:56:20 +03:00
|
|
|
update_nginx_settings(){
|
2016-07-11 11:47:22 +03:00
|
|
|
# Set up nginx
|
|
|
|
sed 's/^worker_processes.*/'"worker_processes ${NGINX_WORKER_PROCESSES};"'/' -i ${NGINX_CONFIG_PATH}
|
|
|
|
sed 's/worker_connections.*/'"worker_connections ${NGINX_WORKER_CONNECTIONS};"'/' -i ${NGINX_CONFIG_PATH}
|
|
|
|
sed 's/access_log.*/'"access_log off;"'/' -i ${NGINX_CONFIG_PATH}
|
|
|
|
|
|
|
|
# setup HTTPS
|
|
|
|
if [ -f "${SSL_CERTIFICATE_PATH}" -a -f "${SSL_KEY_PATH}" ]; then
|
2018-10-16 12:22:18 +03:00
|
|
|
cp -f ${NGINX_ONLYOFFICE_PATH}/ds-ssl.conf.tmpl ${NGINX_ONLYOFFICE_CONF}
|
2016-07-11 11:47:22 +03:00
|
|
|
|
|
|
|
# configure nginx
|
2017-11-29 12:52:57 +03:00
|
|
|
sed 's,{{SSL_CERTIFICATE_PATH}},'"${SSL_CERTIFICATE_PATH}"',' -i ${NGINX_ONLYOFFICE_CONF}
|
|
|
|
sed 's,{{SSL_KEY_PATH}},'"${SSL_KEY_PATH}"',' -i ${NGINX_ONLYOFFICE_CONF}
|
2016-07-11 11:47:22 +03:00
|
|
|
|
2017-12-12 17:02:14 +03:00
|
|
|
# turn on http2
|
|
|
|
sed 's,\(443 ssl\),\1 http2,' -i ${NGINX_ONLYOFFICE_CONF}
|
|
|
|
|
2016-07-11 11:47:22 +03:00
|
|
|
# if dhparam path is valid, add to the config, otherwise remove the option
|
|
|
|
if [ -r "${SSL_DHPARAM_PATH}" ]; then
|
2017-11-29 12:52:57 +03:00
|
|
|
sed 's,\(\#* *\)\?\(ssl_dhparam \).*\(;\)$,'"\2${SSL_DHPARAM_PATH}\3"',' -i ${NGINX_ONLYOFFICE_CONF}
|
2016-07-11 11:47:22 +03:00
|
|
|
else
|
2017-11-29 12:52:57 +03:00
|
|
|
sed '/ssl_dhparam/d' -i ${NGINX_ONLYOFFICE_CONF}
|
2016-07-11 11:47:22 +03:00
|
|
|
fi
|
|
|
|
|
2017-11-29 12:52:57 +03:00
|
|
|
sed 's,\(ssl_verify_client \).*\(;\)$,'"\1${SSL_VERIFY_CLIENT}\2"',' -i ${NGINX_ONLYOFFICE_CONF}
|
2016-07-11 11:47:22 +03:00
|
|
|
|
|
|
|
if [ -f "${CA_CERTIFICATES_PATH}" ]; then
|
2017-11-29 12:52:57 +03:00
|
|
|
sed '/ssl_verify_client/a '"ssl_client_certificate ${CA_CERTIFICATES_PATH}"';' -i ${NGINX_ONLYOFFICE_CONF}
|
2016-07-11 11:47:22 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${ONLYOFFICE_HTTPS_HSTS_ENABLED}" == "true" ]; then
|
2017-11-29 12:52:57 +03:00
|
|
|
sed 's,\(max-age=\).*\(;\)$,'"\1${ONLYOFFICE_HTTPS_HSTS_MAXAGE}\2"',' -i ${NGINX_ONLYOFFICE_CONF}
|
2016-07-11 11:47:22 +03:00
|
|
|
else
|
2017-11-29 12:52:57 +03:00
|
|
|
sed '/max-age=/d' -i ${NGINX_ONLYOFFICE_CONF}
|
2016-07-11 11:47:22 +03:00
|
|
|
fi
|
|
|
|
else
|
2018-10-16 12:22:18 +03:00
|
|
|
ln -sf ${NGINX_ONLYOFFICE_PATH}/ds.conf.tmpl ${NGINX_ONLYOFFICE_CONF}
|
2016-07-11 11:47:22 +03:00
|
|
|
fi
|
2017-05-12 16:51:22 +03:00
|
|
|
|
2019-05-21 16:06:58 +03:00
|
|
|
# check if ipv6 supported otherwise remove it from nginx config
|
|
|
|
if [ ! -f /proc/net/if_inet6 ]; then
|
|
|
|
sed '/listen\s\+\[::[0-9]*\].\+/d' -i $NGINX_ONLYOFFICE_CONF
|
|
|
|
fi
|
|
|
|
|
2017-11-29 14:37:21 +03:00
|
|
|
if [ -f "${NGINX_ONLYOFFICE_EXAMPLE_CONF}" ]; then
|
|
|
|
sed 's/linux/docker/' -i ${NGINX_ONLYOFFICE_EXAMPLE_CONF}
|
2017-01-17 16:15:54 +03:00
|
|
|
fi
|
2016-07-11 11:47:22 +03:00
|
|
|
}
|
|
|
|
|
2016-07-20 18:56:20 +03:00
|
|
|
update_supervisor_settings(){
|
2016-07-11 11:47:22 +03:00
|
|
|
# Copy modified supervisor start script
|
|
|
|
cp ${SYSCONF_TEMPLATES_DIR}/supervisor/supervisor /etc/init.d/
|
|
|
|
# Copy modified supervisor config
|
|
|
|
cp ${SYSCONF_TEMPLATES_DIR}/supervisor/supervisord.conf /etc/supervisor/supervisord.conf
|
|
|
|
}
|
2015-04-17 15:25:41 +00:00
|
|
|
|
2017-05-17 17:41:13 +03:00
|
|
|
update_log_settings(){
|
2018-11-15 12:11:08 +03:00
|
|
|
${JSON_LOG} -I -e "this.categories.default.level = '${DS_LOG_LEVEL}'"
|
2017-05-17 17:41:13 +03:00
|
|
|
}
|
|
|
|
|
2018-11-20 17:06:53 +03:00
|
|
|
update_logrotate_settings(){
|
|
|
|
sed 's|\(^su\b\).*|\1 root root|' -i /etc/logrotate.conf
|
|
|
|
}
|
|
|
|
|
2015-05-25 06:47:54 -04:00
|
|
|
# create base folders
|
2016-06-30 12:41:52 +03:00
|
|
|
for i in converter docservice spellchecker metrics gc; do
|
2017-11-10 15:10:52 +03:00
|
|
|
mkdir -p "${DS_LOG_DIR}/$i"
|
2016-06-30 12:41:52 +03:00
|
|
|
done
|
|
|
|
|
2017-11-10 15:10:52 +03:00
|
|
|
mkdir -p ${DS_LOG_DIR}-example
|
|
|
|
|
|
|
|
# change folder rights
|
2018-10-02 19:36:14 +03:00
|
|
|
for i in ${LOG_DIR} ${LIB_DIR} ${DATA_DIR}; do
|
2018-10-16 12:22:18 +03:00
|
|
|
chown -R ds:ds "$i"
|
2017-11-10 15:10:52 +03:00
|
|
|
chmod -R 755 "$i"
|
|
|
|
done
|
2016-06-30 12:41:52 +03:00
|
|
|
|
2016-07-20 18:56:20 +03:00
|
|
|
if [ ${ONLYOFFICE_DATA_CONTAINER_HOST} = "localhost" ]; then
|
|
|
|
|
|
|
|
read_setting
|
|
|
|
|
2017-05-17 17:41:13 +03:00
|
|
|
update_log_settings
|
|
|
|
|
2017-09-01 16:59:34 +03:00
|
|
|
update_jwt_settings
|
|
|
|
|
2016-07-20 18:56:20 +03:00
|
|
|
# update settings by env variables
|
2016-08-25 19:52:14 +03:00
|
|
|
if [ ${POSTGRESQL_SERVER_HOST} != "localhost" ]; then
|
|
|
|
update_postgresql_settings
|
|
|
|
waiting_for_postgresql
|
2017-04-24 20:02:01 +03:00
|
|
|
create_postgresql_tbl
|
2016-07-20 18:56:20 +03:00
|
|
|
else
|
2018-04-03 19:39:11 +03:00
|
|
|
# change rights for postgres directory
|
|
|
|
chown -R postgres:postgres ${PG_ROOT}
|
|
|
|
chmod -R 700 ${PG_ROOT}
|
|
|
|
|
|
|
|
# create new db if it isn't exist
|
2017-04-24 20:02:01 +03:00
|
|
|
if [ ! -d ${PGDATA} ]; then
|
|
|
|
create_postgresql_cluster
|
|
|
|
PG_NEW_CLUSTER=true
|
|
|
|
fi
|
2016-08-25 19:52:14 +03:00
|
|
|
LOCAL_SERVICES+=("postgresql")
|
2016-07-11 11:47:22 +03:00
|
|
|
fi
|
2016-06-30 12:41:52 +03:00
|
|
|
|
2019-01-28 15:47:32 +03:00
|
|
|
if [ ${AMQP_SERVER_HOST} != "localhost" ]; then
|
2016-07-20 18:56:20 +03:00
|
|
|
update_rabbitmq_setting
|
|
|
|
else
|
2017-04-12 14:46:06 +03:00
|
|
|
LOCAL_SERVICES+=("rabbitmq-server")
|
2018-10-22 10:50:30 +03:00
|
|
|
# allow Rabbitmq startup after container kill
|
|
|
|
rm -rf /var/run/rabbitmq
|
2016-07-11 11:47:22 +03:00
|
|
|
fi
|
2016-06-30 12:41:52 +03:00
|
|
|
|
2016-07-20 18:56:20 +03:00
|
|
|
if [ ${REDIS_SERVER_HOST} != "localhost" ]; then
|
|
|
|
update_redis_settings
|
|
|
|
else
|
2017-04-12 14:46:06 +03:00
|
|
|
LOCAL_SERVICES+=("redis-server")
|
2016-07-11 11:47:22 +03:00
|
|
|
fi
|
2016-07-20 18:56:20 +03:00
|
|
|
else
|
|
|
|
# no need to update settings just wait for remote data
|
|
|
|
waiting_for_datacontainer
|
|
|
|
|
|
|
|
# read settings after the data container in ready state
|
|
|
|
# to prevent get unconfigureted data
|
|
|
|
read_setting
|
2016-06-30 12:41:52 +03:00
|
|
|
fi
|
|
|
|
|
2016-07-20 18:56:20 +03:00
|
|
|
#start needed local services
|
|
|
|
for i in ${LOCAL_SERVICES[@]}; do
|
|
|
|
service $i start
|
|
|
|
done
|
|
|
|
|
2017-04-24 20:02:01 +03:00
|
|
|
if [ ${PG_NEW_CLUSTER} = "true" ]; then
|
2017-04-25 14:29:24 +03:00
|
|
|
create_postgresql_db
|
2017-04-24 20:02:01 +03:00
|
|
|
create_postgresql_tbl
|
|
|
|
fi
|
|
|
|
|
2016-07-11 11:47:22 +03:00
|
|
|
if [ ${ONLYOFFICE_DATA_CONTAINER} != "true" ]; then
|
2016-08-25 19:52:14 +03:00
|
|
|
waiting_for_postgresql
|
2019-01-28 15:47:32 +03:00
|
|
|
waiting_for_amqp
|
2016-07-11 11:47:22 +03:00
|
|
|
waiting_for_redis
|
2016-07-20 18:56:20 +03:00
|
|
|
|
|
|
|
update_nginx_settings
|
|
|
|
|
|
|
|
update_supervisor_settings
|
|
|
|
service supervisor start
|
2018-06-25 14:58:17 +03:00
|
|
|
|
|
|
|
# start cron to enable log rotating
|
2018-11-20 17:06:53 +03:00
|
|
|
update_logrotate_settings
|
2018-06-25 14:58:17 +03:00
|
|
|
service cron start
|
2016-07-11 11:47:22 +03:00
|
|
|
fi
|
2016-06-30 12:41:52 +03:00
|
|
|
|
2016-07-20 18:56:20 +03:00
|
|
|
# nginx used as a proxy, and as data container status service.
|
|
|
|
# it run in all cases.
|
|
|
|
service nginx start
|
|
|
|
|
2016-06-30 12:41:52 +03:00
|
|
|
# Regenerate the fonts list and the fonts thumbnails
|
2016-07-12 17:27:04 +03:00
|
|
|
documentserver-generate-allfonts.sh ${ONLYOFFICE_DATA_CONTAINER}
|
2018-01-29 11:56:51 +03:00
|
|
|
documentserver-static-gzip.sh ${ONLYOFFICE_DATA_CONTAINER}
|
2018-04-12 21:41:24 +00:00
|
|
|
|
2018-05-04 19:31:10 +03:00
|
|
|
tail -f /var/log/onlyoffice/**/*.log
|