summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2020-04-03 20:24:40 +0200
committerMarkus Heiser <markus.heiser@darmarit.de>2020-04-03 20:24:40 +0200
commit853be4e11cd8a82b6b08f04db1717329907a5aaf (patch)
treeee62e8a28ff64208d63f583409ff6b535b23e408
parentaf988dbf71ce4b14d2056676d7d9691335266d83 (diff)
downloadsearxng-853be4e11cd8a82b6b08f04db1717329907a5aaf.tar.gz
searxng-853be4e11cd8a82b6b08f04db1717329907a5aaf.zip
utils/filtron.sh: add generic documentation
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
-rw-r--r--docs/admin/filtron.rst1
-rw-r--r--docs/build-templates/filtron.rst52
-rw-r--r--docs/utils/filtron.sh.rst32
-rwxr-xr-xutils/filtron.sh32
-rwxr-xr-xutils/searx.sh1
5 files changed, 112 insertions, 6 deletions
diff --git a/docs/admin/filtron.rst b/docs/admin/filtron.rst
index 970ce25d2..9615cd935 100644
--- a/docs/admin/filtron.rst
+++ b/docs/admin/filtron.rst
@@ -37,6 +37,7 @@ installed by ``go get`` package management (see `filtron README`_). If you use
filtron as middleware, a more isolated setup is recommended. To simplify such
an installation and the maintenance of, use our script :ref:`filtron.sh`.
+.. _Sample configuration of filtron:
Sample configuration of filtron
===============================
diff --git a/docs/build-templates/filtron.rst b/docs/build-templates/filtron.rst
new file mode 100644
index 000000000..83a451820
--- /dev/null
+++ b/docs/build-templates/filtron.rst
@@ -0,0 +1,52 @@
+.. START create user
+
+.. tabs::
+
+ .. group-tab:: bash
+
+ .. code-block:: sh
+
+ $ sudo -H useradd --shell /bin/bash --system \\
+ --home-dir "$SERVICE_HOME" \\
+ --comment "Privacy-respecting metasearch engine" $SERVICE_USER
+
+ $ sudo -H mkdir "$SERVICE_HOME"
+ $ sudo -H chown -R "$SERVICE_GROUP:$SERVICE_GROUP" "$SERVICE_HOME"
+
+.. END create user
+
+.. START install go
+
+.. tabs::
+
+ .. group-tab:: bash
+
+ .. code-block:: bash
+
+ $ cat > "$GO_ENV" <<EOF
+ export GOPATH=${SERVICE_HOME}/go-apps
+ export PATH=\$PATH:${SERVICE_HOME}/local/go/bin:\$GOPATH/bin
+ EOF
+ $ sudo -i -u "${SERVICE_USER}"
+ (${SERVICE_USER}) $ echo 'source $GO_ENV' >> ~/.profile
+ (${SERVICE_USER}) $ mkdir ${SERVICE_HOME}/local
+ (${SERVICE_USER}) $ wget --progress=bar -O "${GO_TAR}" \\
+ "${GO_PKG_URL}"
+ (${SERVICE_USER}) $ tar -C ${SERVICE_HOME}/local/go -xzf "${GO_TAR}"
+ (${SERVICE_USER}) $ which go
+ ${SERVICE_HOME}/local/go/bin/go
+
+.. END install go
+
+.. START install filtron
+
+.. tabs::
+
+ .. group-tab:: bash
+
+ .. code-block:: bash
+
+ $ sudo -i -u "${SERVICE_USER}"
+ (${SERVICE_USER}) $ go get -v -u github.com/asciimoo/filtron
+
+.. END install filtron
diff --git a/docs/utils/filtron.sh.rst b/docs/utils/filtron.sh.rst
index 40e57aa3c..a3c1aed41 100644
--- a/docs/utils/filtron.sh.rst
+++ b/docs/utils/filtron.sh.rst
@@ -36,6 +36,38 @@ into this user account:
<utils/templates/lib/systemd/system/filtron.service>`
(``/lib/systemd/system/filtron.service``).
+
+Create user
+===========
+
+.. include:: ../../build/docs/includes/filtron.rst
+ :start-after: START create user
+ :end-before: END create user
+
+
+Install go
+==========
+
+.. include:: ../../build/docs/includes/filtron.rst
+ :start-after: START install go
+ :end-before: END install go
+
+
+Install filtron
+===============
+
+Install :origin:`rules.json <utils/templates/etc/filtron/rules.json>` at
+``/etc/filtron/rules.json`` (see :ref:`Sample configuration of filtron`) and
+install filtron software and systemd unit:
+
+.. include:: ../../build/docs/includes/filtron.rst
+ :start-after: START install filtron
+ :end-before: END install filtron
+
+.. include:: ../../build/docs/includes/filtron.rst
+ :start-after: START install systemd unit
+ :end-before: END install systemd unit
+
.. _filtron.sh overview:
Overview
diff --git a/utils/filtron.sh b/utils/filtron.sh
index 208166fda..d2be60737 100755
--- a/utils/filtron.sh
+++ b/utils/filtron.sh
@@ -186,11 +186,7 @@ main() {
debug-off) echo; disable_debug ;;
*) usage "$_usage"; exit 42;;
esac ;;
- doc)
- echo
- echo ".. generic utils/filtron.sh documentation"
- ;;
-
+ doc) rst-doc ;;
*) usage "unknown or missing command $1"; exit 42;;
esac
}
@@ -469,6 +465,32 @@ This removes apache site ${APACHE_FILTRON_SITE}."
apache_remove_site "$APACHE_FILTRON_SITE"
}
+rst-doc() {
+
+ eval "echo \"$(< "${REPO_ROOT}/docs/build-templates/filtron.rst")\""
+
+ echo -e "\n.. START install systemd unit"
+ cat <<EOF
+.. tabs::
+
+ .. group-tab:: systemd
+
+ .. code:: bash
+
+EOF
+ eval "echo \"$(< "${TEMPLATES}/${SERVICE_SYSTEMD_UNIT}")\"" | prefix_stdout " "
+ echo -e "\n.. END install systemd unit"
+
+ # for DIST_NAME in ubuntu-20.04 arch fedora; do
+ # (
+ # DIST_ID=${DIST_NAME%-*}
+ # DIST_VERS=${DIST_NAME#*-}
+ # [[ $DIST_VERS =~ $DIST_ID ]] && DIST_VERS=
+ # # ...
+ # )
+ # done
+}
+
# ----------------------------------------------------------------------------
main "$@"
# ----------------------------------------------------------------------------
diff --git a/utils/searx.sh b/utils/searx.sh
index 981c498fc..5b118478e 100755
--- a/utils/searx.sh
+++ b/utils/searx.sh
@@ -248,7 +248,6 @@ main() {
*) usage "$_usage"; exit 42;;
esac ;;
doc) rst-doc;;
-
*) usage "unknown or missing command $1"; exit 42;;
esac
}