apache: Fix issue with re-running app setup

After removing the index page, when setup is re-run, the setup fails. Fix this
by ignoring the step of index page does not exist.

Tests:

- Rerun apache app setup by removing plinth.sqlite3 or incrementing the app
version number of the initial setup. Without the patch, the setup fails. With
the patch, it succeeds.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa authored and James Valleroy committed 2026-11-28 08:31:54 -05:00
1 parent 9f45088c65
commit b84749a07d
1 file changed
+5 -2
+5 -2
View File
@@ -67,8 +67,11 @@ def _remove_default_index_html():
default_page = pathlib.Path('/var/www/html/index.html')
shipped_default_page = pathlib.Path(
'/usr/share/apache2/default-site/index.html')
if default_page.read_text() == shipped_default_page.read_text():
default_page.unlink(missing_ok=True)
try:
if default_page.read_text() == shipped_default_page.read_text():
default_page.unlink(missing_ok=True)
except FileNotFoundError:
pass
@privileged