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 <contact@nbenedek.me>
[sunil: Update docstrings, 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 02:33:34 +02:00 committed by Sunil Mohan Adapa
parent 1659b456d1
commit f11074ab9d
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
3 changed files with 20 additions and 1 deletions

View File

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

View File

@ -10,4 +10,9 @@ clients = [{
}]
}]
backup = {}
backup = {
'data': {
'files': ['/etc/roundcube/freedombox-config.php',
'/var/lib/dbconfig-common/sqlite3/roundcube/roundcube']
}
}

View File

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