From 16f51ca14d68ccaa0a299e9b70f2b37c7d9454e8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 4 Feb 2011 22:39:26 +0100 Subject: [PATCH] Finish ugly explorer integration Signed-off-by: Nico Schottelius --- bin/cdist-config | 10 ++++++---- bin/cdist-deploy-to | 4 ++-- bin/cdist-explorer-run | 19 ++++++++++++++----- conf/explorers/os | 3 +++ conf/explorers/pkg_system | 4 +++- 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/bin/cdist-config b/bin/cdist-config index 4a7506ab..ff71ec80 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -37,10 +37,12 @@ # Paths used on the target - must be kind of secure.... : ${__cdist_remote_base_dir:=/var/lib/cdist} -: ${__cdist_remote_explorer_dir:=$__cdist_remote_base/explorers} -: ${__cdist_remote_cache_dir:=$__cdist_remote_base/cache} -: ${__cdist_remote_cache_explorer:=$__cdist_remote_base/cache} -: ${__cdist_remote_cache_bin:=$__cdist_remote_base/bin} +: ${__cdist_remote_explorer_dir:=$__cdist_remote_base_dir/explorers} +export __cdist_remote_explorer_dir +: ${__cdist_remote_cache_dir:=$__cdist_remote_base_dir/cache} +: ${__cdist_remote_cache_explorer:=$__cdist_remote_cache_dir/explorers} +export __cdist_remote_cache_explorer +: ${__cdist_remote_cache_bin:=$__cdist_remote_base_dir/bin} # create basedir + tempfile for direct usage # FIXME: remove on exit diff --git a/bin/cdist-deploy-to b/bin/cdist-deploy-to index 02e0a3a0..7d766abd 100755 --- a/bin/cdist-deploy-to +++ b/bin/cdist-deploy-to @@ -31,5 +31,5 @@ set -e export __cdist_target_host="$1" export __cdist_source_host="$(cdist_explore_hostname)" -. cdist-build "$__cdist_intern_target_host" -. cdist-remote-exec "$__cdist_intern_target_host" +. cdist-build "$__cdist_target_host" +. cdist-remote-exec "$__cdist_target_host" diff --git a/bin/cdist-explorer-run b/bin/cdist-explorer-run index 49e79de0..b1b50dd6 100755 --- a/bin/cdist-explorer-run +++ b/bin/cdist-explorer-run @@ -21,25 +21,34 @@ . cdist-config +[ "${__cdist_target_host}" ] || __cdist_usage "Need \$__cdist_target_host setup" + 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}\"" + # 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) scp -r "${__cdist_explorer_dir}" \ - "root@${__cdist_target_host}:${__cdist_remote_cache_dir}" + "root@${__cdist_target_host}:${__cdist_remote_base_dir}" -# Transfer explorer coordinator -scp "$(which cdist-explorer-coordinator)" \ +# 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} "\"${__cdist_remote_cache_bin}/cdist-explorer-coordinator\" \ +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}\"" # Transfer back all results -scp -r "root@${__cdist_target_host}:${__cdist_remote_dir}" +# scp -r "root@${__cdist_target_host}:${__cdist_remote_dir}" exit 0 diff --git a/conf/explorers/os b/conf/explorers/os index c7ccae01..3bd3f2ef 100755 --- a/conf/explorers/os +++ b/conf/explorers/os @@ -33,3 +33,6 @@ fi [ -f /etc/debian_version ] && echo debian [ -f /etc/redhat-release ] && echo redhat + +# ensure correct exit, otherwise other explorer won't get started +exit 0 diff --git a/conf/explorers/pkg_system b/conf/explorers/pkg_system index 14f717ee..d9da3f1e 100755 --- a/conf/explorers/pkg_system +++ b/conf/explorers/pkg_system @@ -19,7 +19,9 @@ # # -case "$(__cdist_explorer_dir/os)" in +case "$("${__cdist_remote_explorer_dir}/os")" in archlinux) echo pacman ;; debian|ubuntu) echo apt ;; esac + +exit 0