]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/core/target.c
core: add IgnoreOnSoftReboot= unit option
[thirdparty/systemd.git] / src / core / target.c
index 3519b4b653a05b1a4b6ca63bc42811e3c67ce083..3cb17b9843489b7943a378a14e02a35e7284c723 100644 (file)
@@ -66,7 +66,16 @@ static int target_add_default_dependencies(Target *t) {
                 return 0;
 
         /* Make sure targets are unloaded on shutdown */
-        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);
+
+        /* Unless we are meant to survive soft reboot, in which case we need to conflict with
+         * non-soft-reboot targets. */
+        return unit_add_dependencies_on_real_shutdown_targets(UNIT(t));
 }
 
 static int target_load(Unit *u) {