summaryrefslogtreecommitdiffstats
path: root/src/core/timer.c
diff options
context:
space:
mode:
authorLuca Boccassi <bluca@debian.org>2023-07-20 02:22:52 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2023-07-21 18:05:41 +0200
commitb80fc61e8971283606f9cd0a48e31d0f701c82f1 (patch)
treef54febc8671c65511d97e865ce4a7b438be8d137 /src/core/timer.c
parentMerge pull request #28460 from bluca/scope_run_env (diff)
downloadsystemd-b80fc61e8971283606f9cd0a48e31d0f701c82f1.tar.xz
systemd-b80fc61e8971283606f9cd0a48e31d0f701c82f1.zip
core: add IgnoreOnSoftReboot= unit option
As it says on the tin, configures the unit to survive a soft reboot. Currently all the following options have to be set by hand: Conflicts=reboot.target kexec.target poweroff.target halt.target Before=reboot.target kexec.target poweroff.target halt.target After=sysinit.target basic.target DefaultDependencies=no IgnoreOnIsolate=yes This is not very user friendly. If new default dependencies are added, or new shutdown/reboot types, they also have to be added manually. The new option is much simpler, easy to find, and does the right thing by default.
Diffstat (limited to 'src/core/timer.c')
-rw-r--r--src/core/timer.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/core/timer.c b/src/core/timer.c
index f6e6605507..3aaebe72c6 100644
--- a/src/core/timer.c
+++ b/src/core/timer.c
@@ -94,7 +94,12 @@ static int timer_add_default_dependencies(Timer *t) {
return r;
if (MANAGER_IS_SYSTEM(UNIT(t)->manager)) {
- r = unit_add_two_dependencies_by_name(UNIT(t), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, true, UNIT_DEPENDENCY_DEFAULT);
+ r = unit_add_two_dependencies_by_name(UNIT(t),
+ UNIT_AFTER,
+ UNIT(t)->ignore_on_soft_reboot ? -EINVAL : UNIT_REQUIRES,
+ SPECIAL_SYSINIT_TARGET,
+ true,
+ UNIT_DEPENDENCY_DEFAULT);
if (r < 0)
return r;
@@ -112,7 +117,14 @@ static int timer_add_default_dependencies(Timer *t) {
}
}
- return unit_add_two_dependencies_by_name(UNIT(t), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, true, UNIT_DEPENDENCY_DEFAULT);
+ if (!UNIT(t)->ignore_on_soft_reboot)
+ return unit_add_two_dependencies_by_name(
+ UNIT(t),
+ UNIT_BEFORE, UNIT_CONFLICTS,
+ SPECIAL_SHUTDOWN_TARGET, true,
+ UNIT_DEPENDENCY_DEFAULT);
+
+ return unit_add_dependencies_on_real_shutdown_targets(UNIT(t));
}
static int timer_add_trigger_dependencies(Timer *t) {