summaryrefslogtreecommitdiff
path: root/src/core/condition.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-07-07 19:25:31 +0200
committerLennart Poettering <lennart@poettering.net>2014-07-07 21:05:09 +0200
commite26807239bd65bc17535a53cd540f38600e7ef24 (patch)
tree3100aec0ebcf4743d138fcf4d6d03977b8a90817 /src/core/condition.c
parent45035609fcfc3fe09324988c4929a3c147171c23 (diff)
firstboot: get rid of firstboot generator again, introduce ConditionFirstBoot= instead
As Zbigniew pointed out a new ConditionFirstBoot= appears like the nicer way to hook in systemd-firstboot.service on first boots (those with /etc unpopulated), so let's do this, and get rid of the generator again.
Diffstat (limited to 'src/core/condition.c')
-rw-r--r--src/core/condition.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/core/condition.c b/src/core/condition.c
index 410fb3679..353e0c97f 100644
--- a/src/core/condition.c
+++ b/src/core/condition.c
@@ -120,6 +120,20 @@ static bool condition_test_needs_update(Condition *c) {
(usr.st_mtim.tv_sec == other.st_mtim.tv_sec && usr.st_mtim.tv_nsec > other.st_mtim.tv_nsec)) == !c->negate;
}
+static bool condition_test_first_boot(Condition *c) {
+ int r;
+
+ assert(c);
+ assert(c->parameter);
+ assert(c->type == CONDITION_FIRST_BOOT);
+
+ r = parse_boolean(c->parameter);
+ if (r < 0)
+ return c->negate;
+
+ return ((access("/run/systemd/first-boot", F_OK) >= 0) == !!r) == !c->negate;
+}
+
static bool condition_test(Condition *c) {
assert(c);
@@ -202,6 +216,9 @@ static bool condition_test(Condition *c) {
case CONDITION_NEEDS_UPDATE:
return condition_test_needs_update(c);
+ case CONDITION_FIRST_BOOT:
+ return condition_test_first_boot(c);
+
case CONDITION_NULL:
return !c->negate;