as `start` into no-ops. If that's what's explicitly desired, you might
consider setting `$SYSTEMD_OFFLINE=1`.
+* `$SYSTEMD_FIRST_BOOT=0|1` — if set, assume "first boot" condition to be false
+ or true, instead of checking the flag file created by PID 1.
+
* `$SD_EVENT_PROFILE_DELAYS=1` — if set, the sd-event event loop implementation
will print latency information at runtime.
return timespec_load_nsec(&usr.st_mtim) > timestamp;
}
+static bool in_first_boot(void) {
+ static int first_boot = -1;
+ int r;
+
+ if (first_boot >= 0)
+ return first_boot;
+
+ const char *e = secure_getenv("SYSTEMD_FIRST_BOOT");
+ if (e) {
+ r = parse_boolean(e);
+ if (r < 0)
+ log_debug_errno(r, "Failed to parse $SYSTEMD_FIRST_BOOT, ignoring: %m");
+ else
+ return (first_boot = r);
+ }
+
+ r = RET_NERRNO(access("/run/systemd/first-boot", F_OK));
+ if (r < 0 && r != -ENOENT)
+ log_debug_errno(r, "Failed to check if /run/systemd/first-boot exists, assuming no: %m");
+ return r >= 0;
+}
+
static int condition_test_first_boot(Condition *c, char **env) {
- int r, q;
+ int r;
assert(c);
assert(c->parameter);
assert(c->type == CONDITION_FIRST_BOOT);
+ // TODO: Parse c->parameter immediately when reading the config.
+ // Apply negation when parsing too.
+
r = parse_boolean(c->parameter);
if (r < 0)
return r;
- q = access("/run/systemd/first-boot", F_OK);
- if (q < 0 && errno != ENOENT)
- log_debug_errno(errno, "Failed to check if /run/systemd/first-boot exists, assuming no: %m");
-
- return (q >= 0) == r;
+ return in_first_boot() == r;
}
static int condition_test_environment(Condition *c, char **env) {