From f11074ab9d44b682343db111ea77492222aab029 Mon Sep 17 00:00:00 2001 From: nbenedek Date: Fri, 7 Apr 2023 02:33:34 +0200 Subject: [PATCH] roundcube: Completely uninstall app * remove local config and sqlite file * add them to the backup manifest Tests: 1. Modify the user's email address inside roundcube 2. Reinstall the app and confirm the modification was reset 3. Functional tests passed Signed-off-by: nbenedek [sunil: Update docstrings, make uninstall fail-safe] Signed-off-by: Sunil Mohan Adapa Reviewed-by: Sunil Mohan Adapa --- plinth/modules/roundcube/__init__.py | 5 +++++ plinth/modules/roundcube/manifest.py | 7 ++++++- plinth/modules/roundcube/privileged.py | 9 +++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/plinth/modules/roundcube/__init__.py b/plinth/modules/roundcube/__init__.py index 86e6ee0c2..214b087e7 100644 --- a/plinth/modules/roundcube/__init__.py +++ b/plinth/modules/roundcube/__init__.py @@ -95,6 +95,11 @@ class RoundcubeApp(app_module.App): privileged.set_config(local_only=True) self.enable() + def uninstall(self): + """De-configure and uninstall the app.""" + super().uninstall() + privileged.uninstall() + def force_upgrade(self, packages): """Force upgrade package to resolve conffile prompts.""" if 'roundcube-core' not in packages: diff --git a/plinth/modules/roundcube/manifest.py b/plinth/modules/roundcube/manifest.py index ee3219da3..314d6740c 100644 --- a/plinth/modules/roundcube/manifest.py +++ b/plinth/modules/roundcube/manifest.py @@ -10,4 +10,9 @@ clients = [{ }] }] -backup = {} +backup = { + 'data': { + 'files': ['/etc/roundcube/freedombox-config.php', + '/var/lib/dbconfig-common/sqlite3/roundcube/roundcube'] + } +} diff --git a/plinth/modules/roundcube/privileged.py b/plinth/modules/roundcube/privileged.py index 1fd6591ba..403e1e591 100644 --- a/plinth/modules/roundcube/privileged.py +++ b/plinth/modules/roundcube/privileged.py @@ -8,6 +8,8 @@ from plinth import action_utils from plinth.actions import privileged _config_file = pathlib.Path('/etc/roundcube/freedombox-config.php') +_rc_db_file = pathlib.Path('/var/lib/dbconfig-common/sqlite3/' + 'roundcube/roundcube') @privileged @@ -68,3 +70,10 @@ $config['smtp_helo_host'] = 'localhost'; ''' _config_file.write_text(config, encoding='utf-8') + + +@privileged +def uninstall(): + """Remove config file and database.""" + for item in _config_file, _rc_db_file: + item.unlink(missing_ok=True)