From 9737e2c850c5ff547510d625a80fad890761a3b4 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Tue, 9 Jan 2024 19:53:18 +0800 Subject: [PATCH] hostnamed: use Type=notify --- src/hostname/hostnamed.c | 5 +++++ units/systemd-hostnamed.service.in | 1 + 2 files changed, 6 insertions(+) diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c index f01d771f9bc..0e06a16a241 100644 --- a/src/hostname/hostnamed.c +++ b/src/hostname/hostnamed.c @@ -14,6 +14,7 @@ #include "bus-log-control-api.h" #include "bus-polkit.h" #include "constants.h" +#include "daemon-util.h" #include "env-file-label.h" #include "env-file.h" #include "env-util.h" @@ -1733,6 +1734,10 @@ static int run(int argc, char *argv[]) { if (r < 0) return r; + r = sd_notify(false, NOTIFY_READY); + if (r < 0) + log_warning_errno(r, "Failed to send readiness notification, ignoring: %m"); + r = bus_event_loop_with_idle( context.event, context.bus, diff --git a/units/systemd-hostnamed.service.in b/units/systemd-hostnamed.service.in index 1cc15dd7cfd..ab00c24b53b 100644 --- a/units/systemd-hostnamed.service.in +++ b/units/systemd-hostnamed.service.in @@ -15,6 +15,7 @@ Documentation=man:machine-info(5) Documentation=man:org.freedesktop.hostname1(5) [Service] +Type=notify BusName=org.freedesktop.hostname1 CapabilityBoundingSet=CAP_SYS_ADMIN ExecStart={{LIBEXECDIR}}/systemd-hostnamed