From ffcf57ee45783145451484ae94f8edc25e6a9195 Mon Sep 17 00:00:00 2001
From: Steven Armstrong <steven@icarus.ethz.ch>
Date: Wed, 4 Apr 2012 00:08:23 +0200
Subject: [PATCH] implement --state exists

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
---
 conf/type/__file/gencode-local | 3 +++
 conf/type/__file/man.text      | 6 +++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/conf/type/__file/gencode-local b/conf/type/__file/gencode-local
index d9839a19..a55cfc2b 100755
--- a/conf/type/__file/gencode-local
+++ b/conf/type/__file/gencode-local
@@ -23,6 +23,9 @@
 
 destination="/$__object_id"
 state_should="$(cat "$__object/parameter/state")"
+exists="$(cat "$__object/explorer/exists")"
+
+[ "$state_should" = "exists" -a "$exists" = "yes" ] && exit 0 # nothing to do
 
 if [ "$state_should" = "present" ]; then
    if [ -f "$__object/parameter/source" ]; then
diff --git a/conf/type/__file/man.text b/conf/type/__file/man.text
index 5e91599f..db20d857 100644
--- a/conf/type/__file/man.text
+++ b/conf/type/__file/man.text
@@ -21,7 +21,11 @@ None.
 OPTIONAL PARAMETERS
 -------------------
 state::
-   'present' or 'absent', defaults to 'present'
+   'present', 'absent' or 'exists', defaults to 'present'
+   where:
+      present: the file is exactly the one from source
+      absent: the file does not exist
+      exists: the file from source but only if it doesn't already exist
 
 group::
    Group to chgrp to.