diff --git a/conf/type/__directory/gencode b/conf/type/__directory/gencode index 99a89bd1..6d226aae 100755 --- a/conf/type/__directory/gencode +++ b/conf/type/__directory/gencode @@ -20,28 +20,27 @@ # # Handle directories # +# +# __directory /etc [--mode --owner --group --parents [yes|no] ] +# -# If destination was specified, do not use the id -if [ -f "$__object/parameter/destination" ]; then - destination="$(cat "$__object/parameter/destination")" -else - # If no destination has been supplied, the id is the destination - # Prepend /, which got lost in the object id (and relative paths - # don't make sense) - destination="/$__object_id" -fi - -# Ensure we have an absolute path -if ! $(echo "$destination" | grep -q ^/); then - echo "Error: Destination ($destination) of $__object_id is not absolute." >&2 - exit 1 +destination="/$__object_id" + +# Include parent directories? +if [ -f "$__object/parameter/parents" ]; then + parents="$(cat "$__object/parameter/parents")" + if [ yes = "$parents" ]; then + mkdiropt="-p" + else + mkdiropt="" + fi fi +# Only create if not already existent if [ no = "$(cat "$__object/explorer/exists")" ]; then - echo mkdir \"$destination\" + echo mkdir $mkdiropt \"$destination\" fi - # Mode settings if [ -f "$__object/parameter/mode" ]; then echo chmod \"$(cat "$__object/parameter/mode")\" \"$destination\" diff --git a/conf/type/__directory/man.text b/conf/type/__directory/man.text index c60ada44..a619666d 100644 --- a/conf/type/__directory/man.text +++ b/conf/type/__directory/man.text @@ -1,30 +1,25 @@ -cdist-type__file(7) -=================== +cdist-type__directory(7) +======================== Nico Schottelius NAME ---- -cdist-type__file - Create files +cdist-type__directory - Create a directory DESCRIPTION ----------- -This cdist type allows you to create files on the target. +This cdist type allows you to create directories on the target. REQUIRED PARAMETERS ------------------- -type:: - Specifies the type of file to be created. Either "directory" or "file" +None. OPTIONAL PARAMETERS ------------------- -destination:: - If supplied, use this as the destination on the target. Otherwise the - object_id is used. - group:: Group to chgrp to. @@ -34,9 +29,8 @@ mode:: owner:: User to chown to. -source:: - If supplied, copy this file from the host running cdist to the target. - If not supplied, an empty file or directory will be created. +parents:: + Whether to create parents as well (mkdir -p behaviour) EXAMPLES