else if (streq(d.result, "canceled"))
log_error("Job for %s canceled.", strna(d.name));
else if (streq(d.result, "dependency"))
- log_error("A dependency job for %s failed. See 'journalctl -n' for details.", strna(d.name));
+ log_error("A dependency job for %s failed. See 'journalctl -xn' for details.", strna(d.name));
else if (!streq(d.result, "done") && !streq(d.result, "skipped"))
- log_error("Job for %s failed. See 'systemctl status %s' and 'journalctl -n' for details.", strna(d.name), strna(d.name));
+ log_error("Job for %s failed. See 'systemctl status %s' and 'journalctl -xn' for details.", strna(d.name), strna(d.name));
}
if (streq_ptr(d.result, "timeout"))
return r;
}
-static int check_one_unit(DBusConnection *bus, char *name, bool quiet) {
+static int check_one_unit(DBusConnection *bus, char *name, char **check_states, bool quiet) {
DBusMessage *reply = NULL;
DBusMessageIter iter, sub;
const char
if (!quiet)
puts(state);
- if (streq(state, "active") || streq(state, "reloading"))
+ if (strv_find(check_states, state))
r = 0;
else
r = 3; /* According to LSB: "program is not running" */
sub = iter;
while (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_INVALID) {
+ char **check_states = NULL;
if (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_STRING) {
log_error("Failed to parse reply.");
dbus_message_iter_get_basic(&sub, &service_trigger);
- r = check_one_unit(bus, service_trigger, true);
+ check_states = strv_new("active", "reloading", NULL);
+ r = check_one_unit(bus, service_trigger, check_states, true);
+ strv_free(check_states);
if (r < 0)
return;
if (r == 0) {
return r;
}
-static int check_unit(DBusConnection *bus, char **args) {
+static int check_unit_active(DBusConnection *bus, char **args) {
char **name;
int r = 3; /* According to LSB: "program is not running" */
assert(args);
STRV_FOREACH(name, args+1) {
- int state = check_one_unit(bus, *name, arg_quiet);
+ char **check_states = strv_new("active", "reloading", NULL);
+ int state = check_one_unit(bus, *name, check_states, arg_quiet);
+ strv_free(check_states);
+ if (state < 0)
+ return state;
+ if (state == 0)
+ r = 0;
+ }
+
+ return r;
+}
+
+static int check_unit_failed(DBusConnection *bus, char **args) {
+ char **name;
+ int r = 1;
+
+ assert(bus);
+ assert(args);
+
+ STRV_FOREACH(name, args+1) {
+ char **check_states = strv_new("failed", NULL);
+ int state = check_one_unit(bus, *name, check_states, arg_quiet);
+ strv_free(check_states);
if (state < 0)
return state;
if (state == 0)
ExecStatusInfo *p;
const char *on, *off, *ss;
usec_t timestamp;
- char since1[FORMAT_TIMESTAMP_PRETTY_MAX], *s1;
+ char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1;
char since2[FORMAT_TIMESTAMP_MAX], *s2;
const char *path;
streq_ptr(i->active_state, "activating") ? i->inactive_exit_timestamp :
i->active_exit_timestamp;
- s1 = format_timestamp_pretty(since1, sizeof(since1), timestamp);
+ s1 = format_timestamp_relative(since1, sizeof(since1), timestamp);
s2 = format_timestamp(since2, sizeof(since2), timestamp);
if (s1)
printf("\n");
if (!i->condition_result && i->condition_timestamp > 0) {
- s1 = format_timestamp_pretty(since1, sizeof(since1), i->condition_timestamp);
+ s1 = format_timestamp_relative(since1, sizeof(since1), i->condition_timestamp);
s2 = format_timestamp(since2, sizeof(since2), i->condition_timestamp);
if (s1)
if (i->status_text)
printf("\t Status: \"%s\"\n", i->status_text);
- if (i->default_control_group) {
+ if (i->default_control_group &&
+ (i->main_pid > 0 || i->control_pid > 0 || cg_is_empty_by_spec(i->default_control_group, false) == 0)) {
unsigned c;
printf("\t CGroup: %s\n", i->default_control_group);
static int switch_root(DBusConnection *bus, char **args) {
unsigned l;
- const char *root, *init;
+ const char *root;
+ _cleanup_free_ char *init = NULL;
l = strv_length(args);
if (l < 2 || l > 3) {
}
root = args[1];
- init = l >= 3 ? args[2] : "";
+
+ if (l >= 3)
+ init = strdup(args[2]);
+ else {
+ parse_env_file("/proc/cmdline", WHITESPACE,
+ "init", &init,
+ NULL);
+
+ if (!init)
+ init = strdup("");
+
+ if (!init)
+ return log_oom();
+
+ }
+
+ log_debug("switching root - root: %s; init: %s", root, init);
return bus_method_call_with_reply (
bus,
static int enable_sysv_units(char **args) {
int r = 0;
-#if defined (HAVE_SYSV_COMPAT) && (defined(TARGET_FEDORA) || defined(TARGET_MANDRIVA) || defined(TARGET_SUSE) || defined(TARGET_ALTLINUX) || defined(TARGET_MAGEIA))
+#if defined(HAVE_SYSV_COMPAT) && defined(HAVE_CHKCONFIG)
const char *verb = args[0];
unsigned f = 1, t = 1;
LookupPaths paths;
}
if (carries_install_info == 0)
- log_warning("The unit files have no [Install] section. They are not meant to be enabled using systemctl.");
+ log_warning(
+"The unit files have no [Install] section. They are not meant to be enabled\n"
+"using systemctl.\n"
+"Possible reasons for having this kind of units are:\n"
+"1) A unit may be statically enabled by being symlinked from another unit's\n"
+" .wants/ or .requires/ directory.\n"
+"2) A unit's purpose may be to act as a helper for some other unit which has\n"
+" a requirement dependency on it.\n"
+"3) A unit may be started when needed via activation (socket, path, timer,\n"
+" D-Bus, udev, scripted systemctl call, ...).\n");
finish:
if (m)
" reload [NAME...] Reload one or more units\n"
" restart [NAME...] Start or restart one or more units\n"
" try-restart [NAME...] Restart one or more units if active\n"
- " reload-or-restart [NAME...] Reload one or more units is possible,\n"
+ " reload-or-restart [NAME...] Reload one or more units if possible,\n"
" otherwise start or restart\n"
- " reload-or-try-restart [NAME...] Reload one or more units is possible,\n"
+ " reload-or-try-restart [NAME...] Reload one or more units if possible,\n"
" otherwise restart if active\n"
" isolate [NAME] Start one unit and stop all others\n"
" kill [NAME...] Send signal to processes of a unit\n"
" is-active [NAME...] Check whether units are active\n"
+ " is-failed [NAME...] Check whether units are failed\n"
" status [NAME...|PID...] Show runtime status of one or more units\n"
" show [NAME...|JOB...] Show properties of one or more\n"
" units/jobs or the manager\n"
{ "condrestart", MORE, 2, start_unit }, /* For compatibility with RH */
{ "isolate", EQUAL, 2, start_unit },
{ "kill", MORE, 2, kill_unit },
- { "is-active", MORE, 2, check_unit },
- { "check", MORE, 2, check_unit },
+ { "is-active", MORE, 2, check_unit_active },
+ { "check", MORE, 2, check_unit_active },
+ { "is-failed", MORE, 2, check_unit_failed },
{ "show", MORE, 1, show },
{ "status", MORE, 2, show },
{ "help", MORE, 2, show },