Revert "Revert "begin to create a general cdist-explorer-run""

Revert the reverts - now we're in the feature branch.

This reverts commit c14df05fbe.
This commit is contained in:
Nico Schottelius 2011-02-22 23:10:38 +01:00
parent d72c5e1f69
commit a0fd43d0a8
2 changed files with 33 additions and 13 deletions

View File

@ -23,25 +23,44 @@
# #
. cdist-config . cdist-config
[ $# -eq 2 ] || __cdist_usage "<target host> <outdir>" if [ $# -ne 5 ]; then
__cdist_usage "<target host> <local srcdir> <local dstdir> <remote srcdir> <remote dstdir>"
fi
set -ue set -ue
export __cdist_target_host="$1"; shift export __cdist_target_host="$1"; shift
export __cdist_output_dir="$1"; shift
export __cdist_local_src_dir="$1"; shift
export __cdist_local_dst_dir="$1"; shift
export __cdist_remote_src_dir="$1"; shift
export __cdist_remote_dst_dir="$1"; shift
################################################################################
# New code
#
# Create remote source and destination directory
ssh "${__cdist_remote_user}@${__cdist_target_host}" \
"mkdir -p \"${__cdist_remote_src_dir}\" \
\"${__cdist_remote_dst_dir}\""
# Copy explorers to remote source directory
# FIXME: enable -q as soon as the code is cleaned up
scp "${__cdist_src_dir}"/* \
"${__cdist_remote_user}@${__cdist_target_host}:${__cdist_remote_src_dir}"
# Execute explorers and save results in remote destination directory
# Copy results back to us
################################################################################
# Old code
#
# create basedir # create basedir
ssh root@${__cdist_target_host} "mkdir -p \"${__cdist_remote_base_dir}\" \
\"${__cdist_remote_cache_dir}\" \"${__cdist_remote_cache_bin}\" \
\"${__cdist_remote_cache_explorer}\""
# Transfer all explorers to the target dir - must be one level above, so # Transfer all explorers to the target dir - must be one level above, so
# coyping it multiple times works: a -> remote:/base/ = remote:/base/a vs. # coyping it multiple times works: a -> remote:/base/ = remote:/base/a vs.
# a -> remote:/base/a = remote:/base/a/a (second copy) # a -> remote:/base/a = remote:/base/a/a (second copy)
# FIXME: enable -q as soon as the code is cleaned up
scp -r "${__cdist_explorer_dir}" \
"root@${__cdist_target_host}:${__cdist_remote_base_dir}"
# Transfer cdist binaries - FIXME: should transfer all (needed?) of them! # Transfer cdist binaries - FIXME: should transfer all (needed?) of them!
scp "$(which cdist-explorer-coordinator)" "$(which cdist-config)" \ scp "$(which cdist-explorer-coordinator)" "$(which cdist-config)" \
"root@${__cdist_target_host}:${__cdist_remote_cache_bin}" "root@${__cdist_target_host}:${__cdist_remote_cache_bin}"
@ -53,12 +72,12 @@ ssh root@${__cdist_target_host} \
\"${__cdist_remote_explorer_dir}\" \"${__cdist_remote_cache_explorer}\"" \"${__cdist_remote_explorer_dir}\" \"${__cdist_remote_cache_explorer}\""
# Ensure local destination directory exists # Ensure local destination directory exists
mkdir -p "$__cdist_output_dir" mkdir -p "$__cdist_local_dst_dir"
# FIXME: enable -q as soon as the code is cleaned up # FIXME: enable -q as soon as the code is cleaned up
# Transfer back all results - FIXME: Add 2 level cache, so old version is kept until success # Transfer back all results - FIXME: Add 2 level cache, so old version is kept until success
scp -r "root@${__cdist_target_host}:${__cdist_remote_cache_explorer}/*" \ scp -r "root@${__cdist_target_host}:${__cdist_remote_cache_explorer}/*" \
"$__cdist_output_dir" "$__cdist_local_dst_dir"
exit 0 exit 0
@ -68,7 +87,7 @@ exit 0
# Keep until above version successfully works # Keep until above version successfully works
cd "${__cdist_explorer_dir}" cd "${__cdist_src_dir}"
ls > "${__cdist_tmp_file}" ls > "${__cdist_tmp_file}"
# first load all functions # first load all functions

View File

@ -28,6 +28,7 @@ set -ue
export __cdist_target_host="$1"; shift export __cdist_target_host="$1"; shift
export __cdist_output_dir="$1"; shift export __cdist_output_dir="$1"; shift
# create basedir # create basedir
ssh root@${__cdist_target_host} "mkdir -p \"${__cdist_remote_base_dir}\" \ ssh root@${__cdist_target_host} "mkdir -p \"${__cdist_remote_base_dir}\" \
\"${__cdist_remote_cache_dir}\" \"${__cdist_remote_cache_bin}\" \ \"${__cdist_remote_cache_dir}\" \"${__cdist_remote_cache_bin}\" \