searx: Set page title to 'FreedomBox Web Search'

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Joseph Nuthalapati 2018-02-21 20:23:39 +05:30 committed by Sunil Mohan Adapa
parent d42492d4df
commit 314f95d562
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2

View File

@ -25,9 +25,11 @@ import os
import secrets
import shutil
from plinth import action_utils
from plinth import action_utils, cfg
from plinth.utils import YAMLFile, gunzip
SETTINGS_FILE = '/etc/searx/settings.yml'
def parse_arguments():
"""Return parsed command line arguments as dictionary."""
@ -60,25 +62,33 @@ def _copy_uwsgi_configuration():
def _generate_secret_key():
""" Generate a secret key for the Searx installation."""
settings_file = '/etc/searx/settings.yml'
# Create settings file if not exists
if not os.path.exists(settings_file):
if not os.path.exists(SETTINGS_FILE):
example_settings_file = '/usr/share/doc/searx/examples/settings.yml.gz'
gunzip(example_settings_file, settings_file)
gunzip(example_settings_file, SETTINGS_FILE)
# Generate and set a secret key
with YAMLFile(settings_file) as settings:
with YAMLFile(SETTINGS_FILE) as settings:
secret_key = secrets.token_hex(32)
settings['server']['secret_key'] = secret_key
action_utils.service_restart('uwsgi')
def _set_title():
"""Set the page title to '{box_name} Web Search'."""
with YAMLFile(SETTINGS_FILE) as settings:
title = 'FreedomBox Web Search'
settings['general']['instance_name'] = title
action_utils.service_restart('uwsgi')
def subcommand_setup(_):
"""Post installation actions for Searx"""
_copy_uwsgi_configuration()
_generate_secret_key()
_set_title()
def subcommand_enable(_):