From 430babca253369d82e864500118f914a9420f74b Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Sat, 2 Oct 2021 12:21:02 +0200 Subject: [PATCH 1/4] SearXNG: environment variables --- Makefile | 2 +- docs/admin/engines/settings.rst | 4 ++-- docs/dev/makefile.rst | 8 ++++---- manage | 2 +- searx/__init__.py | 2 +- searx/settings_defaults.py | 28 ++++++++++++++++++++++------ searx/settings_loader.py | 8 ++++---- tests/__init__.py | 12 +++++++++--- tests/robot/__main__.py | 6 +++--- 9 files changed, 47 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index a4362b171..801323361 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ run: install sleep 2 ; \ xdg-open http://127.0.0.1:8888/ ; \ ) & - SEARX_DEBUG=1 ./manage pyenv.cmd python -m searx.webapp + SEARXNG_DEBUG=1 ./manage pyenv.cmd python -m searx.webapp PHONY += install uninstall install uninstall: diff --git a/docs/admin/engines/settings.rst b/docs/admin/engines/settings.rst index 459b4b46c..7308e2733 100644 --- a/docs/admin/engines/settings.rst +++ b/docs/admin/engines/settings.rst @@ -74,7 +74,7 @@ Global Settings instance_name: "SearXNG" # displayed name contact_url: false # mailto:contact@example.com -``debug`` : ``$SEARX_DEBUG`` +``debug`` : ``$SEARXNG_DEBUG`` Allow a more detailed log if you run SearXNG directly. Display *detailed* error messages in the browser too, so this must be deactivated in production. @@ -119,7 +119,7 @@ Global Settings directly using ``python searx/webapp.py``. Doesn't apply to SearXNG running on Apache or Nginx. -``secret_key`` : ``$SEARX_SECRET`` +``secret_key`` : ``$SEARXNG_SECRET`` Used for cryptography purpose. ``image_proxy`` : diff --git a/docs/dev/makefile.rst b/docs/dev/makefile.rst index 14e9b0555..77c0dddde 100644 --- a/docs/dev/makefile.rst +++ b/docs/dev/makefile.rst @@ -124,7 +124,7 @@ browser (:man:`xdg-open`):: $ make run PYENV OK - SEARX_DEBUG=1 ./manage.sh pyenv.cmd python ./searx/webapp.py + SEARXNG_DEBUG=1 ./manage.sh pyenv.cmd python ./searx/webapp.py ... INFO:werkzeug: * Running on http://127.0.0.1:8888/ (Press CTRL+C to quit) @@ -210,15 +210,15 @@ by underline:: make search.checker.google_news -To see HTTP requests and more use SEARX_DEBUG:: +To see HTTP requests and more use SEARXNG_DEBUG:: - make SEARX_DEBUG=1 search.checker.google_news + make SEARXNG_DEBUG=1 search.checker.google_news .. _3xx: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_redirection To filter out HTTP redirects (3xx_):: - make SEARX_DEBUG=1 search.checker.google_news | grep -A1 "HTTP/1.1\" 3[0-9][0-9]" + make SEARXNG_DEBUG=1 search.checker.google_news | grep -A1 "HTTP/1.1\" 3[0-9][0-9]" ... Engine google news Checking https://news.google.com:443 "GET /search?q=life&hl=en&lr=lang_en&ie=utf8&oe=utf8&ceid=US%3Aen&gl=US HTTP/1.1" 302 0 diff --git a/manage b/manage index e3bf27b50..553d3f208 100755 --- a/manage +++ b/manage @@ -115,7 +115,7 @@ buildenv() { export SEARX_SETTINGS_PATH ( set -e - SEARX_DEBUG=1 pyenv.cmd python utils/build_env.py 2>&1 \ + SEARXNG_DEBUG=1 pyenv.cmd python utils/build_env.py 2>&1 \ | prefix_stdout "${_Blue}BUILDENV${_creset} " ) return "${PIPESTATUS[0]}" diff --git a/searx/__init__.py b/searx/__init__.py index 93ad76bb1..b1626ae9f 100644 --- a/searx/__init__.py +++ b/searx/__init__.py @@ -62,7 +62,7 @@ def logging_config_debug(): except ImportError: coloredlogs = None - log_level = os.environ.get('SEARX_DEBUG_LOG_LEVEL', 'DEBUG') + log_level = os.environ.get('SEARXNG_DEBUG_LOG_LEVEL', 'DEBUG') if coloredlogs and is_color_terminal(): level_styles = { 'spam': {'color': 'green', 'faint': True}, diff --git a/searx/settings_defaults.py b/searx/settings_defaults.py index 62625b912..9284f3050 100644 --- a/searx/settings_defaults.py +++ b/searx/settings_defaults.py @@ -41,6 +41,17 @@ STR_TO_BOOL = { } _UNDEFINED = object() +# compatibility +SEARX_ENVIRON_VARIABLES = { + 'SEARX_DISABLE_ETC_SETTINGS': 'SEARXNG_DISABLE_ETC_SETTINGS', + 'SEARX_SETTINGS_PATH': 'SEARXNG_SETTINGS_PATH', + 'SEARX_DEBUG': 'SEARXNG_DEBUG', + 'SEARX_PORT': 'SEARXNG_PORT', + 'SEARX_BIND_ADDRESS': 'SEARXNG_BIND_ADDRESS', + 'SEARX_SECRET': 'SEARXNG_SECRET', +} + + class SettingsValue: """Check and update a setting value @@ -87,7 +98,6 @@ class SettingsValue: self.check_type_definition(value) return value - class SettingsDirectoryValue(SettingsValue): """Check and update a setting value that is a directory path """ @@ -124,8 +134,8 @@ def apply_schema(settings, schema, path_list): SCHEMA = { 'general': { - 'debug': SettingsValue(bool, False, 'SEARX_DEBUG'), - 'instance_name': SettingsValue(str, 'searxng'), + 'debug': SettingsValue(bool, False, 'SEARXNG_DEBUG'), + 'instance_name': SettingsValue(str, 'SearXNG'), 'contact_url': SettingsValue((None, False, str), None), }, 'brand': { @@ -144,9 +154,9 @@ SCHEMA = { 'formats': SettingsValue(list, OUTPUT_FORMATS), }, 'server': { - 'port': SettingsValue((int,str), 8888, 'SEARX_PORT'), - 'bind_address': SettingsValue(str, '127.0.0.1', 'SEARX_BIND_ADDRESS'), - 'secret_key': SettingsValue(str, environ_name='SEARX_SECRET'), + 'port': SettingsValue((int,str), 8888, 'SEARXNG_PORT'), + 'bind_address': SettingsValue(str, '127.0.0.1', 'SEARXNG_BIND_ADDRESS'), + 'secret_key': SettingsValue(str, environ_name='SEARXNG_SECRET'), 'base_url': SettingsValue((False, str), False), 'image_proxy': SettingsValue(bool, False), 'http_protocol_version': SettingsValue(('1.0', '1.1'), '1.0'), @@ -201,5 +211,11 @@ SCHEMA = { } def settings_set_defaults(settings): + # compatibility with searx variables + for searx, searxng in SEARX_ENVIRON_VARIABLES.items(): + if searx in os.environ and searxng not in os.environ: + os.environ[searxng] = os.environ[searx] + logger.warning('%s uses value from %s', searxng, searx) + apply_schema(settings, SCHEMA, []) return settings diff --git a/searx/settings_loader.py b/searx/settings_loader.py index 6beab59a1..51e5456d5 100644 --- a/searx/settings_loader.py +++ b/searx/settings_loader.py @@ -35,12 +35,12 @@ def get_default_settings_path(): def get_user_settings_path(): # find location of settings.yml - if 'SEARX_SETTINGS_PATH' in environ: + if 'SEARXNG_SETTINGS_PATH' in environ: # if possible set path to settings using the - # enviroment variable SEARX_SETTINGS_PATH - return check_settings_yml(environ['SEARX_SETTINGS_PATH']) + # enviroment variable SEARXNG_SETTINGS_PATH + return check_settings_yml(environ['SEARXNG_SETTINGS_PATH']) - if environ.get('SEARX_DISABLE_ETC_SETTINGS', '').lower() in ('1', 'true'): + if environ.get('SEARXNG_DISABLE_ETC_SETTINGS', '').lower() in ('1', 'true'): return None # if not, get it from searx code base or last solution from /etc/searx diff --git a/tests/__init__.py b/tests/__init__.py index 23e62f040..c823cec87 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -2,11 +2,17 @@ import os import aiounittest -os.environ['SEARX_DEBUG'] = '1' -os.environ['SEARX_DEBUG_LOG_LEVEL'] = 'WARNING' -os.environ['SEARX_DISABLE_ETC_SETTINGS'] = '1' +os.environ.pop('SEARX_DEBUG', None) +os.environ.pop('SEARX_DEBUG_LOG_LEVEL', None) +os.environ.pop('SEARX_DISABLE_ETC_SETTINGS', None) os.environ.pop('SEARX_SETTINGS_PATH', None) +os.environ.pop('SEARXNG_SETTINGS_PATH', None) + +os.environ['SEARXNG_DEBUG'] = '1' +os.environ['SEARXNG_DEBUG_LOG_LEVEL'] = 'WARNING' +os.environ['SEARXNG_DISABLE_ETC_SETTINGS'] = '1' + class SearxTestLayer: """Base layer for non-robot tests.""" diff --git a/tests/robot/__main__.py b/tests/robot/__main__.py index e435f512a..d4d6642a9 100644 --- a/tests/robot/__main__.py +++ b/tests/robot/__main__.py @@ -35,10 +35,10 @@ class SearxRobotLayer(): # - debug mode: https://flask.palletsprojects.com/quickstart/#debug-mode # - Flask.run(..): https://flask.palletsprojects.com/api/#flask.Flask.run - os.environ['SEARX_DEBUG'] = '0' + os.environ['SEARXNG_DEBUG'] = '0' # set robot settings path - os.environ['SEARX_SETTINGS_PATH'] = str(tests_path / 'robot' / 'settings_robot.yml') + os.environ['SEARXNG_SETTINGS_PATH'] = str(tests_path / 'robot' / 'settings_robot.yml') # run the server self.server = subprocess.Popen( # pylint: disable=consider-using-with @@ -52,7 +52,7 @@ class SearxRobotLayer(): def tearDown(self): os.kill(self.server.pid, 9) # remove previously set environment variable - del os.environ['SEARX_SETTINGS_PATH'] + del os.environ['SEARXNG_SETTINGS_PATH'] def run_robot_tests(tests): From 6443ed75622e8b99ea69b60a573275617d5f87a5 Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Sat, 2 Oct 2021 16:56:11 +0200 Subject: [PATCH 2/4] SearXNG: SEARXNG_PORT --- docs/admin/engines/settings.rst | 2 +- docs/dev/makefile.rst | 2 +- utils/brand.env | 2 +- utils/build_env.py | 2 +- utils/filtron.sh | 2 +- utils/searx.sh | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/admin/engines/settings.rst b/docs/admin/engines/settings.rst index 7308e2733..0e1d0d710 100644 --- a/docs/admin/engines/settings.rst +++ b/docs/admin/engines/settings.rst @@ -114,7 +114,7 @@ Global Settings 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`` & ``bind_address``: :ref:`buildenv SEARXNG_PORT & SEARX_BIND_ADDRESS ` Port number and *bind address* of the SearXNG web application if you run it directly using ``python searx/webapp.py``. Doesn't apply to SearXNG running on Apache or Nginx. diff --git a/docs/dev/makefile.rst b/docs/dev/makefile.rst index 77c0dddde..09e37502e 100644 --- a/docs/dev/makefile.rst +++ b/docs/dev/makefile.rst @@ -110,7 +110,7 @@ from the YAML configuration: - ``SEARX_URL`` from :ref:`server.base_url ` (aka ``PUBLIC_URL``) - ``SEARX_BIND_ADDRESS`` from :ref:`server.bind_address ` -- ``SEARX_PORT`` from :ref:`server.port ` +- ``SEARXNG_PORT`` from :ref:`server.port ` .. _make run: diff --git a/utils/brand.env b/utils/brand.env index bd1629175..d63e686d4 100644 --- a/utils/brand.env +++ b/utils/brand.env @@ -1,5 +1,5 @@ export SEARX_URL='' -export SEARX_PORT='8888' +export SEARXNG_PORT='8888' export SEARX_BIND_ADDRESS='127.0.0.1' export GIT_URL='https://github.com/searxng/searxng' export GIT_BRANCH='master' diff --git a/utils/build_env.py b/utils/build_env.py index 6aa1f95f6..750f29f1c 100644 --- a/utils/build_env.py +++ b/utils/build_env.py @@ -29,7 +29,7 @@ def _env(*arg, **kwargs): name_val = [ ('SEARX_URL' , 'server.base_url'), - ('SEARX_PORT' , 'server.port'), + ('SEARXNG_PORT' , 'server.port'), ('SEARX_BIND_ADDRESS' , 'server.bind_address'), ] diff --git a/utils/filtron.sh b/utils/filtron.sh index 83f492407..bb2a8d742 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -28,7 +28,7 @@ FILTRON_LISTEN="${FILTRON_LISTEN:-127.0.0.1:4004}" # server.bind_address. The default of FILTRON_TARGET is taken from the YAML # configuration, do not change this value without reinstalling the entire # SearXNG suite including filtron & morty. -FILTRON_TARGET="${SEARX_BIND_ADDRESS}:${SEARX_PORT}" +FILTRON_TARGET="${SEARX_BIND_ADDRESS}:${SEARXNG_PORT}" SERVICE_NAME="filtron" SERVICE_USER="${SERVICE_USER:-${SERVICE_NAME}}" diff --git a/utils/searx.sh b/utils/searx.sh index a2d42c27b..d7838c5fc 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -12,7 +12,7 @@ source "${REPO_ROOT}/utils/lib_install.sh" # config # ---------------------------------------------------------------------------- -SEARX_INTERNAL_HTTP="${SEARX_BIND_ADDRESS}:${SEARX_PORT}" +SEARX_INTERNAL_HTTP="${SEARX_BIND_ADDRESS}:${SEARXNG_PORT}" SEARX_URL_PATH="${SEARX_URL_PATH:-$(echo "${PUBLIC_URL}" \ | sed -e 's,^.*://[^/]*\(/.*\),\1,g')}" From 9e266ecad3cc20faf2c12cdab7862c29cf8df2ec Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Sat, 2 Oct 2021 16:58:09 +0200 Subject: [PATCH 3/4] SearXNG: SEARX_BIND_ADDRESS --- CHANGELOG.rst | 2 +- docs/admin/engines/settings.rst | 2 +- docs/dev/makefile.rst | 2 +- utils/brand.env | 2 +- utils/build_env.py | 4 ++-- utils/filtron.sh | 2 +- utils/searx.sh | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c319be8e9..c215f225e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -360,7 +360,7 @@ News - Docker image updates - Bang expression fixes - Result merging fixes -- New environment variable added: SEARX_BIND_ADDRESS +- New environment variable added: SEARXNG_BIND_ADDRESS News diff --git a/docs/admin/engines/settings.rst b/docs/admin/engines/settings.rst index 0e1d0d710..8c23bb9bd 100644 --- a/docs/admin/engines/settings.rst +++ b/docs/admin/engines/settings.rst @@ -114,7 +114,7 @@ Global Settings If you change the value, don't forget to rebuild instance's environment (:ref:`utils/brand.env `) -``port`` & ``bind_address``: :ref:`buildenv SEARXNG_PORT & SEARX_BIND_ADDRESS ` +``port`` & ``bind_address``: :ref:`buildenv SEARXNG_PORT & SEARXNG_BIND_ADDRESS ` Port number and *bind address* of the SearXNG web application if you run it directly using ``python searx/webapp.py``. Doesn't apply to SearXNG running on Apache or Nginx. diff --git a/docs/dev/makefile.rst b/docs/dev/makefile.rst index 09e37502e..1db3ed703 100644 --- a/docs/dev/makefile.rst +++ b/docs/dev/makefile.rst @@ -109,7 +109,7 @@ from the YAML configuration: - ``SEARX_URL`` from :ref:`server.base_url ` (aka ``PUBLIC_URL``) -- ``SEARX_BIND_ADDRESS`` from :ref:`server.bind_address ` +- ``SEARXNG_BIND_ADDRESS`` from :ref:`server.bind_address ` - ``SEARXNG_PORT`` from :ref:`server.port ` .. _make run: diff --git a/utils/brand.env b/utils/brand.env index d63e686d4..5cc2af35b 100644 --- a/utils/brand.env +++ b/utils/brand.env @@ -1,5 +1,5 @@ export SEARX_URL='' export SEARXNG_PORT='8888' -export SEARX_BIND_ADDRESS='127.0.0.1' +export SEARXNG_BIND_ADDRESS='127.0.0.1' export GIT_URL='https://github.com/searxng/searxng' export GIT_BRANCH='master' diff --git a/utils/build_env.py b/utils/build_env.py index 750f29f1c..3ba4e4aaf 100644 --- a/utils/build_env.py +++ b/utils/build_env.py @@ -30,14 +30,14 @@ name_val = [ ('SEARX_URL' , 'server.base_url'), ('SEARXNG_PORT' , 'server.port'), - ('SEARX_BIND_ADDRESS' , 'server.bind_address'), + ('SEARXNG_BIND_ADDRESS' , 'server.bind_address'), ] brand_env = 'utils' + sep + 'brand.env' # Some defaults in the settings.yml are taken from the environment, -# e.g. SEARX_BIND_ADDRESS (:py:obj:`searx.settings_defaults.SHEMA`). When the +# e.g. SEARXNG_BIND_ADDRESS (:py:obj:`searx.settings_defaults.SHEMA`). When the # 'brand.env' file is created these enviroment variables should be unset first:: _unset = object() diff --git a/utils/filtron.sh b/utils/filtron.sh index bb2a8d742..a608f7769 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -28,7 +28,7 @@ FILTRON_LISTEN="${FILTRON_LISTEN:-127.0.0.1:4004}" # server.bind_address. The default of FILTRON_TARGET is taken from the YAML # configuration, do not change this value without reinstalling the entire # SearXNG suite including filtron & morty. -FILTRON_TARGET="${SEARX_BIND_ADDRESS}:${SEARXNG_PORT}" +FILTRON_TARGET="${SEARXNG_BIND_ADDRESS}:${SEARXNG_PORT}" SERVICE_NAME="filtron" SERVICE_USER="${SERVICE_USER:-${SERVICE_NAME}}" diff --git a/utils/searx.sh b/utils/searx.sh index d7838c5fc..ed33e18c8 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -12,7 +12,7 @@ source "${REPO_ROOT}/utils/lib_install.sh" # config # ---------------------------------------------------------------------------- -SEARX_INTERNAL_HTTP="${SEARX_BIND_ADDRESS}:${SEARXNG_PORT}" +SEARX_INTERNAL_HTTP="${SEARXNG_BIND_ADDRESS}:${SEARXNG_PORT}" SEARX_URL_PATH="${SEARX_URL_PATH:-$(echo "${PUBLIC_URL}" \ | sed -e 's,^.*://[^/]*\(/.*\),\1,g')}" From 253b8503765b6f0d21135254277e72d17a51e04a Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Sat, 2 Oct 2021 17:18:05 +0200 Subject: [PATCH 4/4] SearXNG: SEARXNG_SETTINGS_PATH --- .config.sh | 6 +-- Dockerfile | 2 +- dockerfiles/docker-entrypoint.sh | 2 +- docs/admin/engines/settings.rst | 2 +- docs/admin/installation-searx.rst | 2 +- docs/build-templates/searx.rst | 16 ++++---- docs/dev/lxcdev.rst | 2 +- manage | 6 +-- tests/unit/__init__.py | 2 +- tests/unit/test_settings_loader.py | 12 +++--- utils/build_env.py | 4 +- utils/lib_install.sh | 6 +-- utils/morty.sh | 2 +- utils/searx.sh | 40 +++++++++---------- .../etc/uwsgi/apps-archlinux/searx.ini | 2 +- .../etc/uwsgi/apps-archlinux/searx.ini:socket | 2 +- .../etc/uwsgi/apps-available/searx.ini | 2 +- .../etc/uwsgi/apps-available/searx.ini:socket | 2 +- 18 files changed, 56 insertions(+), 56 deletions(-) diff --git a/.config.sh b/.config.sh index 0e41a73b0..36066139f 100644 --- a/.config.sh +++ b/.config.sh @@ -17,14 +17,14 @@ # -------------- # The setup of the SearXNG instance is done in the settings.yml -# (SEARX_SETTINGS_PATH). Read the remarks in [1] carefully and don't forget to +# (SEARXNG_SETTINGS_PATH). Read the remarks in [1] carefully and don't forget to # rebuild instance's environment (make buildenv) if needed. The settings.yml # file of an already installed instance is shown by:: # # $ ./utils/searx.sh --help # ---- SearXNG instance setup (already installed) -# SEARX_SETTINGS_PATH : /etc/searx/settings.yml -# SEARX_SRC : /usr/local/searx/searx-src +# SEARXNG_SETTINGS_PATH : /etc/searx/settings.yml +# SEARX_SRC : /usr/local/searx/searx-src # # [1] https://searxng.github.io/searxng/admin/engines/settings.html diff --git a/Dockerfile b/Dockerfile index a05adaf4e..df83f8eff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ ENV INSTANCE_NAME=searxng \ BASE_URL= \ MORTY_KEY= \ MORTY_URL= \ - SEARX_SETTINGS_PATH=/etc/searx/settings.yml \ + SEARXNG_SETTINGS_PATH=/etc/searx/settings.yml \ UWSGI_SETTINGS_PATH=/etc/searx/uwsgi.ini WORKDIR /usr/local/searx diff --git a/dockerfiles/docker-entrypoint.sh b/dockerfiles/docker-entrypoint.sh index d5c4d5fea..c69ed6214 100755 --- a/dockerfiles/docker-entrypoint.sh +++ b/dockerfiles/docker-entrypoint.sh @@ -132,7 +132,7 @@ update_conf() { update_conf "${FORCE_CONF_UPDATE}" "${UWSGI_SETTINGS_PATH}" "/usr/local/searx/dockerfiles/uwsgi.ini" "patch_uwsgi_settings" # make sure there are searx settings -update_conf "${FORCE_CONF_UPDATE}" "${SEARX_SETTINGS_PATH}" "/usr/local/searx/searx/settings.yml" "patch_searx_settings" +update_conf "${FORCE_CONF_UPDATE}" "${SEARXNG_SETTINGS_PATH}" "/usr/local/searx/searx/settings.yml" "patch_searx_settings" # dry run (to update configuration files, then inspect them) if [ $DRY_RUN -eq 1 ]; then diff --git a/docs/admin/engines/settings.rst b/docs/admin/engines/settings.rst index 8c23bb9bd..6a3256357 100644 --- a/docs/admin/engines/settings.rst +++ b/docs/admin/engines/settings.rst @@ -24,7 +24,7 @@ settings.yml location The initial ``settings.yml`` we be load from these locations: -1. the full path specified in the ``SEARX_SETTINGS_PATH`` environment variable. +1. the full path specified in the ``SEARXNG_SETTINGS_PATH`` environment variable. 2. ``/etc/searx/settings.yml`` If these files don't exist (or are empty or can't be read), SearXNG uses the diff --git a/docs/admin/installation-searx.rst b/docs/admin/installation-searx.rst index 9e9157b86..cb3cf9f05 100644 --- a/docs/admin/installation-searx.rst +++ b/docs/admin/installation-searx.rst @@ -107,7 +107,7 @@ Check ===== To check your SearXNG setup, optional enable debugging and start the *webapp*. -SearXNG looks at the exported environment ``$SEARX_SETTINGS_PATH`` for a +SearXNG looks at the exported environment ``$SEARXNG_SETTINGS_PATH`` for a configuration file. .. kernel-include:: $DOCS_BUILD/includes/searx.rst diff --git a/docs/build-templates/searx.rst b/docs/build-templates/searx.rst index 70e658b4c..804514ac8 100644 --- a/docs/build-templates/searx.rst +++ b/docs/build-templates/searx.rst @@ -133,17 +133,17 @@ ${fedora_build} .. code-block:: sh - $ sudo -H mkdir -p \"$(dirname ${SEARX_SETTINGS_PATH})\" + $ sudo -H mkdir -p \"$(dirname ${SEARXNG_SETTINGS_PATH})\" $ sudo -H cp \"$SEARX_SRC/utils/templates/etc/searx/settings.yml\" \\ - \"${SEARX_SETTINGS_PATH}\" + \"${SEARXNG_SETTINGS_PATH}\" .. group-tab:: searx/settings.yml .. code-block:: sh - $ sudo -H mkdir -p \"$(dirname ${SEARX_SETTINGS_PATH})\" + $ sudo -H mkdir -p \"$(dirname ${SEARXNG_SETTINGS_PATH})\" $ sudo -H cp \"$SEARX_SRC/searx/settings.yml\" \\ - \"${SEARX_SETTINGS_PATH}\" + \"${SEARXNG_SETTINGS_PATH}\" .. tabs:: @@ -151,7 +151,7 @@ ${fedora_build} .. code-block:: sh - $ sudo -H sed -i -e \"s/ultrasecretkey/\$(openssl rand -hex 16)/g\" \"$SEARX_SETTINGS_PATH\" + $ sudo -H sed -i -e \"s/ultrasecretkey/\$(openssl rand -hex 16)/g\" \"$SEARXNG_SETTINGS_PATH\" .. END searx config @@ -164,16 +164,16 @@ ${fedora_build} .. code-block:: sh # enable debug .. - $ sudo -H sed -i -e \"s/debug : False/debug : True/g\" \"$SEARX_SETTINGS_PATH\" + $ sudo -H sed -i -e \"s/debug : False/debug : True/g\" \"$SEARXNG_SETTINGS_PATH\" # start webapp $ sudo -H -u ${SERVICE_USER} -i (${SERVICE_USER})$ cd ${SEARX_SRC} - (${SERVICE_USER})$ export SEARX_SETTINGS_PATH=\"${SEARX_SETTINGS_PATH}\" + (${SERVICE_USER})$ export SEARXNG_SETTINGS_PATH=\"${SEARXNG_SETTINGS_PATH}\" (${SERVICE_USER})$ python searx/webapp.py # disable debug - $ sudo -H sed -i -e \"s/debug : True/debug : False/g\" \"$SEARX_SETTINGS_PATH\" + $ sudo -H sed -i -e \"s/debug : True/debug : False/g\" \"$SEARXNG_SETTINGS_PATH\" Open WEB browser and visit http://$SEARX_INTERNAL_HTTP . If you are inside a container or in a script, test with curl: diff --git a/docs/dev/lxcdev.rst b/docs/dev/lxcdev.rst index 9d5503058..12f6d7879 100644 --- a/docs/dev/lxcdev.rst +++ b/docs/dev/lxcdev.rst @@ -288,7 +288,7 @@ The uWSGI-App for the archlinux dsitros is configured in least you should attend the settings of ``uid``, ``chdir``, ``env`` and ``http``:: - env = SEARX_SETTINGS_PATH=/etc/searx/settings.yml + env = SEARXNG_SETTINGS_PATH=/etc/searx/settings.yml http = 127.0.0.1:8888 chdir = /usr/local/searx/searx-src/searx diff --git a/manage b/manage index 553d3f208..b02128df9 100755 --- a/manage +++ b/manage @@ -105,14 +105,14 @@ export DOCS_BUILD buildenv() { # settings file from repository's working tree are used by default - SEARX_SETTINGS_PATH="${REPO_ROOT}/searx/settings.yml" + SEARXNG_SETTINGS_PATH="${REPO_ROOT}/searx/settings.yml" if [ -r '/etc/searx/settings.yml' ]; then if ask_yn "should settings read from: /etc/searx/settings.yml"; then - SEARX_SETTINGS_PATH='/etc/searx/settings.yml' + SEARXNG_SETTINGS_PATH='/etc/searx/settings.yml' fi fi - export SEARX_SETTINGS_PATH + export SEARXNG_SETTINGS_PATH ( set -e SEARXNG_DEBUG=1 pyenv.cmd python utils/build_env.py 2>&1 \ diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py index 8266c675a..d1c97ec81 100644 --- a/tests/unit/__init__.py +++ b/tests/unit/__init__.py @@ -2,5 +2,5 @@ import os from os.path import dirname, sep, abspath # In unit tests the user settings from unit/settings/test_settings.yml are used. -os.environ['SEARX_SETTINGS_PATH'] = abspath( +os.environ['SEARXNG_SETTINGS_PATH'] = abspath( dirname(__file__) + sep + 'settings' + sep + 'test_settings.yml') diff --git a/tests/unit/test_settings_loader.py b/tests/unit/test_settings_loader.py index ad9fc6e95..9e04df653 100644 --- a/tests/unit/test_settings_loader.py +++ b/tests/unit/test_settings_loader.py @@ -58,14 +58,14 @@ class TestUserSettings(SearxTestCase): def test_user_settings_not_found(self): with patch.dict(settings_loader.environ, - {'SEARX_SETTINGS_PATH': '/dev/null'}): + {'SEARXNG_SETTINGS_PATH': '/dev/null'}): settings, msg = settings_loader.load_settings() self.assertTrue(msg.startswith('load the default settings from')) self.assertEqual(settings['server']['secret_key'], "ultrasecretkey") def test_user_settings(self): with patch.dict(settings_loader.environ, - {'SEARX_SETTINGS_PATH': join(test_dir, 'settings/user_settings_simple.yml')}): + {'SEARXNG_SETTINGS_PATH': join(test_dir, 'settings/user_settings_simple.yml')}): settings, msg = settings_loader.load_settings() self.assertTrue(msg.startswith('merge the default settings')) self.assertEqual(settings['server']['secret_key'], "user_secret_key") @@ -73,7 +73,7 @@ class TestUserSettings(SearxTestCase): def test_user_settings_remove(self): with patch.dict(settings_loader.environ, - {'SEARX_SETTINGS_PATH': join(test_dir, 'settings/user_settings_remove.yml')}): + {'SEARXNG_SETTINGS_PATH': join(test_dir, 'settings/user_settings_remove.yml')}): settings, msg = settings_loader.load_settings() self.assertTrue(msg.startswith('merge the default settings')) self.assertEqual(settings['server']['secret_key'], "user_secret_key") @@ -85,7 +85,7 @@ class TestUserSettings(SearxTestCase): def test_user_settings_remove2(self): with patch.dict(settings_loader.environ, - {'SEARX_SETTINGS_PATH': join(test_dir, 'settings/user_settings_remove2.yml')}): + {'SEARXNG_SETTINGS_PATH': join(test_dir, 'settings/user_settings_remove2.yml')}): settings, msg = settings_loader.load_settings() self.assertTrue(msg.startswith('merge the default settings')) self.assertEqual(settings['server']['secret_key'], "user_secret_key") @@ -102,7 +102,7 @@ class TestUserSettings(SearxTestCase): def test_user_settings_keep_only(self): with patch.dict(settings_loader.environ, - {'SEARX_SETTINGS_PATH': join(test_dir, 'settings/user_settings_keep_only.yml')}): + {'SEARXNG_SETTINGS_PATH': join(test_dir, 'settings/user_settings_keep_only.yml')}): settings, msg = settings_loader.load_settings() self.assertTrue(msg.startswith('merge the default settings')) engine_names = [engine['name'] for engine in settings['engines']] @@ -112,7 +112,7 @@ class TestUserSettings(SearxTestCase): def test_custom_settings(self): with patch.dict(settings_loader.environ, - {'SEARX_SETTINGS_PATH': join(test_dir, 'settings/user_settings.yml')}): + {'SEARXNG_SETTINGS_PATH': join(test_dir, 'settings/user_settings.yml')}): settings, msg = settings_loader.load_settings() self.assertTrue(msg.startswith('load the user settings from')) self.assertEqual(settings['server']['port'], 9000) diff --git a/utils/build_env.py b/utils/build_env.py index 3ba4e4aaf..42d75fbfb 100644 --- a/utils/build_env.py +++ b/utils/build_env.py @@ -12,7 +12,7 @@ sys.path.insert(0, repo_root) # Assure that the settings file from reposetorie's working tree is used to # generate the build_env, not from /etc/searx/settings.yml. -os.environ['SEARX_SETTINGS_PATH'] = join(repo_root, 'etc', 'settings.yml') +os.environ['SEARXNG_SETTINGS_PATH'] = join(repo_root, 'etc', 'settings.yml') def _env(*arg, **kwargs): val = get_setting(*arg, **kwargs) @@ -51,7 +51,7 @@ for name, option in name_val: from searx.version import GIT_URL, GIT_BRANCH from searx import get_setting -print('build %s (settings from: %s)' % (brand_env, os.environ['SEARX_SETTINGS_PATH'])) +print('build %s (settings from: %s)' % (brand_env, os.environ['SEARXNG_SETTINGS_PATH'])) sys.path.insert(0, repo_root) with open(repo_root + sep + brand_env, 'w', encoding='utf-8') as f: diff --git a/utils/lib_install.sh b/utils/lib_install.sh index 4ad11d63d..dc9ee6993 100755 --- a/utils/lib_install.sh +++ b/utils/lib_install.sh @@ -53,7 +53,7 @@ source_dot_config() { export eval_SEARX_SRC='true' SEARX_SRC=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARX_SRC) SEARX_PYENV=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARX_PYENV) - SEARX_SETTINGS_PATH=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARX_SETTINGS_PATH) + SEARXNG_SETTINGS_PATH=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARXNG_SETTINGS_PATH) if [ ! -r "${SEARX_SRC}" ]; then info_msg "not yet cloned: ${SEARX_SRC}" orig_source_dot_config @@ -115,7 +115,7 @@ init_SEARX_SRC_INIT_FILES(){ install_log_searx_instance() { echo -e "---- SearXNG instance setup ${_BBlue}(status: $(install_searx_get_state))${_creset}" - echo -e " SEARX_SETTINGS_PATH : ${_BBlue}${SEARX_SETTINGS_PATH}${_creset}" + echo -e " SEARXNG_SETTINGS_PATH : ${_BBlue}${SEARXNG_SETTINGS_PATH}${_creset}" echo -e " SSEARX_PYENV : ${_BBlue}${SEARX_PYENV}${_creset}" echo -e " SEARX_SRC : ${_BBlue}${SEARX_SRC:-none}${_creset}" echo -e " SEARX_URL : ${_BBlue}${SEARX_URL:-none}${_creset}" @@ -163,7 +163,7 @@ install_searx_get_state(){ echo "missing-searx-pyenv" return fi - if ! [ -r "${SEARX_SETTINGS_PATH}" ]; then + if ! [ -r "${SEARXNG_SETTINGS_PATH}" ]; then echo "missing-settings" return fi diff --git a/utils/morty.sh b/utils/morty.sh index c39568677..0c5401eeb 100755 --- a/utils/morty.sh +++ b/utils/morty.sh @@ -111,7 +111,7 @@ info_searx() { cat <&1 | prefix_stdout "$_service_prefix" cd ${SEARX_SRC} -sed -i -e "s/ultrasecretkey/$(openssl rand -hex 16)/g" "$SEARX_SETTINGS_PATH" +sed -i -e "s/ultrasecretkey/$(openssl rand -hex 16)/g" "$SEARXNG_SETTINGS_PATH" EOF } @@ -711,15 +711,15 @@ test_local_searx() { return fi fi - sed -i -e "s/debug: false/debug: true/g" "$SEARX_SETTINGS_PATH" + sed -i -e "s/debug: false/debug: true/g" "$SEARXNG_SETTINGS_PATH" tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" -export SEARX_SETTINGS_PATH="${SEARX_SETTINGS_PATH}" +export SEARXNG_SETTINGS_PATH="${SEARXNG_SETTINGS_PATH}" cd ${SEARX_SRC} timeout 10 python searx/webapp.py & sleep 3 curl --location --verbose --head --insecure $SEARX_INTERNAL_HTTP EOF - sed -i -e "s/debug: true/debug: false/g" "$SEARX_SETTINGS_PATH" + sed -i -e "s/debug: true/debug: false/g" "$SEARXNG_SETTINGS_PATH" } install_searx_uwsgi() { @@ -753,7 +753,7 @@ enable_image_proxy() { info_msg "try to enable image_proxy ..." tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" cd ${SEARX_SRC} -sed -i -e "s/image_proxy: false/image_proxy: true/g" "$SEARX_SETTINGS_PATH" +sed -i -e "s/image_proxy: false/image_proxy: true/g" "$SEARXNG_SETTINGS_PATH" EOF uWSGI_restart "$SEARX_UWSGI_APP" } @@ -762,7 +762,7 @@ disable_image_proxy() { info_msg "try to enable image_proxy ..." tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" cd ${SEARX_SRC} -sed -i -e "s/image_proxy: true/image_proxy: false/g" "$SEARX_SETTINGS_PATH" +sed -i -e "s/image_proxy: true/image_proxy: false/g" "$SEARXNG_SETTINGS_PATH" EOF uWSGI_restart "$SEARX_UWSGI_APP" } @@ -772,7 +772,7 @@ enable_debug() { info_msg "try to enable debug mode ..." tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" cd ${SEARX_SRC} -sed -i -e "s/debug: false/debug: true/g" "$SEARX_SETTINGS_PATH" +sed -i -e "s/debug: false/debug: true/g" "$SEARXNG_SETTINGS_PATH" EOF uWSGI_restart "$SEARX_UWSGI_APP" } @@ -781,7 +781,7 @@ disable_debug() { info_msg "try to disable debug mode ..." tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" cd ${SEARX_SRC} -sed -i -e "s/debug: true/debug: false/g" "$SEARX_SETTINGS_PATH" +sed -i -e "s/debug: true/debug: false/g" "$SEARXNG_SETTINGS_PATH" EOF uWSGI_restart "$SEARX_UWSGI_APP" } @@ -791,8 +791,8 @@ set_result_proxy() { # usage: set_result_proxy [] info_msg "try to set result proxy: '$1' ($2)" - cp "${SEARX_SETTINGS_PATH}" "${SEARX_SETTINGS_PATH}.bak" - _set_result_proxy "$1" "$2" > "${SEARX_SETTINGS_PATH}" + cp "${SEARXNG_SETTINGS_PATH}" "${SEARXNG_SETTINGS_PATH}.bak" + _set_result_proxy "$1" "$2" > "${SEARXNG_SETTINGS_PATH}" } _set_result_proxy() { @@ -829,7 +829,7 @@ _set_result_proxy() { fi fi echo "$line" - done < "${SEARX_SETTINGS_PATH}.bak" + done < "${SEARXNG_SETTINGS_PATH}.bak" } function has_substring() { diff --git a/utils/templates/etc/uwsgi/apps-archlinux/searx.ini b/utils/templates/etc/uwsgi/apps-archlinux/searx.ini index 71cece3c4..dcb7d1a7d 100644 --- a/utils/templates/etc/uwsgi/apps-archlinux/searx.ini +++ b/utils/templates/etc/uwsgi/apps-archlinux/searx.ini @@ -18,7 +18,7 @@ env = LC_ALL=C.UTF-8 chdir = ${SEARX_SRC}/searx # searx configuration (settings.yml) -env = SEARX_SETTINGS_PATH=${SEARX_SETTINGS_PATH} +env = SEARXNG_SETTINGS_PATH=${SEARXNG_SETTINGS_PATH} # disable logging for privacy logger = systemd diff --git a/utils/templates/etc/uwsgi/apps-archlinux/searx.ini:socket b/utils/templates/etc/uwsgi/apps-archlinux/searx.ini:socket index 1a0fda913..580600072 100644 --- a/utils/templates/etc/uwsgi/apps-archlinux/searx.ini:socket +++ b/utils/templates/etc/uwsgi/apps-archlinux/searx.ini:socket @@ -18,7 +18,7 @@ env = LC_ALL=C.UTF-8 chdir = ${SEARX_SRC}/searx # searx configuration (settings.yml) -env = SEARX_SETTINGS_PATH=${SEARX_SETTINGS_PATH} +env = SEARXNG_SETTINGS_PATH=${SEARXNG_SETTINGS_PATH} # disable logging for privacy logger = systemd diff --git a/utils/templates/etc/uwsgi/apps-available/searx.ini b/utils/templates/etc/uwsgi/apps-available/searx.ini index 45214ef13..440c2e97d 100644 --- a/utils/templates/etc/uwsgi/apps-available/searx.ini +++ b/utils/templates/etc/uwsgi/apps-available/searx.ini @@ -18,7 +18,7 @@ env = LC_ALL=C.UTF-8 chdir = ${SEARX_SRC}/searx # searx configuration (settings.yml) -env = SEARX_SETTINGS_PATH=${SEARX_SETTINGS_PATH} +env = SEARXNG_SETTINGS_PATH=${SEARXNG_SETTINGS_PATH} # disable logging for privacy disable-logging = true diff --git a/utils/templates/etc/uwsgi/apps-available/searx.ini:socket b/utils/templates/etc/uwsgi/apps-available/searx.ini:socket index 9cb292102..08c98cf61 100644 --- a/utils/templates/etc/uwsgi/apps-available/searx.ini:socket +++ b/utils/templates/etc/uwsgi/apps-available/searx.ini:socket @@ -18,7 +18,7 @@ env = LC_ALL=C.UTF-8 chdir = ${SEARX_SRC}/searx # searx configuration (settings.yml) -env = SEARX_SETTINGS_PATH=${SEARX_SETTINGS_PATH} +env = SEARXNG_SETTINGS_PATH=${SEARXNG_SETTINGS_PATH} # disable logging for privacy disable-logging = true