From f5eccb2cb181a9384463b0a09412930939b6c96e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 24 Feb 2011 14:24:47 +0100 Subject: [PATCH] introduce new variable names and use __explorers Signed-off-by: Nico Schottelius --- bin/cdist-config | 3 +++ bin/cdist-explorer-run-init | 5 +++-- bin/cdist-manifest-run | 1 + bin/cdist-object-explorer-all | 14 ++++++++++++-- bin/cdist-remote-explorer-run | 18 ++++++++++++++---- conf/explorers/pkg_system | 10 +++++++--- doc/dev/todo/niconext | 1 + 7 files changed, 41 insertions(+), 11 deletions(-) diff --git a/bin/cdist-config b/bin/cdist-config index 2778272e..662f9515 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -39,6 +39,9 @@ set -au : ${__cdist_name_conf_dir:=conf} : ${__cdist_name_type_bin:=type_bin} +# Exported variable names +: ${__cdist_name_var_explorer:=__$__cdist_name_explorer} + # Name of the manifest file in types : ${__cdist_name_manifest:=manifest} diff --git a/bin/cdist-explorer-run-init b/bin/cdist-explorer-run-init index e03c4fea..96049dcd 100755 --- a/bin/cdist-explorer-run-init +++ b/bin/cdist-explorer-run-init @@ -33,8 +33,9 @@ cdist-dir push "$__cdist_target_host" \ "${__cdist_explorer_dir}" "${__cdist_remote_explorer_dir}" # run the initial explorers remotely -cdist-explorer-run "$__cdist_target_host" "$__cdist_remote_base_dir" \ - "$__cdist_remote_explorer_dir" "$__cdist_remote_out_explorer_dir" +cdist-run-remote "${__cdist_target_host}" cdist-remote-explorer-run \ + "$__cdist_remote_base_dir" "$__cdist_remote_explorer_dir" \ + "$__cdist_name_var_explorer" "$__cdist_remote_out_explorer_dir" # retrieve the results cdist-dir pull "$__cdist_target_host" \ diff --git a/bin/cdist-manifest-run b/bin/cdist-manifest-run index 892b3a2f..5ed2c4fe 100755 --- a/bin/cdist-manifest-run +++ b/bin/cdist-manifest-run @@ -45,4 +45,5 @@ fi mkdir -p "${__cdist_output_dir}" || __cdist_exit_err "Cannot create output dir ${__cdist_output_dir}" cd "$__cdist_work_dir" || __cdist_exit_err "Cannot change to work dir \"$__cdist_work_dir\"." + __cdist_exec_fail_on_error "${__cdist_manifest}" "$@" diff --git a/bin/cdist-object-explorer-all b/bin/cdist-object-explorer-all index 45628f4a..f2a8f42d 100755 --- a/bin/cdist-object-explorer-all +++ b/bin/cdist-object-explorer-all @@ -31,22 +31,32 @@ __cdist_object_base_dir="$1"; shift ################################################################################ # New code # +object_listing="$__cdist_tmp_dir/objects" +type_listing_all="$__cdist_tmp_dir/types_all" +type_listing="$__cdist_tmp_dir/types" # Get listing of objects +__cdist_object_list "$__cdist_object_base_dir" > "$__cdist_tmp_file" # Get listing of types used +while read object; do + echo "$(__cdist_type_from_object "$object")" >> "$type_listing_all" +done < "$__cdist_tmp_file" +sort "$type_listing_all" | uniq > "$type_listing" + +cat "$type_listing" # For every type that has explorers, Transfer the explorers # For every object of a type that has explorers, execute the explorers # and retrieve the results +exit 1 + ################################################################################ # Old code # -__cdist_object_list "$__cdist_object_base_dir" > "$__cdist_tmp_file" - # need to create pseudo array, as ssh in cdist-explorer-run will destroy while-read loops while read object; do set -- "$@" "$object" diff --git a/bin/cdist-remote-explorer-run b/bin/cdist-remote-explorer-run index 26708101..6ec0cbed 100755 --- a/bin/cdist-remote-explorer-run +++ b/bin/cdist-remote-explorer-run @@ -19,23 +19,31 @@ # # # 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-config -if [ $# -lt 3 ]; then - __cdist_usage " [explorer args]" +if [ $# -lt 4 ]; then + __cdist_usage " [explorer args]" fi set -ue # cd to this dir __cdist_work_dir="$1"; shift -# find explorers here +# Find explorers here __cdist_explorer_dir="$1"; shift -# write output here +# Variable that defines the home of the explorers +__cdist_variable_name="$1"; shift + +# Write output here __cdist_my_out_dir="$1"; shift +# Setup environment +eval export $__cdist_variable_name=\"$__cdist_explorer_dir\" cd "${__cdist_work_dir}" mkdir -p "$__cdist_my_out_dir" @@ -45,6 +53,8 @@ if [ "$num" -lt 1 ]; then __cdist_exit_err "${__cdist_explorer_dir}: Contains no explorers" fi +# Setup environment for explorer + # Execute all explorers for explorer in "$__cdist_explorer_dir/"*; do explorer_name="${explorer##*/}" diff --git a/conf/explorers/pkg_system b/conf/explorers/pkg_system index d6467631..552209a1 100755 --- a/conf/explorers/pkg_system +++ b/conf/explorers/pkg_system @@ -19,10 +19,14 @@ # # -case "$(./conf/explorers/os)" in +os="$("$__explorers/os")" + +case "$os" in archlinux) echo pacman ;; debian|ubuntu) echo apt ;; gentoo) echo emerge ;; + *) + echo "Unknown OS: $os" >&2 + exit 1 + ;; esac - -exit 0 diff --git a/doc/dev/todo/niconext b/doc/dev/todo/niconext index 1cd5ccdb..6b263955 100644 --- a/doc/dev/todo/niconext +++ b/doc/dev/todo/niconext @@ -1,2 +1,3 @@ add explorers per type/object - change exec directory for all stages + - create cdist-remote-explorer-run that sets