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 <contact@nbenedek.me>
[sunil: Update docstings and 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 00:02:31 +02:00 committed by Sunil Mohan Adapa
parent db2d42c5ac
commit 615c47e49f
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
2 changed files with 15 additions and 0 deletions

View File

@ -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()

View File

@ -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)