From 615c47e49f621324a83f3da82732628be19a2bb8 Mon Sep 17 00:00:00 2001 From: nbenedek Date: Fri, 7 Apr 2023 00:02:31 +0200 Subject: [PATCH] deluge: Completely uninstall app Remove deluge default file, config directory, and systemd service file Test: 1. In a Vagrant box manually install the app 2. Modify the default download path and change the default password 3. Uninstall the app 4. Confirm that the download path and password are reset to default 5. Also test enabling and disabling the app after reinstallation Signed-off-by: nbenedek [sunil: Update docstings and make uninstall fail-safe] Signed-off-by: Sunil Mohan Adapa Reviewed-by: Sunil Mohan Adapa --- plinth/modules/deluge/__init__.py | 5 +++++ plinth/modules/deluge/privileged.py | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/plinth/modules/deluge/__init__.py b/plinth/modules/deluge/__init__.py index ffcb1e639..4c7e5daed 100644 --- a/plinth/modules/deluge/__init__.py +++ b/plinth/modules/deluge/__init__.py @@ -100,3 +100,8 @@ class DelugeApp(app_module.App): add_user_to_share_group(SYSTEM_USER) privileged.setup() self.enable() + + def uninstall(self): + """De-configure and uninstall the app.""" + super().uninstall() + privileged.uninstall() diff --git a/plinth/modules/deluge/privileged.py b/plinth/modules/deluge/privileged.py index d507b5a56..186739e19 100644 --- a/plinth/modules/deluge/privileged.py +++ b/plinth/modules/deluge/privileged.py @@ -2,6 +2,7 @@ """Configuration helper for BitTorrent web client.""" import pathlib +import shutil import subprocess import time @@ -154,3 +155,12 @@ def _wait_for_configuration(service, file_name): if not is_running: action_utils.service_stop(service) + + +@privileged +def uninstall(): + """Remove configuration and service files.""" + for item in DELUGED_DEFAULT_FILE, DELUGE_WEB_SYSTEMD_SERVICE_PATH: + pathlib.Path(item).unlink(missing_ok=True) + + shutil.rmtree(DELUGE_CONF_DIR, ignore_errors=True)