Skip to content

Commit

Permalink
Refactoring (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
romandemidov authored Feb 15, 2024
1 parent 22ed6fb commit 8e22755
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
17 changes: 7 additions & 10 deletions bin/documentserver-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,31 @@ touch $SNAP_DATA/var/run/supervisord.pid

mkdir -p $SNAP_DATA/var/log/onlyoffice/documentserver/docservice/
mkdir -p $SNAP_DATA/var/log/onlyoffice/documentserver/converter/
mkdir -p $SNAP_DATA/var/log/onlyoffice/documentserver/gc/
mkdir -p $SNAP_DATA/var/log/onlyoffice/documentserver/metrics/
mkdir -p $SNAP_DATA/var/log/onlyoffice/documentserver-example/
mkdir -p $SNAP_DATA/var/lib/onlyoffice/documentserver-example/files/

touch $SNAP_DATA/var/log/onlyoffice/documentserver/docservice/out.log
touch $SNAP_DATA/var/log/onlyoffice/documentserver/docservice/err.log
touch $SNAP_DATA/var/log/onlyoffice/documentserver/converter/out.log
touch $SNAP_DATA/var/log/onlyoffice/documentserver/converter/err.log
touch $SNAP_DATA/var/log/onlyoffice/documentserver/gc/out.log
touch $SNAP_DATA/var/log/onlyoffice/documentserver/gc/err.log
touch $SNAP_DATA/var/log/onlyoffice/documentserver/metrics/out.log
touch $SNAP_DATA/var/log/onlyoffice/documentserver/metrics/err.log
touch $SNAP_DATA/var/log/onlyoffice/documentserver-example/out.log
touch $SNAP_DATA/var/log/onlyoffice/documentserver-example/err.log

SUPERVISOR_CONF_DIR=$SNAP_DATA/etc/supervisor/conf.d
DS_CONF_DIR=$SNAP_DATA/etc/onlyoffice/documentserver

EXAMPLE_ENABLED=$(snapctl get onlyoffice.example-enabled)
if [ "${EXAMPLE_ENABLED}" == "true" ]; then
sed -i -e 's/autostart=false/autostart=true/' $SNAP_DATA/etc/supervisor/conf.d/ds-example.conf
sed -i -e 's/autostart=false/autostart=true/' $SUPERVISOR_CONF_DIR/ds-example.conf
else
sed -i -e 's/autostart=true/autostart=false/' $SNAP_DATA/etc/supervisor/conf.d/ds-example.conf
sed -i -e 's/autostart=true/autostart=false/' $SUPERVISOR_CONF_DIR/ds-example.conf
fi

USE_UNAUTHORIZED_STORAGE_ENABLED=$(snapctl get onlyoffice.use-unautorized-storage)
if [ "${USE_UNAUTHORIZED_STORAGE_ENABLED}" == "true" ]; then
sed -i -e 's/"rejectUnauthorized": true/"rejectUnauthorized": false/' /var/snap/onlyoffice-ds/current/etc/onlyoffice/documentserver/local.json
sed -i -e 's/"rejectUnauthorized": true/"rejectUnauthorized": false/' $DS_CONF_DIR/local.json
else
sed -i -e 's/"rejectUnauthorized": false/"rejectUnauthorized": true/' /var/snap/onlyoffice-ds/current/etc/onlyoffice/documentserver/local.json
sed -i -e 's/"rejectUnauthorized": false/"rejectUnauthorized": true/' $DS_CONF_DIR/local.json
fi

export LC_ALL=C.UTF-8
Expand Down
31 changes: 24 additions & 7 deletions snap/hooks/configure
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
if [ ! -f $SNAP_DATA/mysql/my.cnf ]; then
cp $SNAP/my.cnf $SNAP_DATA/mysql/my.cnf
fi

DEFAULT_HTTP_PORT="80"
DEFAULT_HTTPS_PORT="443"
DEFAULT_DB_PORT="3306"
Expand All @@ -13,6 +14,8 @@ DEFAULT_EXAMPLE_ENABLED="false"
DEFAULT_USE_UNAUTHORIZED_STORAGE="false"
DEFAULT_LOOPBACK="false"

# onlyoffice.ds-port
# onlyoffice.ds-ssl-port

nginx_onlyoffice_http_port()
{
Expand Down Expand Up @@ -91,6 +94,8 @@ set_previous_onlyoffice_https_port()
}


# onlyoffice.db-port

db_onlyoffice_db_port()
{
onlyoffice_db_port="$(onlyoffice_db_port)"
Expand Down Expand Up @@ -135,7 +140,7 @@ set_previous_onlyoffice_db_port()
}



# onlyoffice.jwt-enabled

token_onlyoffice_jwt_enabled()
{
Expand Down Expand Up @@ -181,15 +186,18 @@ set_previous_onlyoffice_jwt_enabled()

update_jwt_enabled_settings()
{
sed -i "/browser/s/"${previous_onlyoffice_jwt_enabled}"/"${onlyoffice_jwt_enabled}"/g" $SNAP_DATA/etc/onlyoffice/documentserver/local.json
sed -i "/inbox/s/"${previous_onlyoffice_jwt_enabled}"/"${onlyoffice_jwt_enabled}"/g" $SNAP_DATA/etc/onlyoffice/documentserver/local.json
sed -i "/outbox/s/"${previous_onlyoffice_jwt_enabled}"/"${onlyoffice_jwt_enabled}"/g" $SNAP_DATA/etc/onlyoffice/documentserver/local.json
DS_CONF_DIR=$SNAP_DATA/etc/onlyoffice/documentserver
DS_EXAMPLE_CONF_DIR=$SNAP_DATA/etc/onlyoffice/documentserver-example

sed -i "/enable/s/"${previous_onlyoffice_jwt_enabled}"/"${onlyoffice_jwt_enabled}"/g" $SNAP_DATA/etc/onlyoffice/documentserver-example/local.json
}
sed -i "/browser/s/"${previous_onlyoffice_jwt_enabled}"/"${onlyoffice_jwt_enabled}"/g" $DS_CONF_DIR/local.json
sed -i "/inbox/s/"${previous_onlyoffice_jwt_enabled}"/"${onlyoffice_jwt_enabled}"/g" $DS_CONF_DIR/local.json
sed -i "/outbox/s/"${previous_onlyoffice_jwt_enabled}"/"${onlyoffice_jwt_enabled}"/g" $DS_CONF_DIR/local.json

sed -i "/enable/s/"${previous_onlyoffice_jwt_enabled}"/"${onlyoffice_jwt_enabled}"/g" $DS_EXAMPLE_CONF_DIR/local.json
}


# onlyoffice.jwt-secret

token_onlyoffice_jwt_secret()
{
Expand Down Expand Up @@ -239,7 +247,7 @@ set_previous_onlyoffice_jwt_secret()
}



# onlyoffice.jwt-header

token_onlyoffice_jwt_header()
{
Expand Down Expand Up @@ -278,6 +286,9 @@ set_previous_onlyoffice_jwt_header()
snapctl set private.onlyoffice.jwt-header="$1"
}


# onlyoffice.example-enabled

onlyoffice_example_enabled()
{
onlyoffice_example_enabled="$(onlyoffice_example_enabled)"
Expand Down Expand Up @@ -318,6 +329,9 @@ set_previous_onlyoffice_example_enabled()
snapctl set private.onlyoffice.example-enabled="$1"
}


# onlyoffice.use-unautorized-storage

onlyoffice_use_unautorized_storage()
{
onlyoffice_use_unautorized_storage="$(onlyoffice_use_unautorized_storage)"
Expand Down Expand Up @@ -358,6 +372,9 @@ set_previous_onlyoffice_use_unautorized_storage()
snapctl set private.onlyoffice.use-unautorized-storage="$1"
}


# onlyoffice.loopback

token_onlyoffice_loopback()
{
onlyoffice_loopback="$(onlyoffice_loopback)"
Expand Down

0 comments on commit 8e22755

Please sign in to comment.