Skip to content

Commit

Permalink
Fix bug 66342 : Add ability to enable WOPI via 'snap set' (#145)
Browse files Browse the repository at this point in the history
* Fix bug 66342 : Add ability to enable WOPI via 'snap set'

* Small changes

* Small changes

* Small changes

* Update local.json

* Update local.json
  • Loading branch information
romandemidov authored Feb 15, 2024
1 parent 8e22755 commit 85dd378
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 2 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ If you'd like to change the JSON Web Token parameters, run:
# snap set onlyoffice-ds onlyoffice.key=value
```

#### Allow document server to use WOPI protocol

By default, document server is prevented from using a WOPI protocol. To allow it, run:

```
# snap set onlyoffice-ds onlyoffice.wopi=true
```

### Enabling the Example

By default, example is not enabled. You can enable the example, using the command:
Expand Down
7 changes: 7 additions & 0 deletions bin/documentserver-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ else
sed -i -e 's/"rejectUnauthorized": false/"rejectUnauthorized": true/' $DS_CONF_DIR/local.json
fi

WOPI_ENABLED=$(snapctl get onlyoffice.wopi)
if [ "${WOPI_ENABLED}" == "true" ]; then
sed -i -e 's/"enable": false/"enable": true/' $DS_CONF_DIR/local.json
else
sed -i -e 's/"enable": true/"enable": false/' $DS_CONF_DIR/local.json
fi

export LC_ALL=C.UTF-8

#check fonts
Expand Down
2 changes: 1 addition & 1 deletion config/local.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
}
},
"wopi": {
"enable": false,
"htmlTemplate" : "/snap/onlyoffice-ds/current/var/www/onlyoffice/documentserver/web-apps/apps/api/wopi"
},
"services": {
Expand Down Expand Up @@ -107,4 +108,3 @@
}
}
}

50 changes: 49 additions & 1 deletion snap/hooks/configure
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ DEFAULT_JWT_HEADER="Authorization"
DEFAULT_EXAMPLE_ENABLED="false"
DEFAULT_USE_UNAUTHORIZED_STORAGE="false"
DEFAULT_LOOPBACK="false"
DEFAULT_WOPI="false"


# onlyoffice.ds-port
# onlyoffice.ds-ssl-port
Expand Down Expand Up @@ -418,6 +420,50 @@ set_previous_onlyoffice_loopback()
}


# onlyoffice.wopi

token_onlyoffice_wopi()
{
onlyoffice_wopi="$(onlyoffice_wopi)"
previous_onlyoffice_wopi="$(previous_onlyoffice_wopi)"

if [ "$onlyoffice_wopi" = "$previous_onlyoffice_wopi" ]; then
return 0
fi
set_onlyoffice_wopi "$onlyoffice_wopi"
set_previous_onlyoffice_wopi "$onlyoffice_wopi"

snapctl restart onlyoffice-ds.nginx
snapctl restart onlyoffice-ds.documentserver
}

set_onlyoffice_wopi()
{
snapctl set onlyoffice.wopi="$1"
}

onlyoffice_wopi()
{
param="$(snapctl get onlyoffice.wopi)"
if [ -z "$param" ]; then
param="$DEFAULT_WOPI"
set_onlyoffice_wopi $param
set_previous_onlyoffice_wopi $param
fi

echo "$param"
}

previous_onlyoffice_wopi()
{
snapctl get private.onlyoffice.wopi
}

set_previous_onlyoffice_wopi()
{
snapctl set private.onlyoffice.wopi="$1"
}


nginx_onlyoffice_http_port && \
db_onlyoffice_db_port && \
Expand All @@ -426,4 +472,6 @@ token_onlyoffice_jwt_secret && \
token_onlyoffice_jwt_header && \
onlyoffice_example_enabled && \
onlyoffice_use_unautorized_storage && \
token_onlyoffice_loopback
token_onlyoffice_loopback && \
token_onlyoffice_wopi

2 changes: 2 additions & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ parts:
BUILD_NUMBER=`cat var/www/onlyoffice/documentserver/server/Common/sources/commondefines.js | grep "const buildNumber" | grep -o "[0-9]*"`
echo $BUILD_VERSION-$BUILD_NUMBER > $CRAFT_STAGE/version
cp -r $DIR/server/Common/node_modules/ms $DIR/server/FileConverter/node_modules/
#fix wopi enable page
sed -i -e '/wopi.enable/c <br />Set the <b>onlyoffice.wopi</b> parameter in the Document Server snap configuration to <b>true</b>.' $DIR-example/nodejs/views/wopiIndex.ejs
node:
plugin: dump
Expand Down

0 comments on commit 85dd378

Please sign in to comment.