diff --git a/bin/cdist-explorer-run b/bin/cdist-explorer-run index fcbe2518..494c8c42 100755 --- a/bin/cdist-explorer-run +++ b/bin/cdist-explorer-run @@ -23,25 +23,44 @@ # . cdist-config -[ $# -eq 2 ] || __cdist_usage " " +if [ $# -ne 5 ]; then + __cdist_usage " " +fi set -ue 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 -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 # coyping it multiple times works: a -> remote:/base/ = remote:/base/a vs. # 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! scp "$(which cdist-explorer-coordinator)" "$(which cdist-config)" \ "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}\"" # 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 # 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}/*" \ - "$__cdist_output_dir" + "$__cdist_local_dst_dir" exit 0 @@ -68,7 +87,7 @@ exit 0 # Keep until above version successfully works -cd "${__cdist_explorer_dir}" +cd "${__cdist_src_dir}" ls > "${__cdist_tmp_file}" # first load all functions diff --git a/bin/cdist-explorer-run-global b/bin/cdist-explorer-run-global index e2bb7f41..e4dc8cd1 100755 --- a/bin/cdist-explorer-run-global +++ b/bin/cdist-explorer-run-global @@ -28,6 +28,7 @@ set -ue export __cdist_target_host="$1"; shift export __cdist_output_dir="$1"; shift + # create basedir ssh root@${__cdist_target_host} "mkdir -p \"${__cdist_remote_base_dir}\" \ \"${__cdist_remote_cache_dir}\" \"${__cdist_remote_cache_bin}\" \