Skip to content

Commit

Permalink
status: Introduce tool to quickly check if we are booted as default
Browse files Browse the repository at this point in the history
Generally is ostree based systems you would expect to boot into
deployment 0, in rollback conditions triggered by greenboot-related
rollbacks this might not be the case. This is a tool to detect this.

Signed-off-by: Eric Curtin <[email protected]>
  • Loading branch information
ericcurtin committed Jan 5, 2024
1 parent ac8638f commit 916e4cd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/ostree/ot-admin-builtin-status.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@

static gboolean opt_verify;
static gboolean opt_skip_signatures;
static gboolean opt_query_booted;

static GOptionEntry options[]
= { { "verify", 'V', 0, G_OPTION_ARG_NONE, &opt_verify, "Print the commit verification status",
NULL },
{ "skip-signatures", 'S', 0, G_OPTION_ARG_NONE, &opt_skip_signatures,
"Print the commit verification status", NULL },
{ "query-booted", 'Q', 0, G_OPTION_ARG_NONE, &opt_query_booted,
"Print whether the default deployment is booted or not", NULL },
{ NULL } };
static gboolean
deployment_print_status (OstreeSysroot *sysroot, OstreeRepo *repo, OstreeDeployment *deployment,
Expand Down Expand Up @@ -204,6 +207,11 @@ ot_admin_builtin_status (int argc, char **argv, OstreeCommandInvocation *invocat
{
g_print ("No deployments.\n");
}
else if (opt_query_booted)
{
const gboolean is_default_booted = deployments->pdata[0] == booted_deployment;
g_print ("%s\n", is_default_booted ? "default" : "not-default");
}
else
{
for (guint i = 0; i < deployments->len; i++)
Expand Down

0 comments on commit 916e4cd

Please sign in to comment.