|
|
|
@ -18,74 +18,21 @@ |
|
|
|
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>. |
|
|
|
|
# |
|
|
|
|
# |
|
|
|
|
# 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 "<target host> <outdir>" |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
export __cdist_target_host="$1"; shift |
|
|
|
|
export __cdist_output_dir="$1"; shift |
|
|
|
|
|
|
|
|
|
[ $# -eq 2 ] || __cdist_usage "<target host> <exec_dir>" |
|
|
|
|
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) |
|
|
|
|
|
|
|
|
|
# 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}" |
|
|
|
|
export __cdist_target_host="$1"; shift |
|
|
|
|
export __cdist_exec_dir="$1"; shift |
|
|
|
|
|
|
|
|
|
# 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" |
|
|
|
|
# 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 |
|
|
|
|
# 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}" |
|
|
|
|