chiark / gitweb /
firstboot: get rid of firstboot generator again, introduce ConditionFirstBoot= instead
[elogind.git] / src / core / condition.c
index 410fb36797808757f39bcf71fca52af994a6629f..353e0c97f1d64c50bf15f24a1076af748e1ca508 100644 (file)
@@ -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;