} arg_action = ACTION_RUN;
static char *arg_default_unit = NULL;
+static char *arg_console = NULL;
static ManagerRunningAs arg_running_as = _MANAGER_RUNNING_AS_INVALID;
static bool arg_dump_core = true;
} else if (streq(word, "nomodules"))
arg_nomodules = true;
- else if (streq(word, "quiet")) {
+ else if (startswith(word, "console=")) {
+ const char *k;
+ size_t l;
+ char *w = NULL;
+
+ k = word + 8;
+ l = strcspn(k, ",");
+
+ if (l < 4 ||
+ !startswith(k, "tty") ||
+ k[3+strspn(k+3, "0123456789")] != 0) {
+
+ if (!(w = strndup(k, l)))
+ return -ENOMEM;
+ }
+
+ free(arg_console);
+ arg_console = w;
+
+ } else if (streq(word, "quiet")) {
if (!ignore_quiet)
arg_show_status = false;
} else {
int main(int argc, char *argv[]) {
Manager *m = NULL;
Unit *target = NULL;
- Job *job = NULL;
int r, retval = 1;
FDSet *fds = NULL;
bool reexecute = false;
return 1;
}
- if (label_init() < 0)
- goto finish;
-
log_show_color(isatty(STDERR_FILENO) > 0);
log_show_location(false);
log_set_max_level(LOG_INFO);
if (getpid() == 1) {
arg_running_as = MANAGER_SYSTEM;
log_set_target(LOG_TARGET_SYSLOG_OR_KMSG);
+
+ if (label_init() < 0)
+ goto finish;
} else {
arg_running_as = MANAGER_SESSION;
log_set_target(LOG_TARGET_CONSOLE);
manager_dump_units(m, stdout, "\t");
}
- if ((r = manager_add_job(m, JOB_START, target, JOB_REPLACE, false, &error, &job)) < 0) {
+ if ((r = manager_add_job(m, JOB_START, target, JOB_REPLACE, false, &error, NULL)) < 0) {
log_error("Failed to start default target: %s", bus_error(&error, r));
dbus_error_free(&error);
goto finish;
}
+ if (arg_console && arg_running_as == MANAGER_SYSTEM) {
+ char *name;
+
+ if (asprintf(&name, "getty@%s.service", arg_console) < 0)
+ log_error("Out of memory while generating console getty service name.");
+ else {
+ if ((r = manager_add_job_by_name(m, JOB_START, name, JOB_FAIL, false, &error, NULL)) < 0) {
+ log_error("Failed to start console getty target: %s", bus_error(&error, r));
+ dbus_error_free(&error);
+ }
+
+ free(name);
+ }
+ }
+
if (arg_action == ACTION_TEST) {
printf("-> By jobs:\n");
manager_dump_jobs(m, stdout, "\t");
manager_free(m);
free(arg_default_unit);
+ free(arg_console);
dbus_shutdown();