From b6a55e223ce0e287adeeafce8164e411154b5423 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Tue, 20 Jul 2021 13:16:21 +0200 Subject: [PATCH] [mod] reduce enviroment variables in shell scripts to what is needed Not all settings from the 'brand:' section of the YAML files are needed in the shell scripts. This patch reduce the variables in ./utils/brand.env to what is needed. The following ('brand:' settings) can be removed from this file: - ISSUE_URL - DOCS_URL - PUBLIC_INSTANCES - WIKI_URL Tasks running outside of an *installed instance*, need the following settings from the YAML configuration: - GIT_URL <--> brand.git_url - GIT_BRANCH <--> brand.git_branch - SEARX_URL <--> server.base_url (aka PUBLIC_URL) - SEARX_PORT <--> server.port - SEARX_BIND_ADDRESS <--> server.bind_address Signed-off-by: Markus Heiser --- docs/admin/engines/settings.rst | 37 +++++++++++++++----------- docs/dev/makefile.rst | 10 +++++++ searx/settings.yml | 20 +++++++------- utils/brand.env | 8 +++--- utils/build_env.py | 15 +++++++---- utils/lxc.sh | 2 +- utils/morty.sh | 3 +-- utils/templates/etc/searx/settings.yml | 2 +- 8 files changed, 59 insertions(+), 38 deletions(-) diff --git a/docs/admin/engines/settings.rst b/docs/admin/engines/settings.rst index 7325ea3ba..cab4ee493 100644 --- a/docs/admin/engines/settings.rst +++ b/docs/admin/engines/settings.rst @@ -42,9 +42,6 @@ Global Settings ``brand:`` ------------ -If you change a value in this section, don't forget to rebuild instance's -environment (:ref:`utils/brand.env `) - .. code:: yaml brand: @@ -55,19 +52,24 @@ environment (:ref:`utils/brand.env `) public_instances: https://searx.space wiki_url: https://github.com/searxng/searxng/wiki -``git_url`` & ``git_branch`` : :ref:`buildenv GIT_URL & GIT_BRANCH` +.. sidebar:: buildenv + + Changing a value tagged by :ref:`buildenv `, needs to + rebuild instance's environment :ref:`utils/brand.env `. + +``git_url`` & ``git_branch`` : :ref:`buildenv GIT_URL & GIT_BRANCH ` Changes this, to point to your searx fork (branch). -``issue_url`` : :ref:`buildenv ISSUE_URL` +``issue_url`` : If you host your own issue tracker change this URL. -``docs_url`` : :ref:`buildenv DOCS_URL` +``docs_url`` : If you host your own documentation change this URL. -``public_instances`` : :ref:`buildenv PUBLIC_INSTANCES` +``public_instances`` : If you host your own https://searx.space change this URL. -``wiki_url`` : :ref:`buildenv WIKI_URL` +``wiki_url`` : Link to your wiki (or ``false``) .. _settings global general: @@ -98,10 +100,10 @@ environment (:ref:`utils/brand.env `) .. code:: yaml server: + base_url: false # set custom base_url (or false) port: 8888 bind_address: "127.0.0.1" # address to listen on secret_key: "ultrasecretkey" # change this! - base_url: false # set custom base_url (or false) image_proxy: false # proxying image results through searx default_locale: "" # default interface locale default_theme: oscar # ui theme @@ -112,7 +114,17 @@ environment (:ref:`utils/brand.env `) X-Robots-Tag : noindex, nofollow Referrer-Policy : no-referrer -``port`` & ``bind_address``: ``$SEARX_PORT`` & ``$SEARX_BIND_ADDRESS`` +.. sidebar:: buildenv + + Changing a value tagged by :ref:`buildenv `, needs to + rebuild instance's environment :ref:`utils/brand.env `. + +``base_url`` : :ref:`buildenv SEARX_URL ` + The base URL where searx is deployed. Used to create correct inbound links. + If you change the value, don't forget to rebuild instance's environment + (:ref:`utils/brand.env `) + +``port`` & ``bind_address``: :ref:`buildenv SEARX_PORT & SEARX_BIND_ADDRESS ` Port number and *bind address* of the searx web application if you run it directly using ``python searx/webapp.py``. Doesn't apply to searx running on Apache or Nginx. @@ -120,11 +132,6 @@ environment (:ref:`utils/brand.env `) ``secret_key`` : ``$SEARX_SECRET`` Used for cryptography purpose. -``base_url`` : :ref:`buildenv SEARX_URL ` - The base URL where searx is deployed. Used to create correct inbound links. - If you change the value, don't forget to rebuild instance's environment - (:ref:`utils/brand.env `) - ``image_proxy`` : Allow your instance of searx of being able to proxy images. Uses memory space. diff --git a/docs/dev/makefile.rst b/docs/dev/makefile.rst index 2c10181be..5bf3c13b2 100644 --- a/docs/dev/makefile.rst +++ b/docs/dev/makefile.rst @@ -104,6 +104,16 @@ The ``make buildenv`` target will update the *build environment* in: - :origin:`utils/brand.env` +Tasks running outside of an *installed instance*, need the following settings +from the YAML configuration: + +- ``GIT_URL`` from :ref:`brand.git_url ` +- ``GIT_BRANCH`` from :ref:`brand.git_branch ` + +- ``SEARX_URL`` from :ref:`server.base_url ` (aka + ``PUBLIC_URL``) +- ``SEARX_BIND_ADDRESS`` from :ref:`server.bind_address ` +- ``SEARX_PORT`` from :ref:`server.port ` .. _make run: diff --git a/searx/settings.yml b/searx/settings.yml index 8b642d668..a951b862b 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -4,15 +4,16 @@ general: contact_url: false # mailto:contact@example.com brand: - # If you change a value in this section don't forget to rebuild instance's - # enviroment (make buildenv) - git_url: https://github.com/searxng/searxng - git_branch: master - issue_url: https://github.com/searxng/searxng/issues new_issue_url: https://github.com/searxng/searxng/issues/new docs_url: https://searxng.github.io/searxng public_instances: https://searx.space wiki_url: https://github.com/searxng/searxng/wiki + issue_url: https://github.com/searxng/searxng/issues + + # If you change a value below don't forget to rebuild instance's enviroment + # (make buildenv) + git_url: https://github.com/searxng/searxng + git_branch: master search: # Filter results. 0: None, 1: Moderate, 2: Strict @@ -32,13 +33,14 @@ search: formats: [html, csv, json, rss] server: + # If you change port, bind_address or base_url don't forget to rebuild + # instance's enviroment (make buildenv) port: 8888 bind_address: "127.0.0.1" + base_url: false # Possible values: false or "https://example.org/location". - # Set custom base_url. Possible values: false or "https://example.org/location" - # If you change base_url don't forget to rebuild instance's enviroment (make - # buildenv) port & address to listen on - base_url: false + # If your instance owns a /etc/searx/settings.yml file, then set the following + # values there. secret_key: "ultrasecretkey" # change this! # Proxying image results through searx diff --git a/utils/brand.env b/utils/brand.env index a8491d15d..2075a2bf4 100644 --- a/utils/brand.env +++ b/utils/brand.env @@ -1,7 +1,5 @@ -export SEARX_URL='' export GIT_URL='https://github.com/searxng/searxng' export GIT_BRANCH='master' -export ISSUE_URL='https://github.com/searxng/searxng/issues' -export DOCS_URL='https://searxng.github.io/searxng' -export PUBLIC_INSTANCES='https://searx.space' -export WIKI_URL='https://github.com/searxng/searxng/wiki' +export SEARX_URL='' +export SEARX_PORT='8888' +export SEARX_BIND_ADDRESS='127.0.0.1' diff --git a/utils/build_env.py b/utils/build_env.py index 52ca94611..28674f923 100644 --- a/utils/build_env.py +++ b/utils/build_env.py @@ -23,14 +23,19 @@ def _env(*arg, **kwargs): val = '' return val +# If you add or remove variables here, do not forgett to update: +# - docs/admin/engines/settings.rst +# - /docs/dev/makefile.rst (section make buildenv) + name_val = [ - ('SEARX_URL' , 'server.base_url'), + ('GIT_URL' , 'brand.git_url'), ('GIT_BRANCH' , 'brand.git_branch'), - ('ISSUE_URL' , 'brand.issue_url'), - ('DOCS_URL' , 'brand.docs_url'), - ('PUBLIC_INSTANCES' , 'brand.public_instances'), - ('WIKI_URL' , 'brand.wiki_url'), + + ('SEARX_URL' , 'server.base_url'), + ('SEARX_PORT' , 'server.port'), + ('SEARX_BIND_ADDRESS' , 'server.bind_address'), + ] brand_env = 'utils' + sep + 'brand.env' diff --git a/utils/lxc.sh b/utils/lxc.sh index f94e9841a..9a79606ca 100755 --- a/utils/lxc.sh +++ b/utils/lxc.sh @@ -568,7 +568,7 @@ check_connectivity() { info_msg "Most often the connectivity is blocked by a docker installation:" info_msg "Whenever docker is started (reboot) it sets the iptables policy " info_msg "for the FORWARD chain to DROP, see:" - info_msg " ${DOCS_URL}/utils/lxc.sh.html#internet-connectivity-docker" + info_msg " https://searxng.github.io/searxng/utils/lxc.sh.html#internet-connectivity-docker" iptables-save | grep ":FORWARD" fi return $ret_val diff --git a/utils/morty.sh b/utils/morty.sh index ccf920273..8be0e6ba6 100755 --- a/utils/morty.sh +++ b/utils/morty.sh @@ -12,7 +12,6 @@ source "${REPO_ROOT}/utils/lib_install.sh" MORTY_LISTEN="${MORTY_LISTEN:-127.0.0.1:3000}" PUBLIC_URL_PATH_MORTY="${PUBLIC_URL_PATH_MORTY:-/morty/}" - PUBLIC_URL_MORTY="${PUBLIC_URL_MORTY:-$(echo "$PUBLIC_URL" | sed -e's,^\(.*://[^/]*\).*,\1,g')${PUBLIC_URL_PATH_MORTY}}" # shellcheck disable=SC2034 @@ -111,7 +110,7 @@ info_searx() { # shellcheck disable=SC1117 cat <