infinoted: Completely uninstall app

Remove DATA_DIR, KEY_DIR, CONF_PATH and SYSTEMD_SERVICE_PATH
during the uninstall process. I manually ran apt-get --purge autoremove infinoted
and these files did not get deleted.

Tests:
1. Compare the output of tree -ra /etc/infinoted/ /etc/infinoted/
before and after reinstalling the app: all the files get reinstalled properly
2. Functional tests: passed

Signed-off-by: nbenedek <contact@nbenedek.me>
[sunil: Update docstrings]
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-11 21:48:38 +02:00 committed by Sunil Mohan Adapa
parent 99dfe9fe1e
commit 7e960e7491
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
2 changed files with 16 additions and 0 deletions

View File

@ -78,3 +78,8 @@ class InfinotedApp(app_module.App):
super().setup(old_version)
privileged.setup()
self.enable()
def uninstall(self):
"""De-configure and uninstall the app."""
super().uninstall()
privileged.uninstall()

View File

@ -3,6 +3,7 @@
import grp
import os
import pathlib
import pwd
import shutil
import subprocess
@ -167,3 +168,13 @@ def setup():
group='infinoted')
action_utils.service_enable('infinoted')
@privileged
def uninstall():
"""Remove data, certs, config and systemd unit files."""
for directory in DATA_DIR, KEY_DIR:
shutil.rmtree(directory, ignore_errors=True)
for file_ in CONF_PATH, SYSTEMD_SERVICE_PATH:
pathlib.Path(file_).unlink(missing_ok=True)