diff --git a/plinth/modules/ikiwiki/__init__.py b/plinth/modules/ikiwiki/__init__.py index 72ab46354..02faed584 100644 --- a/plinth/modules/ikiwiki/__init__.py +++ b/plinth/modules/ikiwiki/__init__.py @@ -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]) diff --git a/plinth/modules/ikiwiki/privileged.py b/plinth/modules/ikiwiki/privileged.py index 2b61e9e5c..8d127d1ef 100644 --- a/plinth/modules/ikiwiki/privileged.py +++ b/plinth/modules/ikiwiki/privileged.py @@ -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."""