From 6d3053a9bc855e3c2413093a8af08ec3ff583422 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 27 Jul 2011 01:22:54 +0200 Subject: [PATCH] fix type explorer: working again Signed-off-by: Nico Schottelius --- bin/cdist-deploy-to | 2 +- core/__cdist_object_explorer_run | 40 +++++++++++++++---- core/__cdist_remote_explorer_run | 67 -------------------------------- 3 files changed, 33 insertions(+), 76 deletions(-) delete mode 100755 core/__cdist_remote_explorer_run diff --git a/bin/cdist-deploy-to b/bin/cdist-deploy-to index 67bc4ba0..781c15c4 100755 --- a/bin/cdist-deploy-to +++ b/bin/cdist-deploy-to @@ -54,9 +54,9 @@ __cdist_dir push "${__cdist_core_dir}" "${__cdist_remote_core_dir}" __cdist_explorer_run_global __cdist_manifest_run_init +__cdist_object_all __cdist_object_prepare exit 1 -__cdist_object_all __cdist_object_prepare __cdist_object_all __cdist_object_run __cdist_cache diff --git a/core/__cdist_object_explorer_run b/core/__cdist_object_explorer_run index 45ca3379..1f266dca 100755 --- a/core/__cdist_object_explorer_run +++ b/core/__cdist_object_explorer_run @@ -22,6 +22,8 @@ # Run the explorers for the given object on the target host. # +# FIXME: many cleanups needed before going production! + __cdist_object_explorer_run() { __cdist_object_self="$1"; shift @@ -49,14 +51,36 @@ __cdist_object_explorer_run() "$(__cdist_remote_object_parameter_dir "$__cdist_object_self")" # Execute explorers - __cdist_run_remote \ - "$__cdist_name_var_object=\"$(__cdist_remote_object_dir "$__cdist_object_self")\"" \ - "$__cdist_name_var_object_id=\"$__cdist_object_id\"" \ - "$__cdist_name_var_self=\"$__cdist_object_self\"" \ - cdist-remote-explorer-run \ - "$__cdist_name_var_type_explorer" \ - "$(__cdist_remote_type_explorer_dir "$__cdist_type")" \ - "$(__cdist_remote_object_type_explorer_dir "$__cdist_object_self")" + # FIXME: STOPPED: + # - remove cdist-remote-explorer-run + # - problem: new variables / need to run explorer directly? + # -> or put logic into __cdist_explorer_run + # -> think about having _one_ wrapper script for remote to execute + # shell functions + + # Create remote output directory + __cdist_run_remote mkdir -p "$(__cdist_remote_object_type_explorer_dir "$__cdist_object_self")" + + cd "$(__cdist_type_explorer_dir "$__cdist_type")" + + + for __cdist_object_explorer_run_explorer in *; do + __cdist_run_remote \ + "$__cdist_name_var_object=\"$(__cdist_remote_object_dir "$__cdist_object_self")\"" \ + "$__cdist_name_var_object_id=\"$__cdist_object_id\"" \ + "$__cdist_name_var_self=\"$__cdist_object_self\"" \ + "$(__cdist_remote_type_explorer_dir "$__cdist_type")/$__cdist_object_explorer_run_explorer" \ + ">" "$(__cdist_remote_object_type_explorer_dir "$__cdist_object_self")/$__cdist_object_explorer_run_explorer" + done + +# __cdist_run_remote \ +# "$__cdist_name_var_object=\"$(__cdist_remote_object_dir "$__cdist_object_self")\"" \ +# "$__cdist_name_var_object_id=\"$__cdist_object_id\"" \ +# "$__cdist_name_var_self=\"$__cdist_object_self\"" \ +# cdist-remote-explorer-run \ +# "$__cdist_name_var_type_explorer" \ +# "$(__cdist_remote_type_explorer_dir "$__cdist_type")" \ +# "$(__cdist_remote_object_type_explorer_dir "$__cdist_object_self")" # Copy back results __cdist_dir pull "$(__cdist_remote_object_type_explorer_dir "$__cdist_object_self")" \ diff --git a/core/__cdist_remote_explorer_run b/core/__cdist_remote_explorer_run deleted file mode 100755 index 2fc0f999..00000000 --- a/core/__cdist_remote_explorer_run +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh -# -# 2011 Nico Schottelius (nico-cdist at schottelius.org) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# -# This binary is executed on the remote side to execute explorers -# -# It supports different variables names to be used, so __explorers -# and __type_explorers can be submitted :-) -# - -__cdist_remote_explorer_run() -{ - [ $# -eq 3 ] || __cdist_usage " " - - "$__cdist_name_var_object=\"$(__cdist_remote_object_dir "$__cdist_object_self")\"" - - # Variable that defines the home of the explorers - __cdist_variable_name="$1"; shift - - # Find explorers here - __cdist_explorer_dir="$1"; shift - - # Write output here - __cdist_my_out_dir="$1"; shift - - mkdir -p "$__cdist_my_out_dir" - - # Ensure there is at least one explorer - num="$(ls -1 "$__cdist_explorer_dir" | wc -l)" - if [ "$num" -lt 1 ]; then - __cdist_exit_err "${__cdist_explorer_dir}: Contains no explorers" - fi - - # Execute all explorers - for explorer in "$__cdist_explorer_dir/"*; do - explorer_name="${explorer##*/}" - - if [ -f "$explorer" ]; then - if [ ! -x "$explorer" ]; then - __cdist_exit_err "Explorer \"$explorer\" exists, but is not executable." - fi - - # Execute explorers and save results in remote destination directory - "$explorer" > "${__cdist_my_out_dir}/$explorer_name" - else - if [ -e "$explorer" ]; then - __cdist_exit_err "Explorer \"$explorer\" exists, but is not a file." - fi - fi - done -}