searx: Completely uninstall app

* If only the SETTINGS_FILE gets removed, the setup
    process fails afterwards
* Don't remove the public access file since the setup process
    will remove it anyway

Test: Functional tests passed

Signed-off-by: nbenedek <contact@nbenedek.me>
[sunil: Update docstrings, make uninstall fail-safe]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
nbenedek 2023-04-07 02:56:28 +02:00 committed by Sunil Mohan Adapa
parent 17e062e829
commit be7fd45393
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
2 changed files with 12 additions and 0 deletions

View File

@ -100,6 +100,11 @@ class SearxApp(app_module.App):
self.enable()
self.set_shortcut_login_required(True)
def uninstall(self):
"""De-configure and uninstall the app."""
super().uninstall()
privileged.unininstall()
class SearxWebserverAuth(Webserver):
"""Component to handle Searx authentication webserver configuration."""

View File

@ -153,3 +153,10 @@ def disable_public_access():
"""Disable public access to the SearX application."""
if os.path.exists(PUBLIC_ACCESS_SETTING_FILE):
os.remove(PUBLIC_ACCESS_SETTING_FILE)
@privileged
def unininstall():
"""Remove configuration uWSGI file."""
shutil.rmtree('/etc/searx', ignore_errors=True)
pathlib.Path(UWSGI_FILE).unlink(missing_ok=True)