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

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

commite32b08f61681da42104bc94b7b3266e41a79c58b authorMarkus Heiser <markus.heiser@darmarit.de> dateFri 3 Apr 2020, 20:26 (7 years ago) parent853be4e
3 files changed+109−5
docs/build-templates/morty.rst+52 docs/utils/morty.sh.rst+29 utils/morty.sh+28−5
docs/build-templates/morty.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 morty
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/morty
51+
52+.. END install morty
docs/utils/morty.sh.rst+29
@@ -13,6 +13,7 @@
1313
1414 - :ref:`installation`
1515 - :ref:`architecture`
16+ - :ref:`searx morty`
1617
1718To simplify installation and maintenance of a morty_ instance you can use the
1819script :origin:`utils/morty.sh`. In most cases you will install morty_ simply by
@@ -37,6 +38,34 @@ into this user account:
3738
3839 To add morty to your searx instance read chapter :ref:`searx morty`.
3940
41+Create user
42+===========
43+
44+.. include:: ../../build/docs/includes/morty.rst
45+ :start-after: START create user
46+ :end-before: END create user
47+
48+
49+Install go
50+==========
51+
52+.. include:: ../../build/docs/includes/morty.rst
53+ :start-after: START install go
54+ :end-before: END install go
55+
56+
57+Install morty
58+=============
59+
60+Install morty software and systemd unit:
61+
62+.. include:: ../../build/docs/includes/morty.rst
63+ :start-after: START install morty
64+ :end-before: END install morty
65+
66+.. include:: ../../build/docs/includes/morty.rst
67+ :start-after: START install systemd unit
68+ :end-before: END install systemd unit
4069
4170Overview
4271========
utils/morty.sh+28−5
@@ -194,11 +194,7 @@ main() {
194194 debug-off) disable_debug ;;
195195 *) usage "$_usage"; exit 42;;
196196 esac ;;
197− doc)
198− echo
199− echo ".. generic utils/morty.sh documentation"
200− ;;
201−
197+ doc) rst-doc ;;
202198 *) usage "ERROR: unknown or missing command $1"; exit 42;;
203199 esac
204200}
@@ -436,6 +432,33 @@ This removes apache site ${APACHE_MORTY_SITE}."
436432 apache_remove_site "$APACHE_MORTY_SITE"
437433}
438434
435+rst-doc() {
436+
437+ eval "echo \"$(< "${REPO_ROOT}/docs/build-templates/morty.rst")\""
438+
439+ echo -e "\n.. START install systemd unit"
440+ cat <<EOF
441+.. tabs::
442+
443+ .. group-tab:: systemd
444+
445+ .. code:: bash
446+
447+EOF
448+ eval "echo \"$(< "${TEMPLATES}/${SERVICE_SYSTEMD_UNIT}")\"" | prefix_stdout " "
449+ echo -e "\n.. END install systemd unit"
450+
451+ # for DIST_NAME in ubuntu-20.04 arch fedora; do
452+ # (
453+ # DIST_ID=${DIST_NAME%-*}
454+ # DIST_VERS=${DIST_NAME#*-}
455+ # [[ $DIST_VERS =~ $DIST_ID ]] && DIST_VERS=
456+ # # ...
457+ # )
458+ # done
459+}
460+
461+
439462# ----------------------------------------------------------------------------
440463main "$@"
441464# ----------------------------------------------------------------------------