openvpn: Completely uninstall app

Remove /etc/openvpn when the app is uninstalled

* Tests:
1. Uninstall app and manually check if /etc/openvpn gets removed
2. Sucessfully install app
3. Functional tests: passed
4. In case we choose to purge packages in the future: I checked purging openvpn and it will not
remove /etc/openvpn.

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-15 14:45:49 +02:00 committed by Sunil Mohan Adapa
parent 7e960e7491
commit 4d7651c89f
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
2 changed files with 12 additions and 0 deletions

View File

@ -91,3 +91,8 @@ class OpenVPNApp(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

@ -2,6 +2,7 @@
"""Configure OpenVPN server."""
import os
import shutil
import subprocess
import augeas
@ -222,3 +223,9 @@ def load_augeas():
aug.set('/augeas/load/Simplevars/incl[last() + 1]', ATTR_FILE)
aug.load()
return aug
@privileged
def uninstall():
"""Remove configuration directory for OpenVPN."""
shutil.rmtree('/etc/openvpn', ignore_errors=True)