Skip to content

Commit

Permalink
Add example (#61)
Browse files Browse the repository at this point in the history
* Add example
  • Loading branch information
romandemidov authored Mar 10, 2021
1 parent 21bf176 commit 7a26d9d
Show file tree
Hide file tree
Showing 14 changed files with 324 additions and 4 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ If you'd like to change the JSON Web Token parameters, run:
# snap set onlyoffice-ds onlyoffice.key=value
```

### Enabling the Example

By default, example is not enabled. You can enable the example, using the command:

```
# snap set onlyoffice-ds onlyoffice.example-enabled=true
```

## Project Information

Official website: [https://www.onlyoffice.com/apps.aspx](https://www.onlyoffice.com/apps.aspx/?utm_source=github&utm_medium=cpc&utm_campaign=GitHubSnap)
Expand Down
8 changes: 8 additions & 0 deletions bin/documentserver-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ 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/spellchecker/
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
Expand All @@ -25,4 +26,11 @@ touch $SNAP_DATA/var/log/onlyoffice/documentserver/spellchecker/err.log
touch $SNAP_DATA/var/log/onlyoffice/documentserver-example/out.log
touch $SNAP_DATA/var/log/onlyoffice/documentserver-example/err.log

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
else
sed -i -e 's/autostart=true/autostart=false/' $SNAP_DATA/etc/supervisor/conf.d/ds-example.conf
fi

$SNAP/usr/bin/python $SNAP/usr/bin/supervisord -n -c $SNAP_DATA/etc/supervisor/supervisord.conf
13 changes: 13 additions & 0 deletions config/ds-example.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[program:example]
command=node %(ENV_SNAP)s/var/www/onlyoffice/documentserver-example/nodejs/bin/www
directory=%(ENV_SNAP)s/var/www/onlyoffice/documentserver-example/nodejs/bin/
environment=NODE_ENV=production-linux,NODE_CONFIG_DIR=%(ENV_SNAP_DATA)s/etc/onlyoffice/documentserver-example,NODE_DISABLE_COLORS=1
stdout_logfile=%(ENV_SNAP_DATA)s/var/log/onlyoffice/documentserver-example/out.log
stdout_logfile_backups=0
stdout_logfile_maxbytes=0
stderr_logfile=%(ENV_SNAP_DATA)s/var/log/onlyoffice/documentserver-example/err.log
stderr_logfile_backups=0
stderr_logfile_maxbytes=0
autostart=false
autorestart=true
redirect_stderr=true
6 changes: 6 additions & 0 deletions config/ds-ssl.conf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,10 @@ server {
proxy_pass http://localhost:8080/;
proxy_http_version 1.1;
}
location /example/ {
proxy_pass http://localhost:3000/;
proxy_set_header Host $the_host/example;
proxy_set_header X-Forwarded-Proto $the_scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
2 changes: 1 addition & 1 deletion config/ds.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[group:ds]
programs=docservice,converter,spellchecker
programs=docservice,converter,spellchecker,example
6 changes: 6 additions & 0 deletions config/ds.conf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,11 @@ server {
proxy_pass http://localhost:8080/;
proxy_http_version 1.1;
}
location /example/ {
proxy_pass http://localhost:3000/;
proxy_set_header Host $the_host/example;
proxy_set_header X-Forwarded-Proto $the_scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

44 changes: 43 additions & 1 deletion snap/hooks/configure
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ DEFAULT_DB_PORT="3306"
DEFAULT_JWT_ENABLED="false"
DEFAULT_JWT_SECRET="secret"
DEFAULT_JWT_HEADER="Authorization"
DEFAULT_EXAMPLE_ENABLED="false"


nginx_onlyoffice_http_port()
Expand Down Expand Up @@ -268,11 +269,52 @@ set_previous_onlyoffice_jwt_header()
snapctl set private.onlyoffice.jwt-header="$1"
}

onlyoffice_example_enabled()
{
onlyoffice_example_enabled="$(onlyoffice_example_enabled)"
previous_onlyoffice_example_enabled="$(previous_onlyoffice_example_enabled)"

# If no changes were requested, then there's nothing to do here.
if [ "$onlyoffice_example_enabled" = "$previous_onlyoffice_example_enabled" ]; then
return 0
fi
set_onlyoffice_example_enabled "$onlyoffice_example_enabled"
set_previous_onlyoffice_example_enabled $onlyoffice_example_enabled
}

set_onlyoffice_example_enabled()
{
snapctl set onlyoffice.example-enabled="$1"
}

onlyoffice_example_enabled()
{
port="$(snapctl get onlyoffice.example-enabled)"
if [ -z "$port" ]; then
port="$DEFAULT_EXAMPLE_ENABLED"
set_onlyoffice_example_enabled $port
set_previous_onlyoffice_example_enabled $port
fi

echo "$port"
}

previous_onlyoffice_example_enabled()
{
snapctl get private.onlyoffice.example-enabled
}

set_previous_onlyoffice_example_enabled()
{
snapctl set private.onlyoffice.example-enabled="$1"
}




nginx_onlyoffice_http_port && \
db_onlyoffice_db_port && \
token_onlyoffice_jwt_enabled && \
token_onlyoffice_jwt_secret && \
token_onlyoffice_jwt_header
token_onlyoffice_jwt_header && \
onlyoffice_example_enabled
7 changes: 7 additions & 0 deletions snap/hooks/post-refresh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
rm -R $SNAP_DATA/etc
rm -R $SNAP_DATA/mysql
mv $SNAP_DATA/var/www/onlyoffice/Data/certs $SNAP_DATA
if [ -d $SNAP_DATA/var/lib/onlyoffice/documentserver-example/files ]; then
mv $SNAP_DATA/var/lib/onlyoffice/documentserver-example/files $SNAP_DATA
fi
rm -R $SNAP_DATA/var
mkdir -p $SNAP_DATA/var/www/onlyoffice/Data
mv $SNAP_DATA/certs $SNAP_DATA/var/www/onlyoffice/Data
if [ -d $SNAP_DATA/files ]; then
mkdir -p $SNAP_DATA/var/lib/onlyoffice/documentserver-example
mv $SNAP_DATA/files $SNAP_DATA/var/lib/onlyoffice/documentserver-example
fi
cp -R $SNAP/etc $SNAP_DATA/

$SNAP/usr/sbin/generate-all-fonts.sh
25 changes: 23 additions & 2 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,21 @@ parts:
rm -r $SNAPCRAFT_PART_INSTALL/sdkjs-plugins
rm -r $SNAPCRAFT_PART_INSTALL/server
rm -r $SNAPCRAFT_PART_INSTALL/web-apps
rm -r $SNAPCRAFT_PART_INSTALL/example
DIR="$SNAPCRAFT_PART_INSTALL/var/www/onlyoffice/documentserver"
mkdir -p $DIR
mkdir -p $DIR-example
rm -r ./server/welcome
mv ./example/* $DIR-example
rm -r ./example
cp -r * $DIR
mkdir -p $SNAPCRAFT_PART_INSTALL/etc/onlyoffice/documentserver
mv $DIR/server/Common/config/* $SNAPCRAFT_PART_INSTALL/etc/onlyoffice/documentserver
DIR_ETC="$SNAPCRAFT_PART_INSTALL/etc/onlyoffice/documentserver"
mkdir -p $DIR_ETC
mv $DIR/server/Common/config/* $DIR_ETC
#example
mkdir -p $DIR_ETC-example
sed -i -e 's/\/var\/lib\/onlyoffice/\/var\/snap\/onlyoffice-ds\/current\/var\/lib\/onlyoffice/' $DIR-example/nodejs/config/production-linux.json
mv $DIR-example/nodejs/config/* $DIR_ETC-example
# documentserver-generate-allfonts.sh
OUTDIR="/var/snap/onlyoffice-ds/current/var/www/onlyoffice/documentserver"
#fonts
Expand Down Expand Up @@ -281,6 +291,7 @@ parts:
ds-docservice.conf: etc/supervisor/conf.d/ds-docservice.conf
ds-converter.conf: etc/supervisor/conf.d/ds-converter.conf
ds-spellchecker.conf: etc/supervisor/conf.d/ds-spellchecker.conf
ds-example.conf: etc/supervisor/conf.d/ds-example.conf
ds.conf: etc/supervisor/conf.d/ds.conf
ds.conf.tmpl: etc/onlyoffice/documentserver/nginx/ds.conf.tmpl
ds-ssl.conf.tmpl: etc/onlyoffice/documentserver/nginx/ds-ssl.conf.tmpl
Expand All @@ -294,3 +305,13 @@ parts:
nginx-start.sh: usr/sbin/nginx-start.sh
generate-all-fonts.sh: usr/sbin/generate-all-fonts.sh

welcome:
plugin: dump
source: ./welcome/
organize:
index.html: var/www/onlyoffice/documentserver/server/welcome/index.html
css/favicon.ico: var/www/onlyoffice/documentserver/server/welcome/css/favicon.ico
css/logo.png: var/www/onlyoffice/documentserver/server/welcome/css/logo.png
css/[email protected]: var/www/onlyoffice/documentserver/server/welcome/css/[email protected]
css/stylesheet.css: var/www/onlyoffice/documentserver/server/welcome/css/stylesheet.css

Binary file added welcome/css/favicon.ico
Binary file not shown.
Binary file added welcome/css/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added welcome/css/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
129 changes: 129 additions & 0 deletions welcome/css/stylesheet.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/*
*
* (c) Copyright Ascensio System Limited 2010-2020
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at [email protected]
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/

html {
height: 100%;
width: 100%;
}

body {
background: #fff;
color: #333;
font-family: 'Open Sans', sans-serif;
font-size: 12px;
font-weight: normal;
height: 100%;
margin: 0;
padding: 0;
text-decoration: none;
}

form {
height: 100%;
}

div {
margin: 0;
padding: 0;
}

a, a:hover, a:visited {
color: #333;
}

header {
height: 44px;
background: #3D4A6B;
height: 80px;
margin: 0 auto;
min-width: 600px;
width: auto;
}

header img {
margin: 12px 0 0 16px;
}

.main-panel {
margin: 80px auto 16px;
width: 600px;
}

.portal-name {
font-size: 20px;
}

.portal-descr {
display: inline-block;
line-height: 20px;
margin-bottom: 20px;
width: 600px;
}

pre {
border: 1px solid #CCC;
background-color: #fff;
border-radius: 3px;
display: block;
font-family: Monaco,Andale Mono,Courier New,monospace;
font-size: 12px;
line-height: 18px;
margin: 18px 0 24px;
padding: 8px;
white-space: pre-wrap;
word-wrap: break-word;
}

pre.hljs {
padding-left: 35px;
}

.features-list {
padding-left: 16px;
list-style: outside none disc;
line-height: 20px;
margin-bottom: 20px;
margin-top: 0px;
}

footer {
text-align: right;
width: auto;
margin-bottom: 15px;
margin-right: 15px;
}

.help-block span {
font-size: 16px;
line-height: 26px;
}

.clearFix:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
Loading

0 comments on commit 7a26d9d

Please sign in to comment.