diff --git a/actions/searx b/actions/searx index 7af352bd7..70217941b 100755 --- a/actions/searx +++ b/actions/searx @@ -20,6 +20,7 @@ Configuration helper for searx. """ import argparse +import augeas import os import secrets import shutil @@ -31,6 +32,8 @@ from plinth.utils import gunzip SETTINGS_FILE = '/etc/searx/settings.yml' +UWSGI_FILE = '/etc/uwsgi/apps-available/searx.ini' + def parse_arguments(): """Return parsed command line arguments as dictionary.""" @@ -64,10 +67,22 @@ def _copy_uwsgi_configuration(): """ example_config = ('/usr/share/doc/searx/examples/' 'uwsgi/apps-available/searx.ini') - destination = '/etc/uwsgi/apps-available/' + if not os.path.exists(UWSGI_FILE): + shutil.copy(example_config, os.path.dirname(UWSGI_FILE)) - if not os.path.exists(os.path.join(destination, 'searx.ini')): - shutil.copy(example_config, destination) + +def _update_uwsgi_configuration(): + """Fix uwsgi configuration. + + uwsgi 2.0.15-debian crashes when trying to autoload. + """ + aug = augeas.Augeas( + flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD) + aug.set('/augeas/load/inifile/lens', 'Puppet.lns') + aug.set('/augeas/load/inifile/incl[last() + 1]', UWSGI_FILE) + aug.load() + aug.set('/files/etc/uwsgi/apps-available/searx.ini/uwsgi/autoload', 'false') + aug.save() def _generate_secret_key(settings): @@ -119,6 +134,7 @@ def write_settings(settings): def subcommand_setup(_): """Post installation actions for Searx""" _copy_uwsgi_configuration() + _update_uwsgi_configuration() action_utils.webserver_enable('proxy_uwsgi', kind='module') if not os.path.exists(SETTINGS_FILE): diff --git a/plinth/modules/searx/__init__.py b/plinth/modules/searx/__init__.py index 0f375b72a..0b0c61ad2 100644 --- a/plinth/modules/searx/__init__.py +++ b/plinth/modules/searx/__init__.py @@ -31,7 +31,7 @@ from .manifest import clients clients = clients -version = 1 +version = 2 managed_services = ['searx'] @@ -80,7 +80,9 @@ def setup(helper, old_version=None): """Install and configure the module.""" helper.install(managed_packages) helper.call('post', actions.superuser_run, 'searx', ['setup']) - helper.call('post', actions.superuser_run, 'searx', ['enable']) + if not old_version: + helper.call('post', actions.superuser_run, 'searx', ['enable']) + global service if service is None: service = service_module.Service(managed_services[0], name, ports=[