diff --git a/man/initctl.8 b/man/initctl.8 index 09adcbb7..fbab638a 100644 --- a/man/initctl.8 +++ b/man/initctl.8 @@ -118,6 +118,13 @@ Show condition status, default command. .It Nm Ar cond dump Dump all conditions and their status +.It Nm Ar ident Op Cm NAME +Display indentities of all run/task/services, or only instances +matching +.Cm NAME . +A partial string, e.g., +.Cm NAM , +will not match anything .It Nm Ar log Op Cm NAME Show ten last Finit, or .Cm NAME , diff --git a/src/initctl.c b/src/initctl.c index f6677fd8..e1605330 100644 --- a/src/initctl.c +++ b/src/initctl.c @@ -803,6 +803,30 @@ static int show_status(char *arg) return 0; } +static int show_ident(char *arg) +{ + svc_t *svc; + + for (svc = client_svc_iterator(1); svc; svc = client_svc_iterator(0)) { + char ident[MAX_IDENT_LEN]; + size_t len; + char *pos; + + svc_ident(svc, ident, sizeof(ident)); + pos = strchr(ident, ':'); + if (pos) + len = pos - ident; + else + len = strlen(ident); + if (arg && arg[0] && strncasecmp(ident, arg, len)) + continue; + + puts(ident); + } + + return 0; +} + static int transform(char *nm) { char *names[] = { @@ -899,6 +923,7 @@ static int usage(int rc) " stop [:ID] Stop/Pause a running service by name\n" " reload [:ID] Reload service by name (SIGHUP or restart)\n" " restart [:ID] Restart (stop/start) service by name\n" + " ident [NAME] Show matching identities for NAME, or all\n" " status [:ID] Show service status, by name\n" " status Show status of services, default command\n" "\n" @@ -992,6 +1017,7 @@ int main(int argc, char *argv[]) }; struct cmd command[] = { { "status", NULL, show_status }, /* default cmd */ + { "ident", NULL, show_ident }, { "debug", NULL, toggle_debug }, { "devel", NULL, do_devel },