matrixsynapse: Completely uninstall app

Remove database, mediafiles and freedombox configs.
Removal of certs are not neccessary since the next setup will
overwrite them

Test:
1. Install the app and set a domain
2. Reinstall the app and confirm the domain can be set like it's the first time

Signed-off-by: nbenedek <contact@nbenedek.me>
[sunil: Update docstrings, make uninstall fail-safe]
[sunil: Fix uninstall functional test]
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:18:02 +02:00 committed by Sunil Mohan Adapa
parent b2ad4088aa
commit 1659b456d1
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
3 changed files with 18 additions and 0 deletions

View File

@ -126,6 +126,11 @@ class MatrixSynapseApp(app_module.App):
config = self.get_component('turn-matrixsynapse').get_configuration()
update_turn_configuration(config, force=True)
def uninstall(self):
"""De-configure and uninstall the app."""
super().uninstall()
privileged.uninstall()
class MatrixSynapseTurnConsumer(TurnConsumer):
"""Component to manage Coturn configuration for Matrix Synapse."""

View File

@ -339,3 +339,10 @@ def _generate_mac(shared_secret: str, nonce: str, user: str, password: str,
mac.update(user_type.encode('utf8'))
return mac.hexdigest()
@privileged
def uninstall():
"""Delete configuration and data directories."""
for item in ['/etc/matrix-synapse/conf.d', '/var/lib/matrix-synapse']:
shutil.rmtree(item, ignore_errors=True)

View File

@ -24,3 +24,9 @@ class TestMatrixSynapseApp(functional.BaseAppTests):
functional.install(session_browser, self.app_name)
functional.app_select_domain_name(session_browser, self.app_name,
'mydomain.example')
def test_uninstall(self, session_browser):
"""After uninstall test, after installing select the domain again."""
super().test_uninstall(session_browser)
functional.app_select_domain_name(session_browser, self.app_name,
'mydomain.example')