Compare commits

...

3 Commits

Author SHA1 Message Date
Roman Demidov
2d665f7957 Small changes 2021-03-01 17:53:22 +03:00
Roman Demidov
a7334483d0 Small changes 2021-03-01 12:02:00 +03:00
Roman Demidov
b1239047d2 Add database update 2021-03-01 11:57:42 +03:00

@ -11,16 +11,31 @@ shopt -s globstar
APP_DIR="/var/www/${COMPANY_NAME}/documentserver"
DATA_DIR="/var/www/${COMPANY_NAME}/Data"
PRIVATE_DATA_DIR="${DATA_DIR}/.private"
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 ${PRIVATE_DATA_DIR}/release_date ]; then
PREV_RELEASE_DATE=$(head -n 1 ${PRIVATE_DATA_DIR}/release_date)
else
PREV_RELEASE_DATE="0"
fi
if [ "${RELEASE_DATE}" != "${PREV_RELEASE_DATE}" ]; then
mkdir -p ${PRIVATE_DATA_DIR}
echo ${RELEASE_DATE} > ${PRIVATE_DATA_DIR}/release_date
IS_UPGRADE="true";
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 +342,38 @@ 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"
for i in $(ls $APP_DIR/server/schema/postgresql/upgrade/upgrade*); do
$PSQL -f "${i}";
done
}
upgrade_mysql_tbl() {
CONNECTION_PARAMS="-h$DB_HOST -P$DB_PORT -u$DB_USER -p$DB_PWD -w"
MYSQL="mysql -q $CONNECTION_PARAMS"
for i in $(ls $APP_DIR/server/schema/mysql/upgrade/upgrade*); do
$MYSQL "$DB_NAME" < ${i} >/dev/null 2>&1;
done
}
create_postgresql_tbl() {
if [ -n "$DB_PWD" ]; then
export PGPASSWORD=$DB_PWD
@ -460,6 +507,7 @@ if [ ${ONLYOFFICE_DATA_CONTAINER_HOST} = "localhost" ]; then
update_db_settings
waiting_for_db
create_db_tbl
IS_UPGRADE="false"
else
# change rights for postgres directory
chown -R postgres:postgres ${PG_ROOT}
@ -518,6 +566,11 @@ done
if [ ${PG_NEW_CLUSTER} = "true" ]; then
create_postgresql_db
create_postgresql_tbl
IS_UPGRADE="false"
fi
if [ "${IS_UPGRADE}" = "true" ]; then
upgrade_db_tbl
fi
if [ ${ONLYOFFICE_DATA_CONTAINER} != "true" ]; then