|
|
|
@ -22,8 +22,6 @@ |
|
|
|
|
# example for typewrites later |
|
|
|
|
# |
|
|
|
|
|
|
|
|
|
type="$(cat "$__object/parameter/type")" |
|
|
|
|
|
|
|
|
|
# If destination was specified, do not use the id |
|
|
|
|
if [ -f "$__object/parameter/destination" ]; then |
|
|
|
|
destination="$(cat "$__object/parameter/destination")" |
|
|
|
@ -40,6 +38,7 @@ if ! $(echo "$destination" | grep -q ^/); then |
|
|
|
|
exit 1 |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
# Use correct md5sum binary - MacOSx is different here |
|
|
|
|
case "$os" in |
|
|
|
|
macosx) |
|
|
|
|
md5sum="md5" |
|
|
|
@ -50,45 +49,62 @@ case "$os" in |
|
|
|
|
;; |
|
|
|
|
esac |
|
|
|
|
|
|
|
|
|
# Copy source if existing |
|
|
|
|
# FIXME: directory handling not supported - add recursive flag? |
|
|
|
|
if [ -f "$__object/parameter/source" ]; then |
|
|
|
|
source="$(cat "$__object/parameter/source")" |
|
|
|
|
|
|
|
|
|
if [ -f "$source" ]; then |
|
|
|
|
local_md5sum="$($md5sum < "$source")" |
|
|
|
|
remote_md5sum="$(cat "$__object/explorer/md5sum")" |
|
|
|
|
type="$(cat "$__object/parameter/type")" |
|
|
|
|
|
|
|
|
|
# Is md5sum the right approach? |
|
|
|
|
if [ "$local_md5sum" != "$remote_md5sum" ]; then |
|
|
|
|
# FIXME: This is ugly and hardcoded, replace after 1.0! |
|
|
|
|
# Probably a better aproach is to have the user configured |
|
|
|
|
# ~/.ssh/config to contain the right username |
|
|
|
|
# Probably describe it in cdist-quickstart... |
|
|
|
|
scp "$source" "root@${__target_host}:${destination}" |
|
|
|
|
fi |
|
|
|
|
fi |
|
|
|
|
# No source? Create empty file/dir |
|
|
|
|
else |
|
|
|
|
# Only touch / create if it does not exist |
|
|
|
|
if [ no = "$(cat "$__object/explorer/exists")" ]; then |
|
|
|
|
case "$type" in |
|
|
|
|
directory) |
|
|
|
|
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")" |
|
|
|
|
|
|
|
|
|
file) |
|
|
|
|
if [ -f "$source" ]; then |
|
|
|
|
local_md5sum="$($md5sum < "$source")" |
|
|
|
|
remote_md5sum="$(cat "$__object/explorer/md5sum")" |
|
|
|
|
|
|
|
|
|
# FIXME: Is md5sum the right approach? |
|
|
|
|
if [ "$local_md5sum" != "$remote_md5sum" ]; then |
|
|
|
|
# FIXME: This is ugly and hardcoded, replace after 1.0! |
|
|
|
|
# Probably a better aproach is to have the user configured |
|
|
|
|
# ~/.ssh/config to contain the right username |
|
|
|
|
# Probably describe it in cdist-quickstart... |
|
|
|
|
scp "$source" "root@${__target_host}:${destination}" |
|
|
|
|
fi |
|
|
|
|
fi |
|
|
|
|
else |
|
|
|
|
if [ no = "$(cat "$__object/explorer/exists")" ]; then |
|
|
|
|
echo touch \"$destination\" |
|
|
|
|
;; |
|
|
|
|
fi |
|
|
|
|
fi |
|
|
|
|
;; |
|
|
|
|
|
|
|
|
|
*) |
|
|
|
|
echo "Unsupported type: \"$type\"" >&2 |
|
|
|
|
exit 1 |
|
|
|
|
;; |
|
|
|
|
esac |
|
|
|
|
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 |
|
|
|
|
mode="$(cat "$__object/parameters/mode")" |
|
|
|
|
echo chmod \"$mode\" \"$destination\" |
|
|
|
|