on master help sign in
tooling box: simplify build enviroments

- no more need for a .config.mk - docs: use searx.brands environment - searx.sh, filtron.sh & morty.sh are sourcing utils/brand.env Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>

commit7b4cf2eb489d8f6c95ccac5af180254b78e7c460 authorMarkus Heiser <markus.heiser@darmarit.de> dateSun 29 Mar 2020, 15:09 (7 years ago) parent65b22be
9 files changed+44−50
.config.mk−13 .config.sh+15−20 Makefile+5−1 docs/conf.py+3−3 docs/dev/makefile.rst+1−2 utils/filtron.sh+5 utils/morty.sh+5−2 utils/searx.sh+9−8 utils/templates/etc/apache2/sites-available/morty.conf+1−1
.config.mkdeleted−13
@@ -1,13 +0,0 @@
1−# -*- coding: utf-8; mode: makefile-gmake -*-
2−# SPDX-License-Identifier: AGPL-3.0-or-later
3−#
4−# This environment is used by Makefile targets. If you not maintain your own
5−# searx brand, you normally not need to change the defaults (except SEARX_URL).
6−# Compare your settings here with file .config.sh used by the toolboxing in
7−# utils.
8−
9−export SEARX_URL:=$(or ${SEARX_URL},https://searx.me)
10−
11−export DOCS_URL:=$(or ${DOCS_URL},https://asciimoo.github.io/searx)
12−export GIT_URL:=$(or ${GIT_URL},https://github.com/asciimoo/searx)
13−
.config.sh+15−20
@@ -11,46 +11,41 @@
1111# adding them to you local brand (git branch)::
1212#
1313# git add .config
14−#
15−# Compare your settings here with file .config.mk used by the Makefile targets.
1614
1715# The public URL of the searx instance: PUBLIC_URL="https://mydomain.xy/searx"
18−# The default is taken from the Makefile environment (SEARX_URL).
19−PUBLIC_URL="${SEARX_URL:-http://$(uname -n)/searx}"
20−PUBLIC_HOST="${PUBLIC_HOST:-$(echo "$PUBLIC_URL" | sed -e 's/[^/]*\/\/\([^@]*@\)\?\([^:/]*\).*/\2/')}"
16+# The default is taken from ./utils/brand.env.
17+
18+PUBLIC_URL="${SEARX_URL}"
19+#PUBLIC_URL="http://$(uname -n)/searx"
2120
2221# searx.sh
2322# ---------
2423
25−SEARX_INTERNAL_URL="${SEARX_INTERNAL_URL:-127.0.0.1:8888}"
24+# SEARX_INTERNAL_URL="127.0.0.1:8888"
2625
27−# Only change, if you maintain a searx brand in your searx fork. The default is
28−# taken from the Makefile environment (DOCS_URL, GIT_URL).
29−SEARX_DOCS_URL="${DOCS_URL:-https://asciimoo.github.io/searx}"
30−SEARX_GIT_URL="${GIT_URL:-https://github.com/asciimoo/searx.git}"
31−SEARX_GIT_BRANCH="${SEARX_GIT_BRANCH:-master}"
26+# Only change, if you maintain a searx brand in your searx fork.
27+# GIT_BRANCH="${GIT_BRANCH:-master}"
3228
3329# filtron.sh
3430# ----------
3531
36−FILTRON_API="${FILTRON_API:-127.0.0.1:4005}"
37−FILTRON_LISTEN="${FILTRON_LISTEN:-127.0.0.1:4004}"
38−FILTRON_TARGET="${FILTRON_TARGET:-127.0.0.1:8888}"
32+# FILTRON_API="127.0.0.1:4005"
33+# FILTRON_LISTEN="127.0.0.1:4004"
34+# FILTRON_TARGET="127.0.0.1:8888"
3935
4036# morty.sh
4137# --------
4238
4339# morty listen address
44−MORTY_LISTEN="${MORTY_LISTEN:-127.0.0.1:3000}"
40+# MORTY_LISTEN="127.0.0.1:3000"
41+# PUBLIC_URL_PATH_MORTY="/morty"
4542
4643# system services
4744# ---------------
4845
46+# Common $HOME folder of the service accounts
47+# SERVICE_HOME_BASE="/usr/local"
48+
4949# **experimental**: Set SERVICE_USER to run all services by one account, but be
5050# aware that removing discrete components might conflict!
51−#
5251# SERVICE_USER=searx
53−
54−# Common $HOME folder of the service accounts
55−SERVICE_HOME_BASE="${SERVICE_HOME_BASE:-/usr/local}"
56−
Makefile+5−1
@@ -1,6 +1,10 @@
11# -*- coding: utf-8; mode: makefile-gmake -*-
22.DEFAULT_GOAL=help
3−include ./.config.mk
3+
4+export GIT_URL=https://github.com/asciimoo/searx
5+export SEARX_URL=https://searx.me
6+export DOCS_URL=https://asciimoo.github.io/searx
7+
48include utils/makefile.include
59
610PYOBJECTS = searx
docs/conf.py+3−3
@@ -5,10 +5,10 @@ from sphinx_build_tools import load_sphinx_config
55from searx.version import VERSION_STRING
66from pallets_sphinx_themes import ProjectLink
77
8−GIT_URL = os.environ.get("GIT_URL", "https://github.com/asciimoo/searx")
8+from searx.brand import GIT_URL
99GIT_BRANCH =os.environ.get("GIT_BRANCH", "master")
10−SEARX_URL = os.environ.get("SEARX_URL", "https://searx.me")
11−DOCS_URL = os.environ.get("DOCS_URL", "https://asciimoo.github.io/searx/")
10+from searx.brand import SEARX_URL
11+from searx.brand import DOCS_URL
1212
1313# Project --------------------------------------------------------------
1414
docs/dev/makefile.rst+1−2
@@ -44,8 +44,7 @@ Makefile setup
4444
4545.. _git stash: https://git-scm.com/docs/git-stash
4646
47−The main setup is done in the :origin:`.config.sh` (read :ref:`toolboxing
48−setup`)::
47+The main setup is done in the :origin:`Makefile`::
4948
5049 export SEARX_URL=https://searx.me
5150
utils/filtron.sh+5
@@ -5,6 +5,8 @@
55
66# shellcheck source=utils/lib.sh
77source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
8+# shellcheck source=utils/brand.env
9+source "${REPO_ROOT}/utils/brand.env"
810source_dot_config
911source "${REPO_ROOT}/utils/lxc-searx.env"
1012in_container && lxc_set_suite_env
@@ -13,6 +15,9 @@ in_container && lxc_set_suite_env
1315# config
1416# ----------------------------------------------------------------------------
1517
18+PUBLIC_URL="${PUBLIC_URL:-http://$(uname -n)/searx}"
19+PUBLIC_HOST="${PUBLIC_HOST:-$(echo "$PUBLIC_URL" | sed -e 's/[^/]*\/\/\([^@]*@\)\?\([^:/]*\).*/\2/')}"
20+
1621FILTRON_URL_PATH="${FILTRON_URL_PATH:-$(echo "${PUBLIC_URL}" \
1722| sed -e 's,^.*://[^/]*\(/.*\),\1,g')}"
1823[[ "${FILTRON_URL_PATH}" == "${PUBLIC_URL}" ]] && FILTRON_URL_PATH=/
utils/morty.sh+5−2
@@ -4,6 +4,8 @@
44
55# shellcheck source=utils/lib.sh
66source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
7+# shellcheck source=utils/brand.env
8+source "${REPO_ROOT}/utils/brand.env"
79source_dot_config
810source "${REPO_ROOT}/utils/lxc-searx.env"
911in_container && lxc_set_suite_env
@@ -12,8 +14,9 @@ in_container && lxc_set_suite_env
1214# config
1315# ----------------------------------------------------------------------------
1416
15−PUBLIC_URL_PATH_MORTY="/morty"
16−PUBLIC_URL_MORTY="$(dirname "${PUBLIC_URL}")${PUBLIC_URL_PATH_MORTY}"
17+PUBLIC_URL="${PUBLIC_URL:-http://$(uname -n)/searx}"
18+PUBLIC_URL_PATH_MORTY="${PUBLIC_URL_PATH_MORTY:-/morty}"
19+PUBLIC_URL_MORTY="$(echo $PUBLIC_URL | sed -e's,^\(.*://[^/]*\).*,\1,g')${PUBLIC_URL_PATH_MORTY}"
1720
1821MORTY_LISTEN="${MORTY_LISTEN:-127.0.0.1:3000}"
1922# shellcheck disable=SC2034
utils/searx.sh+9−8
@@ -5,6 +5,8 @@
55
66# shellcheck source=utils/lib.sh
77source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
8+# shellcheck source=utils/brand.env
9+source "${REPO_ROOT}/utils/brand.env"
810source_dot_config
911source "${REPO_ROOT}/utils/lxc-searx.env"
1012in_container && lxc_set_suite_env
@@ -13,6 +15,8 @@ in_container && lxc_set_suite_env
1315# config
1416# ----------------------------------------------------------------------------
1517
18+PUBLIC_URL="${PUBLIC_URL:-http://$(uname -n)/searx}"
19+
1620SEARX_INTERNAL_URL="${SEARX_INTERNAL_URL:-127.0.0.1:8888}"
1721
1822SEARX_URL_PATH="${SEARX_URL_PATH:-$(echo "${PUBLIC_URL}" \
@@ -28,8 +32,7 @@ SERVICE_HOME="${SERVICE_HOME_BASE}/${SERVICE_USER}"
2832# shellcheck disable=SC2034
2933SERVICE_GROUP="${SERVICE_USER}"
3034
31−SEARX_GIT_URL="${SEARX_GIT_URL:-https://github.com/asciimoo/searx.git}"
32−SEARX_GIT_BRANCH="${SEARX_GIT_BRANCH:-master}"
35+GIT_BRANCH="${GIT_BRANCH:-master}"
3336SEARX_PYENV="${SERVICE_HOME}/searx-pyenv"
3437SEARX_SRC="${SERVICE_HOME}/searx-src"
3538SEARX_SETTINGS_PATH="/etc/searx/settings.yml"
@@ -126,7 +129,7 @@ shell
126129install / remove
127130 :all: complete (de-) installation of searx service
128131 :user: add/remove service user '$SERVICE_USER' ($SERVICE_HOME)
129− :searx-src: clone $SEARX_GIT_URL
132+ :searx-src: clone $GIT_URL
130133 :pyenv: create/remove virtualenv (python) in $SEARX_PYENV
131134 :uwsgi: install searx uWSGI application
132135 :settings: reinstall settings from ${REPO_ROOT}/searx/settings.yml
@@ -151,7 +154,6 @@ searx settings: ${SEARX_SETTINGS_PATH}
151154If needed, set PUBLIC_URL of your WEB service in the '${DOT_CONFIG#"$REPO_ROOT/"}' file::
152155
153156 PUBLIC_URL : ${PUBLIC_URL}
154− PUBLIC_HOST : ${PUBLIC_HOST}
155157 SEARX_INSTANCE_NAME : ${SEARX_INSTANCE_NAME}
156158 SERVICE_USER : ${SERVICE_USER}
157159
@@ -286,7 +288,7 @@ update_searx() {
286288 echo
287289 tee_stderr 0.3 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&1 | prefix_stdout "$_service_prefix"
288290cd ${SEARX_SRC}
289−git checkout -B "$SEARX_GIT_BRANCH"
291+git checkout -B "$GIT_BRANCH"
290292git pull
291293${SEARX_SRC}/manage.sh update_packages
292294EOF
@@ -344,12 +346,12 @@ clone_searx() {
344346 fi
345347 export SERVICE_HOME
346348 git_clone "$REPO_ROOT" "$SEARX_SRC" \
347− "$SEARX_GIT_BRANCH" "$SERVICE_USER"
349+ "$GIT_BRANCH" "$SERVICE_USER"
348350
349351 pushd "${SEARX_SRC}" > /dev/null
350352 tee_stderr 0.1 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&1 | prefix_stdout "$_service_prefix"
351353cd "${SEARX_SRC}"
352−git remote set-url origin ${SEARX_GIT_URL}
354+git remote set-url origin ${GIT_URL}
353355git config user.email "$ADMIN_EMAIL"
354356git config user.name "$ADMIN_NAME"
355357git config --list
@@ -546,7 +548,6 @@ inspect_service() {
546548sourced ${DOT_CONFIG#"$REPO_ROOT/"} :
547549
548550 PUBLIC_URL : ${PUBLIC_URL}
549− PUBLIC_HOST : ${PUBLIC_HOST}
550551 SEARX_URL_PATH : ${SEARX_URL_PATH}
551552 SEARX_INSTANCE_NAME : ${SEARX_INSTANCE_NAME}
552553 SEARX_INTERNAL_URL : ${SEARX_INTERNAL_URL}
utils/templates/etc/apache2/sites-available/morty.conf+1−1
@@ -23,6 +23,6 @@ ProxyPreserveHost On
2323 # needed by searx to render correct *Search URL* in the *Link* box and
2424 # *saved preference*.
2525
26− # RequestHeader set Host ${PUBLIC_URL_PATH_MORTY}
26+ # RequestHeader set Host ${PUBLIC_HOST}
2727
2828</Location>