diff --git a/bin/cdist-remote-explorer-run b/bin/cdist-remote-explorer-run index d95913ba..040e36a2 100755 --- a/bin/cdist-remote-explorer-run +++ b/bin/cdist-remote-explorer-run @@ -24,45 +24,50 @@ # and __type_explorers can be submitted :-) # -. cdist-config -[ $# -eq 3 ] || __cdist_usage " " -set -ue +# FIXME: cleanup! +__cdist_remote_explorer_run() +{ + [ $# -eq 3 ] || __cdist_usage " " + set -ue -# Variable that defines the home of the explorers -__cdist_variable_name="$1"; shift + "$__cdist_name_var_object=\"$(__cdist_remote_object_dir "$__cdist_object_self")\"" -# Find explorers here -__cdist_explorer_dir="$1"; shift + # Variable that defines the home of the explorers + __cdist_variable_name="$1"; shift -# Write output here -__cdist_my_out_dir="$1"; shift + # Find explorers here + __cdist_explorer_dir="$1"; shift -# Setup environment -export $__cdist_variable_name="$__cdist_explorer_dir" -export __global="$__cdist_remote_out_dir" + # Write output here + __cdist_my_out_dir="$1"; shift -mkdir -p "$__cdist_my_out_dir" + # Setup environment + export $__cdist_variable_name="$__cdist_explorer_dir" + export __global="$__cdist_remote_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 + mkdir -p "$__cdist_my_out_dir" -# 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 + # 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 -done + + # 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 +} diff --git a/core/__cdist_code_run b/core/__cdist_code_run index 6a1b916b..ca73b02d 100755 --- a/core/__cdist_code_run +++ b/core/__cdist_code_run @@ -23,7 +23,6 @@ __cdist_code_run() { - [ $# -eq 2 ] || __cdist_usage " " __cdist_object_self="$1"; shift @@ -49,4 +48,7 @@ __cdist_code_run() __cdist_exit_err "$__cdist_code exists, but is not a file." fi fi + + # Exit gracefully if nothing is todo + true } diff --git a/core/__cdist_object_gencode b/core/__cdist_object_gencode index 585c9d9d..1024f2c5 100755 --- a/core/__cdist_object_gencode +++ b/core/__cdist_object_gencode @@ -28,7 +28,6 @@ __cdist_object_gencode() { - __cdist_myname="foo" [ $# -eq 2 ] || __cdist_usage "" "" __cdist_object_self="$1"; shift diff --git a/core/__cdist_object_run b/core/__cdist_object_run index 07461b23..7f08f192 100755 --- a/core/__cdist_object_run +++ b/core/__cdist_object_run @@ -38,6 +38,8 @@ __cdist_object_run() # Export to non-core for use in manifest and gencode scripts export $__cdist_name_var_self=$__cdist_object_self + # FIXME: BUG: should be named differently! + # FIXME: BUG: I can be called recursively! -> variables are probably already set / overwritten! __cdist_object_finished="$(__cdist_object_finished "$__cdist_object_self")" if [ ! -f "$__cdist_object_finished" ]; then # Resolve dependencies, if any @@ -52,9 +54,12 @@ __cdist_object_run() __cdist_requirement="$1"; shift __cdist_echo info "Resolving requirement $__cdist_requirement" __cdist_object_run "$__cdist_requirement" + echo "done run" done fi + echo "after done" + __cdist_object_gencode_run "$__cdist_object_self" __cdist_dir push "$(__cdist_object_dir "$__cdist_object_self")" \ "$(__cdist_remote_object_dir "$__cdist_object_self")"