From e72c39b786eaee7e693a58cb579e311a3944ca71 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 20 Jan 2012 13:12:14 +0100 Subject: [PATCH 1/2] ++todo (absent/present) Signed-off-by: Nico Schottelius Conflicts: doc/dev/todo/TAKEME Signed-off-by: Nico Schottelius --- doc/dev/todo/TAKEME | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/dev/todo/TAKEME b/doc/dev/todo/TAKEME index 25d088b9..abcd5097 100644 --- a/doc/dev/todo/TAKEME +++ b/doc/dev/todo/TAKEME @@ -36,6 +36,5 @@ TYPES ------ - __user add option to include --create-home -- __init_script? - to enable/disable startup of init stuff - http://linuxhelp.blogspot.com/2006/04/enabling-and-disabling-services-during_01.html +- ensure that all types, which support --state support + present and absent (consistent look and feel) From 578fd664e44ecfbac7ab7a89fc27faa401528ca0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 20 Jan 2012 13:14:24 +0100 Subject: [PATCH 2/2] __process: support present/absent Signed-off-by: Nico Schottelius --- conf/type/__process/gencode-remote | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/conf/type/__process/gencode-remote b/conf/type/__process/gencode-remote index f8da1795..be0e0cae 100755 --- a/conf/type/__process/gencode-remote +++ b/conf/type/__process/gencode-remote @@ -18,8 +18,6 @@ # along with cdist. If not, see . # # -# __file is a very basic type, which will probably be reused quite often -# if [ -f "$__object/parameter/name" ]; then name="$(cat "$__object/parameter/name")" @@ -28,10 +26,10 @@ else fi runs="$(cat "$__object/explorer/runs")" -state="$(cat "$__object/parameter/state")" +state_should="$(cat "$__object/parameter/state")" -case "$state" in - running) +case "$state_should" in + running|present) # Does not run, start it! if [ -z "$runs" ]; then if [ -f "$__object/parameter/start" ]; then @@ -41,7 +39,7 @@ case "$state" in fi fi ;; - stopped) + stopped|absent) # Runs, kill it! if [ "$runs" ]; then if [ -f "$__object/parameter/stop" ]; then @@ -52,7 +50,7 @@ case "$state" in fi ;; *) - echo "Unknown state: $state" >&2 + echo "Unknown state: $state_should" >&2 exit 1 ;;