diff --git a/bin/cdist-explorer-run b/bin/cdist-explorer-run index 5d325d3e..bf738355 100755 --- a/bin/cdist-explorer-run +++ b/bin/cdist-explorer-run @@ -24,7 +24,12 @@ . cdist-config -[ "${__cdist_target_host}" ] || __cdist_usage "Need \$__cdist_target_host setup" +if [ $# -ne 2 ]; then + __cdist_usage " " +fi + +export __cdist_target_host="$1"; shift +export __cdist_output_dir="$1"; shift set -e @@ -52,12 +57,12 @@ ssh root@${__cdist_target_host} \ \"${__cdist_remote_explorer_dir}\" \"${__cdist_remote_cache_explorer}\"" # Ensure local destination directory exists -mkdir -p "$(__cdist_cache_host)/$__cdist_name_explorer" +mkdir -p "$__cdist_output_dir" # 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_cache_host)/$__cdist_name_explorer" + "$__cdist_output_dir" exit 0 diff --git a/bin/cdist-manifest-init b/bin/cdist-manifest-init index 2ab2b758..7e3c0f2b 100755 --- a/bin/cdist-manifest-init +++ b/bin/cdist-manifest-init @@ -24,6 +24,11 @@ . cdist-config -[ "${__cdist_target_host}" ] || __cdist_usage "Need \$__cdist_target_host setup" +if [ $# -ne 2 ]; then + __cdist_usage " " +fi -cdist-manifest-run "$(__cdist_cache_host)" "${__cdist_manifest_init}" +export __cdist_target_host="$1"; shift +export __cdist_output_dir="$1"; shift + +cdist-manifest-run "$__cdist_target_host" "$__cdist_manifest_init" "$__cdist_output_dir" diff --git a/bin/cdist-manifest-run b/bin/cdist-manifest-run index 28123afa..ba9eb9e6 100755 --- a/bin/cdist-manifest-run +++ b/bin/cdist-manifest-run @@ -24,14 +24,16 @@ . cdist-config -if [ $# -ne 2 ]; then - __cdist_usage " " +if [ $# -ne 3 ]; then + __cdist_usage " " fi +set -x set -aeu -__cdist_output_dir="$1"; shift +export __cdist_target_host="$1"; shift export __cdist_manifest="$1"; shift +export __cdist_output_dir="$1"; shift # Ensure binaries exist and are up-to-date cdist-build-bin diff --git a/bin/cdist_tree_wrapper b/bin/cdist_tree_wrapper index 31c49ed7..dde151b5 100755 --- a/bin/cdist_tree_wrapper +++ b/bin/cdist_tree_wrapper @@ -35,14 +35,15 @@ echo "I am $__cdist_myname and have been called with $@" export __cdist_object_id="$1"; shift export __cdist_type_current="$__cdist_myname" -echo "$__cdist_object_id" | grep -q "^${__cdist_sane_regexp}\$" || __cdist_usage "Provide sane id, please" +echo "$__cdist_object_id" | grep -q "^${__cdist_sane_regexp}\$" || \ + __cdist_usage "Insane object id, ${__cdist_object_id}." -__cdist_tid="${__cdist_myname}/${__cdist_object_id}" -__cdist_ddir="$(__cdist_cache_host)/${__cdist_name_object}/${__cdist_tid}" +__cdist_tid="${__cdist_type_current}/${__cdist_object_id}" +__cdist_ddir="$__cdist_output_dir/${__cdist_tid}" if [ -e "${__cdist_ddir}" ]; then - source="$(cat "${__cdist_ddir}/${__cdist_object_source}")" - __cdist_usage "${__cdist_tid} already exists (source: $source)" + source="$(__cdist_object_source "${__cdist_ddir}")" + __cdist_exit_err "${__cdist_tid} already exists (source: $source)" fi mkdir -p "${__cdist_ddir}"