From 2e71b60248acd0d044c5529c3148700fdc143ad0 Mon Sep 17 00:00:00 2001 From: ston1th Date: Sat, 3 Aug 2019 20:48:12 +0200 Subject: [PATCH] added linux install script --- README.md | 2 +- pkg/index/index.go | 4 ++++ pkg/server/context.go | 2 +- scripts/install_linux.sh | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100755 scripts/install_linux.sh diff --git a/README.md b/README.md index c4926d5..200275c 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ GOOS=openbsd make vendor ## Install -See the `scripts/` directory on how to install docstore on OpenBSD. +See the `scripts/` directory on how to install docstore on Linux or OpenBSD. ## Config diff --git a/pkg/index/index.go b/pkg/index/index.go index c18cfff..d8364fd 100644 --- a/pkg/index/index.go +++ b/pkg/index/index.go @@ -36,6 +36,10 @@ func NewIndex(path string) (i *Index, err error) { if _, err = os.Stat(path); os.IsNotExist(err) { var m *mapping.IndexMappingImpl m, err = createMapping() + if err != nil { + err = errors.New("index: " + err.Error()) + return + } //m := bleve.NewIndexMapping() bi, err = bleve.New(path, m) if err != nil { diff --git a/pkg/server/context.go b/pkg/server/context.go index 8040156..64adc5e 100644 --- a/pkg/server/context.go +++ b/pkg/server/context.go @@ -33,7 +33,7 @@ func newContext(w http.ResponseWriter, r *http.Request, s *HTTPServer) *Context h.Set("X-Frame-Options", "sameorigin") h.Set("X-Content-Type-Options", "nosniff") h.Set("X-XSS-Protection", "1; mode=block") - h.Set("Content-Security-Policy", "default-src 'none';object-src 'self';frame-src 'self';style-src 'self';img-src 'self' data:;connect-src 'self';frame-ancestors 'self'") + h.Set("Content-Security-Policy", "default-src 'none';object-src 'self';frame-src 'self';style-src 'self';img-src 'self' data:;media-src 'self';connect-src 'self';frame-ancestors 'self'") h.Set("Referrer-Policy", "same-origin") return &Context{ Request: r, diff --git a/scripts/install_linux.sh b/scripts/install_linux.sh new file mode 100755 index 0000000..cf3719c --- /dev/null +++ b/scripts/install_linux.sh @@ -0,0 +1,36 @@ +#!/bin/sh +groupadd docstore +useradd -g docstore docstore +mkdir /var/lib/docstore +chown docstore: /var/lib/docstore +mkdir /etc/docstore +cat < /etc/docstore/docstore.conf +{ + "run_dir": "/var/lib/docstore", + "listen_addr": "0.0.0.0:8080", + "secret": "$(openssl rand -hex 32)" + "langs": ["deu"], + "cmd_timeout": 6000, + "debug": true +} +EOF +cat < /etc/systemd/system/docstore.service +[Unit] +Description=DocStore +After=syslog.target +After=network.target + +[Service] +Type=forking +ExecStart=/usr/local/bin/docstore server -c /etc/docstore/docstore.conf +Restart=always + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable docstore +cat <