From 3b67ff7730fd53179c563773a670d9f1ee3294ad Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Thu, 26 Aug 2021 16:13:35 +0200 Subject: [PATCH] Set correct systemd default target --- CHANGELOG.adoc | 3 +++ src/provider/systemdmanager/systemdunit.rs | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 413e13b..0699682 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -32,6 +32,9 @@ systemd manages restarts now and the Stackable agent cannot detect if a service is in a restart loop ({263}). +=== Fixed +* Systemd services in session mode are restarted after a reboot ({263}). + == 0.5.0 - 2021-07-26 :224: https://github.com/stackabletech/agent/pull/224[#224] diff --git a/src/provider/systemdmanager/systemdunit.rs b/src/provider/systemdmanager/systemdunit.rs index 906635c..d3d1d95 100644 --- a/src/provider/systemdmanager/systemdunit.rs +++ b/src/provider/systemdmanager/systemdunit.rs @@ -227,7 +227,15 @@ impl SystemDUnit { } // This one is mandatory, as otherwise enabling the unit fails - unit.set_property(Section::Install, "WantedBy", "multi-user.target"); + unit.set_property( + Section::Install, + "WantedBy", + if user_mode { + "default.target" + } else { + "multi-user.target" + }, + ); Ok(unit) } @@ -727,7 +735,7 @@ mod test { TimeoutStopSec=30 [Install] - WantedBy=multi-user.target"#} + WantedBy=default.target"#} )] #[case::set_termination_timeout( BusType::System,