From 623604649e5427ce8a6e2ae2e0e82f44b428448f Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Mon, 27 Oct 2025 20:43:56 -0700 Subject: [PATCH] views: Implement an API to retrieve the readiness status in JSON - This can have may uses such as: - Waiting properly on the reboot page until the system has been restarted while showing the status. - Or, waiting for first setup to complete before running functional tests. - Or, monitoring for the health status of FreedomBox in general. - The page is public as all the information conveyed there is also already public. Should we introduce any sensitive information there such as 'operations_in_progress', we can provide that information only to administrators. Tests: - Visiting /plinth/status/ shows the status in JSON. Using curl to retrieve the information is also possible. - During the first setup 'is_first_setup_running' is 'true'. After it has completed, it is 'false'. Signed-off-by: Sunil Mohan Adapa Reviewed-by: Veiko Aasa --- plinth/modules/first_boot/middleware.py | 5 +++-- plinth/urls.py | 1 + plinth/views.py | 10 ++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/plinth/modules/first_boot/middleware.py b/plinth/modules/first_boot/middleware.py index fee5b2991..bec324f7c 100644 --- a/plinth/modules/first_boot/middleware.py +++ b/plinth/modules/first_boot/middleware.py @@ -30,9 +30,10 @@ class FirstBootMiddleware(MiddlewareMixin): if user_requests_login: return - # Don't interfere with help pages + # Don't interfere with help or status pages user_requests_help = request.path.startswith(reverse('help:index')) - if user_requests_help: + user_requests_status = request.path.startswith(reverse('status')) + if user_requests_help or user_requests_status: return # Don't interfere with first setup progress page. When first setup is diff --git a/plinth/urls.py b/plinth/urls.py index 60e3c3196..8842e7b88 100644 --- a/plinth/urls.py +++ b/plinth/urls.py @@ -18,6 +18,7 @@ system_urlpatterns = [ urlpatterns = [ re_path(r'^$', views.index, name='index'), + re_path(r'^status/$', views.status, name='status'), re_path(r'^language-selection/$', public(views.LanguageSelectionView.as_view()), name='language-selection'), diff --git a/plinth/views.py b/plinth/views.py index f72fd60bb..c90e23429 100644 --- a/plinth/views.py +++ b/plinth/views.py @@ -178,6 +178,16 @@ def index(request): }) +@public +def status(request): + """Return the status of service in JSON format.""" + status = { + 'is_available': True, + 'is_first_setup_running': setup.is_first_setup_running + } + return JsonResponse(status) + + def _pick_menu_items(menu_items, selected_tags): """Return a sorted list of menu items filtered by tags."""