mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
ikiwiki: Completely uninstall app
Tests: 1. Create a wiki and a blog 2. Reinstall the app and confirm the sites get deleted 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:
parent
53f4edb016
commit
b2ad4088aa
@ -112,6 +112,11 @@ class IkiwikiApp(app_module.App):
|
||||
privileged.setup()
|
||||
self.enable()
|
||||
|
||||
def uninstall(self):
|
||||
"""De-configure and uninstall the app."""
|
||||
super().uninstall()
|
||||
privileged.uninstall()
|
||||
|
||||
|
||||
class IkiwikiBackupRestore(BackupRestore):
|
||||
"""Component to handle Ikiwiki restore"""
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
"""Configure ikiwiki."""
|
||||
|
||||
import os
|
||||
import pathlib
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
@ -96,10 +97,14 @@ def delete(name: str):
|
||||
raise ValueError(
|
||||
'Error: {0} is not a correct wiki/blog name.'.format(name))
|
||||
|
||||
try:
|
||||
shutil.rmtree(html_folder)
|
||||
shutil.rmtree(wiki_folder)
|
||||
shutil.rmtree(wiki_folder + '.git')
|
||||
os.remove(wiki_folder + '.setup')
|
||||
except FileNotFoundError:
|
||||
raise RuntimeError('Unable to delete wiki/blog')
|
||||
shutil.rmtree(html_folder, ignore_errors=True)
|
||||
shutil.rmtree(wiki_folder, ignore_errors=True)
|
||||
shutil.rmtree(wiki_folder + '.git', ignore_errors=True)
|
||||
pathlib.Path(wiki_folder + '.setup').unlink(missing_ok=True)
|
||||
|
||||
|
||||
@privileged
|
||||
def uninstall():
|
||||
"""Remove all ikiwiki sites."""
|
||||
for site in get_sites():
|
||||
delete(site[0])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user