mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
searx: Fix YAML parsing errors
Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
02b3a4cc97
commit
bffaf903b8
@ -25,8 +25,10 @@ import os
|
|||||||
import secrets
|
import secrets
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from plinth import action_utils, cfg
|
import yaml
|
||||||
from plinth.utils import YAMLFile, gunzip
|
|
||||||
|
from plinth import action_utils
|
||||||
|
from plinth.utils import gunzip
|
||||||
|
|
||||||
SETTINGS_FILE = '/etc/searx/settings.yml'
|
SETTINGS_FILE = '/etc/searx/settings.yml'
|
||||||
|
|
||||||
@ -57,7 +59,7 @@ def _copy_uwsgi_configuration():
|
|||||||
|
|
||||||
if not os.path.exists(os.path.join(destination, 'searx.ini')):
|
if not os.path.exists(os.path.join(destination, 'searx.ini')):
|
||||||
shutil.copy(example_config, destination)
|
shutil.copy(example_config, destination)
|
||||||
action_utils.webserver_enable('uwsgi', kind='module')
|
action_utils.webserver_enable('proxy_uwsgi', kind='module')
|
||||||
|
|
||||||
|
|
||||||
def _generate_secret_key():
|
def _generate_secret_key():
|
||||||
@ -68,22 +70,34 @@ def _generate_secret_key():
|
|||||||
gunzip(example_settings_file, SETTINGS_FILE)
|
gunzip(example_settings_file, SETTINGS_FILE)
|
||||||
|
|
||||||
# Generate and set a secret key
|
# Generate and set a secret key
|
||||||
with YAMLFile(SETTINGS_FILE) as settings:
|
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')
|
action_utils.service_restart('uwsgi')
|
||||||
|
|
||||||
|
|
||||||
def _set_title():
|
def _set_title():
|
||||||
"""Set the page title to '{box_name} Web Search'."""
|
"""Set the page title to '{box_name} Web Search'."""
|
||||||
with YAMLFile(SETTINGS_FILE) as settings:
|
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')
|
action_utils.service_restart('uwsgi')
|
||||||
|
|
||||||
|
|
||||||
|
def read_settings():
|
||||||
|
with open(SETTINGS_FILE, 'rb') as settings_file:
|
||||||
|
return yaml.load(settings_file)
|
||||||
|
|
||||||
|
|
||||||
|
def write_settings(settings):
|
||||||
|
with open(SETTINGS_FILE, 'w') as settings_file:
|
||||||
|
yaml.dump(settings, settings_file)
|
||||||
|
|
||||||
|
|
||||||
def subcommand_setup(_):
|
def subcommand_setup(_):
|
||||||
"""Post installation actions for Searx"""
|
"""Post installation actions for Searx"""
|
||||||
_copy_uwsgi_configuration()
|
_copy_uwsgi_configuration()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user