@@ -18,7 +18,7 @@ along with searx. If not, see < http://www.gnu.org/licenses/ >.
1818import certifi
1919import logging
2020from os import environ
21−from os.path import realpath, dirname, join, abspath
21+from os.path import realpath, dirname, join, abspath, isfile
2222from ssl import OPENSSL_VERSION_INFO, OPENSSL_VERSION
2323try:
2424 from yaml import load
@@ -30,13 +30,24 @@ except:
3030searx_dir = abspath(dirname(__file__))
3131engine_dir = dirname(realpath(__file__))
3232
33−# if possible set path to settings using the
34−# enviroment variable SEARX_SETTINGS_PATH
33+
34+def check_settings_yml(file_name):
35+ if isfile(file_name):
36+ return file_name
37+ else:
38+ return None
39+
40+# find location of settings.yml
3541if 'SEARX_SETTINGS_PATH' in environ:
36− settings_path = environ['SEARX_SETTINGS_PATH']
37−# otherwise using default path
42+ # if possible set path to settings using the
43+ # enviroment variable SEARX_SETTINGS_PATH
44+ settings_path = check_settings_yml(environ['SEARX_SETTINGS_PATH'])
3845else:
39− settings_path = join(searx_dir, 'settings.yml')
46+ # if not, get it from searx code base or last solution from /etc/searx
47+ settings_path = check_settings_yml(join(searx_dir, 'settings.yml')) or check_settings_yml('/etc/searx/settings.yml')
48+
49+if not settings_path:
50+ raise Exception('settings.yml not found')
4051
4152# load settings
4253with open(settings_path) as settings_yaml:
@@ -67,7 +78,7 @@ else:
6778 logging.basicConfig(level=logging.WARNING)
6879
6980logger = logging.getLogger('searx')
70−
81+logger.debug('read configuration from %s', settings_path)
7182# Workaround for openssl versions <1.0.2
7283# https://github.com/certifi/python-certifi/issues/26
7384if OPENSSL_VERSION_INFO[0:3] < (1, 0, 2):