begin to cleanup __file

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-03-15 21:18:15 +01:00
parent 1619964cbb
commit e06e8026dd
2 changed files with 27 additions and 73 deletions

View file

@ -18,27 +18,13 @@
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
#
# __file is a very basic type and should be able to be used as an
# example for typewrites later
# __file is a very basic type, which will probably be reused quite often
#
# 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
fi
# Use correct md5sum binary - MacOSx is different here
# FIXME: broken: we don't know the host os!
case "$os" in
macosx)
md5sum="md5"
@ -49,21 +35,6 @@ case "$os" in
;;
esac
type="$(cat "$__object/parameter/type")"
case "$type" in
directory)
if [ -f "$__object/parameter/source" ]; then
echo "Source not supported for directory currently - FIXME" >&2
exit 1
else
if [ no = "$(cat "$__object/explorer/exists")" ]; then
echo mkdir \"$destination\"
fi
fi
;;
file)
if [ -f "$__object/parameter/source" ]; then
source="$(cat "$__object/parameter/source")"
@ -88,24 +59,7 @@ case "$type" in
echo touch \"$destination\"
fi
fi
;;
symlink)
if [ ! -f "$__object/parameter/source" ]; then
echo "Source required for symlink" >&2
exit 1
fi
source="$(cat "$__object/parameter/source")"
# FIXME: handle directories or document & ignore?
echo ln -sf \"$source\" \"$destination\"
;;
*)
echo "Unsupported type: \"$type\"" >&2
exit 1
;;
esac
# Mode settings
if [ -f "$__object/parameter/mode" ]; then

View file

@ -1,7 +1,7 @@
Proposal for new types, which replace __file:
__directory /etc [--mode --owner --group --parents [yes|no] ]
x __directory /etc [--mode --owner --group --parents [yes|no] ]
__link /destination --source abc --type [symbolic|hard]
x __link /destination --source abc --type [symbolic|hard]
__file /etc/passwd [--source] --mode --owner --group