diff --git a/plinth/modules/bepasty/__init__.py b/plinth/modules/bepasty/__init__.py index d02b8139b..8b2b9a423 100644 --- a/plinth/modules/bepasty/__init__.py +++ b/plinth/modules/bepasty/__init__.py @@ -99,3 +99,8 @@ class BepastyApp(app_module.App): # Upgrade to a better default only if user hasn't changed the # value. privileged.set_default(['read']) + + def uninstall(self): + """De-configure and uninstall the app.""" + super().uninstall() + privileged.uninstall() diff --git a/plinth/modules/bepasty/privileged.py b/plinth/modules/bepasty/privileged.py index 4c28ec803..d0e37bcb8 100644 --- a/plinth/modules/bepasty/privileged.py +++ b/plinth/modules/bepasty/privileged.py @@ -168,3 +168,12 @@ def _generate_password(): """Generate a random password.""" alphabet = string.ascii_letters + string.digits return ''.join(secrets.choice(alphabet) for _ in range(PASSWORD_LENGTH)) + + +@privileged +def uninstall(): + """Remove bepasty user, group and data.""" + shutil.rmtree(DATA_DIR, ignore_errors=True) + CONF_FILE.unlink(missing_ok=True) + subprocess.run(['deluser', 'bepasty'], check=False) + subprocess.run(['delgroup', 'bepasty'], check=False)