on master help sign in
utils/filtron.sh: add generic documentation

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>

commit853be4e11cd8a82b6b08f04db1717329907a5aaf authorMarkus Heiser <markus.heiser@darmarit.de> dateFri 3 Apr 2020, 20:24 (7 years ago) parentaf988db
5 files changed+112−6
docs/admin/filtron.rst+1 docs/build-templates/filtron.rst+52 docs/utils/filtron.sh.rst+32 utils/filtron.sh+27−5 utils/searx.sh−1
docs/admin/filtron.rst+1
@@ -37,6 +37,7 @@ installed by ``go get`` package management (see `filtron README`_). If you use
3737filtron as middleware, a more isolated setup is recommended. To simplify such
3838an installation and the maintenance of, use our script :ref:`filtron.sh`.
3939
40+.. _Sample configuration of filtron:
4041
4142Sample configuration of filtron
4243===============================
docs/build-templates/filtron.rstnew file+52
@@ -0,0 +1,52 @@
1+.. START create user
2+
3+.. tabs::
4+
5+ .. group-tab:: bash
6+
7+ .. code-block:: sh
8+
9+ $ sudo -H useradd --shell /bin/bash --system \\
10+ --home-dir "$SERVICE_HOME" \\
11+ --comment "Privacy-respecting metasearch engine" $SERVICE_USER
12+
13+ $ sudo -H mkdir "$SERVICE_HOME"
14+ $ sudo -H chown -R "$SERVICE_GROUP:$SERVICE_GROUP" "$SERVICE_HOME"
15+
16+.. END create user
17+
18+.. START install go
19+
20+.. tabs::
21+
22+ .. group-tab:: bash
23+
24+ .. code-block:: bash
25+
26+ $ cat > "$GO_ENV" <<EOF
27+ export GOPATH=${SERVICE_HOME}/go-apps
28+ export PATH=\$PATH:${SERVICE_HOME}/local/go/bin:\$GOPATH/bin
29+ EOF
30+ $ sudo -i -u "${SERVICE_USER}"
31+ (${SERVICE_USER}) $ echo 'source $GO_ENV' >> ~/.profile
32+ (${SERVICE_USER}) $ mkdir ${SERVICE_HOME}/local
33+ (${SERVICE_USER}) $ wget --progress=bar -O "${GO_TAR}" \\
34+ "${GO_PKG_URL}"
35+ (${SERVICE_USER}) $ tar -C ${SERVICE_HOME}/local/go -xzf "${GO_TAR}"
36+ (${SERVICE_USER}) $ which go
37+ ${SERVICE_HOME}/local/go/bin/go
38+
39+.. END install go
40+
41+.. START install filtron
42+
43+.. tabs::
44+
45+ .. group-tab:: bash
46+
47+ .. code-block:: bash
48+
49+ $ sudo -i -u "${SERVICE_USER}"
50+ (${SERVICE_USER}) $ go get -v -u github.com/asciimoo/filtron
51+
52+.. END install filtron
docs/utils/filtron.sh.rst+32
@@ -36,6 +36,38 @@ into this user account:
3636 <utils/templates/lib/systemd/system/filtron.service>`
3737 (``/lib/systemd/system/filtron.service``).
3838
39+
40+Create user
41+===========
42+
43+.. include:: ../../build/docs/includes/filtron.rst
44+ :start-after: START create user
45+ :end-before: END create user
46+
47+
48+Install go
49+==========
50+
51+.. include:: ../../build/docs/includes/filtron.rst
52+ :start-after: START install go
53+ :end-before: END install go
54+
55+
56+Install filtron
57+===============
58+
59+Install :origin:`rules.json <utils/templates/etc/filtron/rules.json>` at
60+``/etc/filtron/rules.json`` (see :ref:`Sample configuration of filtron`) and
61+install filtron software and systemd unit:
62+
63+.. include:: ../../build/docs/includes/filtron.rst
64+ :start-after: START install filtron
65+ :end-before: END install filtron
66+
67+.. include:: ../../build/docs/includes/filtron.rst
68+ :start-after: START install systemd unit
69+ :end-before: END install systemd unit
70+
3971.. _filtron.sh overview:
4072
4173Overview
utils/filtron.sh+27−5
@@ -186,11 +186,7 @@ main() {
186186 debug-off) echo; disable_debug ;;
187187 *) usage "$_usage"; exit 42;;
188188 esac ;;
189− doc)
190− echo
191− echo ".. generic utils/filtron.sh documentation"
192− ;;
193−
189+ doc) rst-doc ;;
194190 *) usage "unknown or missing command $1"; exit 42;;
195191 esac
196192}
@@ -469,6 +465,32 @@ This removes apache site ${APACHE_FILTRON_SITE}."
469465 apache_remove_site "$APACHE_FILTRON_SITE"
470466}
471467
468+rst-doc() {
469+
470+ eval "echo \"$(< "${REPO_ROOT}/docs/build-templates/filtron.rst")\""
471+
472+ echo -e "\n.. START install systemd unit"
473+ cat <<EOF
474+.. tabs::
475+
476+ .. group-tab:: systemd
477+
478+ .. code:: bash
479+
480+EOF
481+ eval "echo \"$(< "${TEMPLATES}/${SERVICE_SYSTEMD_UNIT}")\"" | prefix_stdout " "
482+ echo -e "\n.. END install systemd unit"
483+
484+ # for DIST_NAME in ubuntu-20.04 arch fedora; do
485+ # (
486+ # DIST_ID=${DIST_NAME%-*}
487+ # DIST_VERS=${DIST_NAME#*-}
488+ # [[ $DIST_VERS =~ $DIST_ID ]] && DIST_VERS=
489+ # # ...
490+ # )
491+ # done
492+}
493+
472494# ----------------------------------------------------------------------------
473495main "$@"
474496# ----------------------------------------------------------------------------
utils/searx.sh−1
@@ -248,7 +248,6 @@ main() {
248248 *) usage "$_usage"; exit 42;;
249249 esac ;;
250250 doc) rst-doc;;
251−
252251 *) usage "unknown or missing command $1"; exit 42;;
253252 esac
254253}