mirror of
https://github.com/systemd/systemd.git
synced 2024-11-23 18:23:32 +08:00
Merge pull request #27787 from keszybz/firstboot-synchronous-restart
firstboot: make restart of vconsole-setup synchronuous
This commit is contained in:
commit
97d822abac
@ -13,6 +13,7 @@
|
|||||||
#include "bus-error.h"
|
#include "bus-error.h"
|
||||||
#include "bus-locator.h"
|
#include "bus-locator.h"
|
||||||
#include "bus-util.h"
|
#include "bus-util.h"
|
||||||
|
#include "bus-wait-for-jobs.h"
|
||||||
#include "chase.h"
|
#include "chase.h"
|
||||||
#include "copy.h"
|
#include "copy.h"
|
||||||
#include "creds-util.h"
|
#include "creds-util.h"
|
||||||
@ -1588,6 +1589,9 @@ static int reload_system_manager(sd_bus **bus) {
|
|||||||
|
|
||||||
static int reload_vconsole(sd_bus **bus) {
|
static int reload_vconsole(sd_bus **bus) {
|
||||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||||
|
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
|
||||||
|
_cleanup_(bus_wait_for_jobs_freep) BusWaitForJobs *w = NULL;
|
||||||
|
const char *object;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(bus);
|
assert(bus);
|
||||||
@ -1598,10 +1602,22 @@ static int reload_vconsole(sd_bus **bus) {
|
|||||||
return bus_log_connect_error(r, BUS_TRANSPORT_LOCAL);
|
return bus_log_connect_error(r, BUS_TRANSPORT_LOCAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = bus_call_method(*bus, bus_systemd_mgr, "RestartUnit", &error, NULL, "ss", "systemd-vconsole-setup.service", "replace");
|
r = bus_wait_for_jobs_new(*bus, &w);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Could not watch jobs: %m");
|
||||||
|
|
||||||
|
r = bus_call_method(*bus, bus_systemd_mgr, "RestartUnit", &error, &reply,
|
||||||
|
"ss", "systemd-vconsole-setup.service", "replace");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to issue method call: %s", bus_error_message(&error, r));
|
return log_error_errno(r, "Failed to issue method call: %s", bus_error_message(&error, r));
|
||||||
log_info("Requested vconsole setup to apply key map configuration.");
|
|
||||||
|
r = sd_bus_message_read(reply, "o", &object);
|
||||||
|
if (r < 0)
|
||||||
|
return bus_log_parse_error(r);
|
||||||
|
|
||||||
|
r = bus_wait_for_jobs_one(w, object, false, NULL);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to wait for systemd-vconsole-setup.service/restart: %m");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1483,7 +1483,7 @@ static int start_transient_scope(sd_bus *bus) {
|
|||||||
|
|
||||||
r = bus_wait_for_jobs_new(bus, &w);
|
r = bus_wait_for_jobs_new(bus, &w);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_oom();
|
return log_error_errno(r, "Could not watch jobs: %m");
|
||||||
|
|
||||||
if (arg_unit) {
|
if (arg_unit) {
|
||||||
r = unit_name_mangle_with_suffix(arg_unit, "as unit",
|
r = unit_name_mangle_with_suffix(arg_unit, "as unit",
|
||||||
@ -1725,7 +1725,7 @@ static int start_transient_trigger(sd_bus *bus, const char *suffix) {
|
|||||||
|
|
||||||
r = bus_wait_for_jobs_new(bus, &w);
|
r = bus_wait_for_jobs_new(bus, &w);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_oom();
|
return log_error_errno(r, "Could not watch jobs: %m");
|
||||||
|
|
||||||
if (arg_unit) {
|
if (arg_unit) {
|
||||||
switch (unit_name_to_type(arg_unit)) {
|
switch (unit_name_to_type(arg_unit)) {
|
||||||
|
@ -213,7 +213,7 @@ static int allocate_scope(void) {
|
|||||||
|
|
||||||
r = bus_wait_for_jobs_new(bus, &w);
|
r = bus_wait_for_jobs_new(bus, &w);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_oom();
|
return log_error_errno(r, "Could not watch jobs: %m");
|
||||||
|
|
||||||
if (asprintf(&scope, "%s-%" PRIx64 ".scope", program_invocation_short_name, random_u64()) < 0)
|
if (asprintf(&scope, "%s-%" PRIx64 ".scope", program_invocation_short_name, random_u64()) < 0)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
|
@ -15,9 +15,9 @@ ConditionPathIsReadWrite=/etc
|
|||||||
ConditionFirstBoot=yes
|
ConditionFirstBoot=yes
|
||||||
|
|
||||||
DefaultDependencies=no
|
DefaultDependencies=no
|
||||||
After=systemd-remount-fs.service
|
After=systemd-remount-fs.service systemd-sysusers.service systemd-tmpfiles-setup.service
|
||||||
Before=systemd-vconsole-setup.service sysinit.target first-boot-complete.target
|
|
||||||
Wants=first-boot-complete.target
|
Wants=first-boot-complete.target
|
||||||
|
Before=first-boot-complete.target sysinit.target
|
||||||
Conflicts=shutdown.target
|
Conflicts=shutdown.target
|
||||||
Before=shutdown.target
|
Before=shutdown.target
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user