From 255124b8c99433c84677bcb1928dde9dc9a6c79c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 17 Feb 2011 15:11:41 +0100 Subject: [PATCH] Create, finish and integrate bin/cdist-exec-transfer Signed-off-by: Nico Schottelius --- HACKERS_README | 3 ++ bin/cdist-config | 1 + bin/cdist-deploy-to | 4 ++- bin/cdist-exec-transfer | 71 ++++++----------------------------------- 4 files changed, 16 insertions(+), 63 deletions(-) diff --git a/HACKERS_README b/HACKERS_README index a5b1d23a..7d6aafdf 100755 --- a/HACKERS_README +++ b/HACKERS_README @@ -52,3 +52,6 @@ cdist-object-codegen-all localhost "$object_tmp" "$exec_tmp" # Display result find "$exec_tmp" + +# Transfer generated code +cdist-exec-transfer localhost "$exec_tmp" diff --git a/bin/cdist-config b/bin/cdist-config index 68df3d4b..8542d23f 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -77,6 +77,7 @@ export __cdist_remote_explorer_dir : ${__cdist_remote_cache_explorer:=$__cdist_remote_cache_dir/$__cdist_name_explorer} export __cdist_remote_cache_explorer : ${__cdist_remote_cache_bin:=$__cdist_remote_base_dir/$__cdist_name_bin} +: ${__cdist_remote_cache_exec:=$__cdist_remote_base_dir/$__cdist_name_exec} # Tempfiles need to be recreated for each individual script, unshared! __cdist_tmp_dir=$(mktemp -d "/tmp/cdist.XXXXXXXXXXXX") diff --git a/bin/cdist-deploy-to b/bin/cdist-deploy-to index 1e9bd85c..4fa31bfe 100755 --- a/bin/cdist-deploy-to +++ b/bin/cdist-deploy-to @@ -38,10 +38,12 @@ cdist-explorer-run "$__cdist_target_host" "$tmp_exp" cdist-manifest-init "$__cdist_target_host" "$tmp_obj" cdist-manifest-run-all "$__cdist_target_host" "$tmp_obj" cdist-object-codegen-all "$__cdist_target_host" "$tmp_obj" "$tmp_exec" +cdist-object-codegen-all "$__cdist_target_host" "$tmp_obj" "$tmp_exec" exit 1 -cdist-target-exec "$__cdist_target_host" "$tmp_code" +cdist-exec-transfer "$__cdist_target_host" "$tmp_exec" +cdist-exec-run "$__cdist_target_host" "$tmp_exec" # Create new cache - put into seperate script? # cdist-cache migrate? diff --git a/bin/cdist-exec-transfer b/bin/cdist-exec-transfer index bf738355..d1ba128d 100755 --- a/bin/cdist-exec-transfer +++ b/bin/cdist-exec-transfer @@ -18,74 +18,21 @@ # along with cdist. If not, see . # # -# FIXME: This script is ugly, should be either seperated into smaller ones, -# but definitely be cleaned up - PROOF OF CONCEPT CODE +# Transfer executables # . cdist-config -if [ $# -ne 2 ]; then - __cdist_usage " " -fi - -export __cdist_target_host="$1"; shift -export __cdist_output_dir="$1"; shift - +[ $# -eq 2 ] || __cdist_usage " " set -e -# 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}\"" +export __cdist_target_host="$1"; shift +export __cdist_exec_dir="$1"; shift -# 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) + +# re-create basedir so it's clean +ssh "root@${__cdist_target_host}" "rm -rf \"${__cdist_remote_cache_exec}\" && mkdir -p \"${__cdist_remote_cache_exec}\"" # 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}" - -# Execute explorer coordinator, which will save results on target -ssh root@${__cdist_target_host} \ - "PATH=\"${__cdist_remote_cache_bin}:\$PATH\" - \"${__cdist_remote_cache_bin}/cdist-explorer-coordinator\" \ - \"${__cdist_remote_explorer_dir}\" \"${__cdist_remote_cache_explorer}\"" - -# Ensure local destination directory exists -mkdir -p "$__cdist_output_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" - - -exit 0 - -# -------------------------------------------------------------------------------- -# old idea with shell scripts (also sexy) -# Keep until above version successfully works - - -cd "${__cdist_explorer_dir}" -ls > "${__cdist_tmp_file}" - -# first load all functions -while read funcfull; do - cat "${funcfull}" -done < "${__cdist_tmp_file}" - -# then execute functions -while read funcfull; do - sh="${funcfull##*/}" - func="${sh%.sh}" - var="__$func" - - echo "$var=\"\$($func)\"" - echo "echo $var=\\\"\$$var\\\"" -done < "${CDIST_TMP}" +scp -r "${__cdist_exec_dir}"/* \ + "root@${__cdist_target_host}:${__cdist_remote_cache_exec}"