Browse Source

[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 <markus.heiser@darmarit.de>
Markus Heiser 3 years ago
parent
commit
b6a55e223c

+ 22 - 15
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 <make buildenv>`)
-
 .. code:: yaml
 
    brand:
@@ -55,19 +52,24 @@ environment (:ref:`utils/brand.env <make buildenv>`)
      public_instances: https://searx.space
      wiki_url: https://github.com/searxng/searxng/wiki
 
-``git_url`` & ``git_branch`` : :ref:`buildenv GIT_URL & GIT_BRANCH<make buildenv>`
+.. sidebar::  buildenv
+
+   Changing a value tagged by :ref:`buildenv <make buildenv>`, needs to
+   rebuild instance's environment :ref:`utils/brand.env <make buildenv>`.
+
+``git_url`` & ``git_branch`` : :ref:`buildenv GIT_URL & GIT_BRANCH <make buildenv>`
   Changes this, to point to your searx fork (branch).
 
-``issue_url`` : :ref:`buildenv ISSUE_URL<make buildenv>`
+``issue_url`` :
   If you host your own issue tracker change this URL.
 
-``docs_url`` : :ref:`buildenv DOCS_URL<make buildenv>`
+``docs_url`` :
   If you host your own documentation change this URL.
 
-``public_instances`` : :ref:`buildenv PUBLIC_INSTANCES<make buildenv>`
+``public_instances`` :
   If you host your own https://searx.space change this URL.
 
-``wiki_url`` : :ref:`buildenv WIKI_URL<make buildenv>`
+``wiki_url`` :
   Link to your wiki (or ``false``)
 
 .. _settings global general:
@@ -98,10 +100,10 @@ environment (:ref:`utils/brand.env <make buildenv>`)
 .. 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,19 +114,24 @@ environment (:ref:`utils/brand.env <make buildenv>`)
          X-Robots-Tag : noindex, nofollow
          Referrer-Policy : no-referrer
 
-``port`` & ``bind_address``: ``$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.
+.. sidebar::  buildenv
 
-``secret_key`` : ``$SEARX_SECRET``
-  Used for cryptography purpose.
+   Changing a value tagged by :ref:`buildenv <make buildenv>`, needs to
+   rebuild instance's environment :ref:`utils/brand.env <make buildenv>`.
 
 ``base_url`` : :ref:`buildenv SEARX_URL <make buildenv>`
   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 <make buildenv>`)
 
+``port`` & ``bind_address``: :ref:`buildenv SEARX_PORT & SEARX_BIND_ADDRESS <make buildenv>`
+  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.
+
+``secret_key`` : ``$SEARX_SECRET``
+  Used for cryptography purpose.
+
 ``image_proxy`` :
   Allow your instance of searx of being able to proxy images.  Uses memory space.
 

+ 10 - 0
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 <settings global brand>`
+- ``GIT_BRANCH`` from :ref:`brand.git_branch <settings global brand>`
+
+- ``SEARX_URL`` from :ref:`server.base_url <settings global server>` (aka
+  ``PUBLIC_URL``)
+- ``SEARX_BIND_ADDRESS`` from :ref:`server.bind_address <settings global server>`
+- ``SEARX_PORT`` from :ref:`server.port <settings global server>`
 
 .. _make run:
 

+ 11 - 9
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

+ 3 - 5
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'

+ 10 - 5
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'

+ 1 - 1
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

+ 1 - 2
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 <<EOF
 To activate result and image proxy in SearXNG read:
-  ${DOCS_URL}/admin/morty.html
+  https://searxng.github.io/searxng/admin/morty.html
 Check settings in file ${SEARX_SETTINGS_PATH} ...
   result_proxy:
       url : ${PUBLIC_URL_MORTY}

+ 1 - 1
utils/templates/etc/searx/settings.yml

@@ -1,6 +1,6 @@
 # SearXNG settings, before editing this file read:
 #
-#     ${DOCS_URL}/admin/engines/settings.html
+#     https://searxng.github.io/searxng/admin/engines/settings.html
 
 use_default_settings: true