diff --git a/conf/type/__file/gencode-remote b/conf/type/__file/gencode-remote index ef42dd54..aedae218 100755 --- a/conf/type/__file/gencode-remote +++ b/conf/type/__file/gencode-remote @@ -25,30 +25,42 @@ destination="/$__object_id" state_should="$(cat "$__object/parameter/state")" exists="$(cat "$__object/explorer/exists")" -if [ "$state_should" = "present" ]; then - # No source? Create empty file - if [ ! -f "$__object/parameter/source" ]; then - if [ "$exists" = "no" ]; then - echo touch \"$destination\" +case "$state_should" in + present) + # No source? Create empty file + if [ ! -f "$__object/parameter/source" ]; then + if [ "$exists" = "no" ]; then + echo touch \"$destination\" + fi fi - fi - - # Mode settings - if [ -f "$__object/parameter/mode" ]; then - echo chmod \"$(cat "$__object/parameter/mode")\" \"$destination\" - fi - - # Group - if [ -f "$__object/parameter/group" ]; then - echo chgrp \"$(cat "$__object/parameter/group")\" \"$destination\" - fi - - # Owner - if [ -f "$__object/parameter/owner" ]; then - echo chown \"$(cat "$__object/parameter/owner")\" \"$destination\" - fi -elif [ "$state_should" = "absent" ]; then - if [ "$exists" = "yes" ]; then - echo rm -f \"$destination\" - fi -fi + + # Mode settings + if [ -f "$__object/parameter/mode" ]; then + echo chmod \"$(cat "$__object/parameter/mode")\" \"$destination\" + fi + + # Group + if [ -f "$__object/parameter/group" ]; then + echo chgrp \"$(cat "$__object/parameter/group")\" \"$destination\" + fi + + # Owner + if [ -f "$__object/parameter/owner" ]; then + echo chown \"$(cat "$__object/parameter/owner")\" \"$destination\" + fi + ;; + + absent) + + if [ "$exists" = "yes" ]; then + echo rm -f \"$destination\" + fi + + ;; + + *) + echo "Unknown state: $state_should" >&2 + exit 1 + ;; + +esac