summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-11-22 19:18:52 +0100
committerLennart Poettering <lennart@poettering.net>2013-11-22 19:27:56 +0100
commitdbc2c080debdc45683bc5534e327455d4fbbbea7 (patch)
tree7f18e82c9012d46486e831bf8fbc11bcfe7332a4 /src
parent92c1622e14dd99890928b1a1596e4a670b31a7ff (diff)
systemctl: indicate in list-dependencies whether a unit is already running
Diffstat (limited to 'src')
-rw-r--r--src/shared/util.h4
-rw-r--r--src/systemctl/systemctl.c10
2 files changed, 14 insertions, 0 deletions
diff --git a/src/shared/util.h b/src/shared/util.h
index 00d2364c61..e46438c92d 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -395,6 +395,10 @@ static inline const char *ansi_highlight_green(void) {
return on_tty() ? ANSI_HIGHLIGHT_GREEN_ON : "";
}
+static inline const char *ansi_highlight_yellow(void) {
+ return on_tty() ? ANSI_HIGHLIGHT_YELLOW_ON : "";
+}
+
static inline const char *ansi_highlight_off(void) {
return on_tty() ? ANSI_HIGHLIGHT_OFF : "";
}
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index bd443e98ce..fa6447607a 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -137,6 +137,8 @@ static bool arg_plain = false;
static int daemon_reload(sd_bus *bus, char **args);
static int halt_now(enum action a);
+static int check_one_unit(sd_bus *bus, const char *name, const char *good_states, bool quiet);
+
static void pager_open_if_enabled(void) {
if (arg_no_pager)
@@ -1309,6 +1311,8 @@ static int list_dependencies_one(
qsort_safe(deps, strv_length(deps), sizeof (char*), list_dependencies_compare);
STRV_FOREACH(c, deps) {
+ int state;
+
if (strv_contains(u, *c)) {
if (!arg_plain) {
r = list_dependencies_print("...", level + 1, (branches << 1) | (c[1] == NULL ? 0 : 1), 1);
@@ -1318,6 +1322,12 @@ static int list_dependencies_one(
continue;
}
+ state = check_one_unit(bus, *c, "activating\0active\0reloading\0", true);
+ if (state > 0)
+ printf("%s%s%s", ansi_highlight_green(), draw_special_char(DRAW_BLACK_CIRCLE), ansi_highlight_off());
+ else
+ printf("%s%s%s", ansi_highlight_red(), draw_special_char(DRAW_BLACK_CIRCLE), ansi_highlight_off());
+
r = list_dependencies_print(*c, level, branches, c[1] == NULL);
if (r < 0)
return r;