mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
searx: Fixes for enable/disable actions
- Restarting uwsgi is required on enable and disable. - Some refactoring to improve efficiency. Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
bffaf903b8
commit
05715b4e64
@ -62,30 +62,21 @@ def _copy_uwsgi_configuration():
|
|||||||
action_utils.webserver_enable('proxy_uwsgi', kind='module')
|
action_utils.webserver_enable('proxy_uwsgi', kind='module')
|
||||||
|
|
||||||
|
|
||||||
def _generate_secret_key():
|
def _generate_secret_key(settings):
|
||||||
""" Generate a secret key for the Searx installation."""
|
"""Generate a secret key for the Searx installation."""
|
||||||
|
|
||||||
if not os.path.exists(SETTINGS_FILE):
|
|
||||||
example_settings_file = '/usr/share/doc/searx/examples/settings.yml.gz'
|
|
||||||
gunzip(example_settings_file, SETTINGS_FILE)
|
|
||||||
|
|
||||||
# Generate and set a secret key
|
|
||||||
settings = read_settings()
|
|
||||||
secret_key = secrets.token_hex(32)
|
secret_key = secrets.token_hex(32)
|
||||||
settings['server']['secret_key'] = secret_key
|
settings['server']['secret_key'] = secret_key
|
||||||
write_settings(settings)
|
|
||||||
|
|
||||||
action_utils.service_restart('uwsgi')
|
|
||||||
|
|
||||||
|
|
||||||
def _set_title():
|
def _set_title(settings):
|
||||||
"""Set the page title to '{box_name} Web Search'."""
|
"""Set the page title to '{box_name} Web Search'."""
|
||||||
settings = read_settings()
|
|
||||||
title = 'FreedomBox Web Search'
|
title = 'FreedomBox Web Search'
|
||||||
settings['general']['instance_name'] = title
|
settings['general']['instance_name'] = title
|
||||||
write_settings(settings)
|
|
||||||
|
|
||||||
action_utils.service_restart('uwsgi')
|
|
||||||
|
def _set_timeout(settings):
|
||||||
|
"""Set timeout to 20 seconds."""
|
||||||
|
settings['outgoing']['request_timeout'] = 20.0
|
||||||
|
|
||||||
|
|
||||||
def read_settings():
|
def read_settings():
|
||||||
@ -101,8 +92,17 @@ def write_settings(settings):
|
|||||||
def subcommand_setup(_):
|
def subcommand_setup(_):
|
||||||
"""Post installation actions for Searx"""
|
"""Post installation actions for Searx"""
|
||||||
_copy_uwsgi_configuration()
|
_copy_uwsgi_configuration()
|
||||||
_generate_secret_key()
|
|
||||||
_set_title()
|
if not os.path.exists(SETTINGS_FILE):
|
||||||
|
example_settings_file = '/usr/share/doc/searx/examples/settings.yml.gz'
|
||||||
|
gunzip(example_settings_file, SETTINGS_FILE)
|
||||||
|
|
||||||
|
settings = read_settings()
|
||||||
|
_generate_secret_key(settings)
|
||||||
|
_set_title(settings)
|
||||||
|
_set_timeout(settings)
|
||||||
|
|
||||||
|
action_utils.service_restart('uwsgi')
|
||||||
|
|
||||||
|
|
||||||
def subcommand_enable(_):
|
def subcommand_enable(_):
|
||||||
@ -110,6 +110,8 @@ def subcommand_enable(_):
|
|||||||
if not os.path.exists('/etc/uwsgi/apps-enabled/searx.ini'):
|
if not os.path.exists('/etc/uwsgi/apps-enabled/searx.ini'):
|
||||||
os.symlink('/etc/uwsgi/apps-available/searx.ini',
|
os.symlink('/etc/uwsgi/apps-available/searx.ini',
|
||||||
'/etc/uwsgi/apps-enabled/searx.ini')
|
'/etc/uwsgi/apps-enabled/searx.ini')
|
||||||
|
|
||||||
|
action_utils.service_restart('uwsgi')
|
||||||
action_utils.webserver_enable('searx-freedombox')
|
action_utils.webserver_enable('searx-freedombox')
|
||||||
|
|
||||||
|
|
||||||
@ -117,6 +119,7 @@ def subcommand_disable(_):
|
|||||||
"""Disable web configuration and reload."""
|
"""Disable web configuration and reload."""
|
||||||
action_utils.webserver_disable('searx-freedombox')
|
action_utils.webserver_disable('searx-freedombox')
|
||||||
os.unlink('/etc/uwsgi/apps-enabled/searx.ini')
|
os.unlink('/etc/uwsgi/apps-enabled/searx.ini')
|
||||||
|
action_utils.service_restart('uwsgi')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user