ikiwiki: Re-run setup for each site after restore

Closes: #2028.

Tests:

- Backup and restore with no sites.

- Backup and restore with one wiki and one blog. Confirm that login
  works for both sites.

- Backup from one container, and restore in another container. Confirm
  that login works for both sites.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
James Valleroy 2023-01-31 10:57:24 -05:00 committed by Sunil Mohan Adapa
parent 9cec959cd1
commit a179dd302e
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
2 changed files with 20 additions and 2 deletions

View File

@ -74,8 +74,8 @@ class IkiwikiApp(app_module.App):
groups=groups)
self.add(users_and_groups)
backup_restore = BackupRestore('backup-restore-ikiwiki',
**manifest.backup)
backup_restore = IkiwikiBackupRestore('backup-restore-ikiwiki',
**manifest.backup)
self.add(backup_restore)
def post_init(self):
@ -111,3 +111,14 @@ class IkiwikiApp(app_module.App):
super().setup(old_version)
privileged.setup()
self.enable()
class IkiwikiBackupRestore(BackupRestore):
"""Component to handle Ikiwiki restore"""
def restore_post(self, packet):
"""Re-run setup for each wiki after restore."""
super().restore_post(packet)
sites = privileged.get_sites()
for site in sites:
privileged.setup_site(site[0])

View File

@ -78,6 +78,13 @@ def create_blog(blog_name: str, admin_name: str, admin_password: str):
PERL_UNICODE='AS'))
@privileged
def setup_site(site_name: str):
"""Run setup for a site."""
setup_path = os.path.join(WIKI_PATH, site_name + '.setup')
subprocess.run(['ikiwiki', '-setup', setup_path], check=True)
@privileged
def delete(name: str):
"""Delete a wiki or blog."""