mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-17 03:21:57 +00:00
fu-util-common: when stopping a daemon, check for snap too
This commit is contained in:
parent
5cbb5cf908
commit
ea527ca2e7
@ -17,6 +17,15 @@
|
|||||||
#define SYSTEMD_OBJECT_PATH "/org/freedesktop/systemd1"
|
#define SYSTEMD_OBJECT_PATH "/org/freedesktop/systemd1"
|
||||||
#define SYSTEMD_MANAGER_INTERFACE "org.freedesktop.systemd1.Manager"
|
#define SYSTEMD_MANAGER_INTERFACE "org.freedesktop.systemd1.Manager"
|
||||||
#define SYSTEMD_FWUPD_UNIT "fwupd.service"
|
#define SYSTEMD_FWUPD_UNIT "fwupd.service"
|
||||||
|
#define SYSTEMD_SNAP_FWUPD_UNIT "snap.fwupd.fwupd.service"
|
||||||
|
|
||||||
|
static const gchar *
|
||||||
|
fu_util_get_systemd_unit (void)
|
||||||
|
{
|
||||||
|
if (g_getenv ("SNAP") != NULL)
|
||||||
|
return SYSTEMD_SNAP_FWUPD_UNIT;
|
||||||
|
return SYSTEMD_FWUPD_UNIT;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
fu_util_stop_daemon (GError **error)
|
fu_util_stop_daemon (GError **error)
|
||||||
@ -24,8 +33,8 @@ fu_util_stop_daemon (GError **error)
|
|||||||
g_autoptr(GDBusConnection) connection = NULL;
|
g_autoptr(GDBusConnection) connection = NULL;
|
||||||
g_autoptr(GDBusProxy) proxy = NULL;
|
g_autoptr(GDBusProxy) proxy = NULL;
|
||||||
g_autoptr(GVariant) val = NULL;
|
g_autoptr(GVariant) val = NULL;
|
||||||
|
const gchar *target = fu_util_get_systemd_unit ();
|
||||||
|
|
||||||
/* try to stop any already running daemon */
|
|
||||||
connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, error);
|
connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, error);
|
||||||
if (connection == NULL) {
|
if (connection == NULL) {
|
||||||
g_prefix_error (error, "failed to get bus: ");
|
g_prefix_error (error, "failed to get bus: ");
|
||||||
@ -46,20 +55,20 @@ fu_util_stop_daemon (GError **error)
|
|||||||
val = g_dbus_proxy_call_sync (proxy,
|
val = g_dbus_proxy_call_sync (proxy,
|
||||||
"GetUnit",
|
"GetUnit",
|
||||||
g_variant_new ("(s)",
|
g_variant_new ("(s)",
|
||||||
SYSTEMD_FWUPD_UNIT),
|
target),
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
-1,
|
-1,
|
||||||
NULL,
|
NULL,
|
||||||
error);
|
error);
|
||||||
if (val == NULL) {
|
if (val == NULL) {
|
||||||
g_prefix_error (error, "failed to find %s: ", SYSTEMD_FWUPD_UNIT);
|
g_prefix_error (error, "failed to find %s: ", target);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
g_variant_unref (val);
|
g_variant_unref (val);
|
||||||
val = g_dbus_proxy_call_sync (proxy,
|
val = g_dbus_proxy_call_sync (proxy,
|
||||||
"StopUnit",
|
"StopUnit",
|
||||||
g_variant_new ("(ss)",
|
g_variant_new ("(ss)",
|
||||||
SYSTEMD_FWUPD_UNIT,
|
target,
|
||||||
"replace"),
|
"replace"),
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
-1,
|
-1,
|
||||||
|
Loading…
Reference in New Issue
Block a user