forked from zaclys/searxng
Merge pull request #373 from dalf/searxng-environ
SearXNG: environment variables
This commit is contained in:
commit
9da9dbcbb4
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
2
Makefile
2
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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
@ -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.
|
||||
|
||||
|
@ -114,12 +114,12 @@ Global Settings
|
|||
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`` & ``bind_address``: :ref:`buildenv SEARXNG_PORT & SEARXNG_BIND_ADDRESS <make buildenv>`
|
||||
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.
|
||||
|
||||
``secret_key`` : ``$SEARX_SECRET``
|
||||
``secret_key`` : ``$SEARXNG_SECRET``
|
||||
Used for cryptography purpose.
|
||||
|
||||
``image_proxy`` :
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -109,8 +109,8 @@ from the YAML configuration:
|
|||
|
||||
- ``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>`
|
||||
- ``SEARXNG_BIND_ADDRESS`` from :ref:`server.bind_address <settings global server>`
|
||||
- ``SEARXNG_PORT`` from :ref:`server.port <settings global server>`
|
||||
|
||||
.. _make run:
|
||||
|
||||
|
@ -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
|
||||
|
|
8
manage
8
manage
|
@ -105,17 +105,17 @@ 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
|
||||
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]}"
|
||||
|
|
|
@ -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},
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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."""
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
export SEARX_URL=''
|
||||
export SEARX_PORT='8888'
|
||||
export SEARX_BIND_ADDRESS='127.0.0.1'
|
||||
export SEARXNG_PORT='8888'
|
||||
export SEARXNG_BIND_ADDRESS='127.0.0.1'
|
||||
export GIT_URL='https://github.com/searxng/searxng'
|
||||
export GIT_BRANCH='master'
|
||||
|
|
|
@ -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)
|
||||
|
@ -29,15 +29,15 @@ def _env(*arg, **kwargs):
|
|||
name_val = [
|
||||
|
||||
('SEARX_URL' , 'server.base_url'),
|
||||
('SEARX_PORT' , 'server.port'),
|
||||
('SEARX_BIND_ADDRESS' , 'server.bind_address'),
|
||||
('SEARXNG_PORT' , 'server.port'),
|
||||
('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()
|
||||
|
@ -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:
|
||||
|
|
|
@ -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="${SEARXNG_BIND_ADDRESS}:${SEARXNG_PORT}"
|
||||
|
||||
SERVICE_NAME="filtron"
|
||||
SERVICE_USER="${SERVICE_USER:-${SERVICE_NAME}}"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -111,7 +111,7 @@ info_searx() {
|
|||
cat <<EOF
|
||||
To activate result and image proxy in SearXNG read:
|
||||
https://searxng.github.io/searxng/admin/morty.html
|
||||
Check settings in file ${SEARX_SETTINGS_PATH} ...
|
||||
Check settings in file ${SEARXNG_SETTINGS_PATH} ...
|
||||
result_proxy:
|
||||
url : ${PUBLIC_URL_MORTY}
|
||||
server:
|
||||
|
|
|
@ -12,7 +12,7 @@ source "${REPO_ROOT}/utils/lib_install.sh"
|
|||
# config
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
SEARX_INTERNAL_HTTP="${SEARX_BIND_ADDRESS}:${SEARX_PORT}"
|
||||
SEARX_INTERNAL_HTTP="${SEARXNG_BIND_ADDRESS}:${SEARXNG_PORT}"
|
||||
|
||||
SEARX_URL_PATH="${SEARX_URL_PATH:-$(echo "${PUBLIC_URL}" \
|
||||
| sed -e 's,^.*://[^/]*\(/.*\),\1,g')}"
|
||||
|
@ -28,7 +28,7 @@ SERVICE_GROUP="${SERVICE_USER}"
|
|||
GIT_BRANCH="${GIT_BRANCH:-master}"
|
||||
SEARX_PYENV="${SERVICE_HOME}/searx-pyenv"
|
||||
SEARX_SRC="${SERVICE_HOME}/searx-src"
|
||||
SEARX_SETTINGS_PATH="/etc/searx/settings.yml"
|
||||
SEARXNG_SETTINGS_PATH="/etc/searx/settings.yml"
|
||||
SEARX_UWSGI_APP="searx.ini"
|
||||
# shellcheck disable=SC2034
|
||||
SEARX_UWSGI_SOCKET="/run/uwsgi/app/searx/socket"
|
||||
|
@ -130,7 +130,7 @@ CONFIG_FILES=(
|
|||
|
||||
# shellcheck disable=SC2034
|
||||
CONFIG_BACKUP_ENCRYPTED=(
|
||||
"${SEARX_SETTINGS_PATH}"
|
||||
"${SEARXNG_SETTINGS_PATH}"
|
||||
)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
|
@ -160,7 +160,7 @@ install / remove
|
|||
:init-src: copy files (SEARX_SRC_INIT_FILES) to ${SEARX_SRC}
|
||||
:pyenv: create/remove virtualenv (python) in $SEARX_PYENV
|
||||
:uwsgi: install searx uWSGI application
|
||||
:settings: reinstall settings from ${SEARX_SETTINGS_PATH}
|
||||
:settings: reinstall settings from ${SEARXNG_SETTINGS_PATH}
|
||||
:packages: install needed packages from OS package manager
|
||||
:buildhost: install packages from OS package manager needed by buildhosts
|
||||
update searx
|
||||
|
@ -613,16 +613,16 @@ install_DOT_CONFIG(){
|
|||
}
|
||||
|
||||
install_settings() {
|
||||
rst_title "${SEARX_SETTINGS_PATH}" section
|
||||
rst_title "${SEARXNG_SETTINGS_PATH}" section
|
||||
|
||||
if ! clone_is_available; then
|
||||
err_msg "you have to install SearXNG first"
|
||||
exit 42
|
||||
fi
|
||||
|
||||
mkdir -p "$(dirname "${SEARX_SETTINGS_PATH}")"
|
||||
mkdir -p "$(dirname "${SEARXNG_SETTINGS_PATH}")"
|
||||
install_template --no-eval \
|
||||
"${SEARX_SETTINGS_PATH}" \
|
||||
"${SEARXNG_SETTINGS_PATH}" \
|
||||
"${SERVICE_USER}" "${SERVICE_GROUP}"
|
||||
configure_searx
|
||||
}
|
||||
|
@ -630,8 +630,8 @@ install_settings() {
|
|||
remove_settings() {
|
||||
rst_title "remove SearXNG settings" section
|
||||
echo
|
||||
info_msg "delete ${SEARX_SETTINGS_PATH}"
|
||||
rm -f "${SEARX_SETTINGS_PATH}"
|
||||
info_msg "delete ${SEARXNG_SETTINGS_PATH}"
|
||||
rm -f "${SEARXNG_SETTINGS_PATH}"
|
||||
}
|
||||
|
||||
remove_searx() {
|
||||
|
@ -692,11 +692,11 @@ EOF
|
|||
|
||||
configure_searx() {
|
||||
rst_title "Configure SearXNG" section
|
||||
rst_para "Setup SearXNG config located at $SEARX_SETTINGS_PATH"
|
||||
rst_para "Setup SearXNG config located at $SEARXNG_SETTINGS_PATH"
|
||||
echo
|
||||
tee_stderr 0.1 <<EOF | sudo -H -i 2>&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 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&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 <<EOF | sudo -H -i 2>&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 <<EOF | sudo -H -i 2>&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 <<EOF | sudo -H -i 2>&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 <<EOF | sudo -H -i 2>&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 <URL> [<key>]
|
||||
|
||||
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() {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue