make scripts more variable and less dependent on each other
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
4ee71d5571
commit
425f2bb71a
4 changed files with 26 additions and 13 deletions
|
@ -24,7 +24,12 @@
|
||||||
|
|
||||||
. cdist-config
|
. cdist-config
|
||||||
|
|
||||||
[ "${__cdist_target_host}" ] || __cdist_usage "Need \$__cdist_target_host setup"
|
if [ $# -ne 2 ]; then
|
||||||
|
__cdist_usage "<target host> <outdir>"
|
||||||
|
fi
|
||||||
|
|
||||||
|
export __cdist_target_host="$1"; shift
|
||||||
|
export __cdist_output_dir="$1"; shift
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
@ -52,12 +57,12 @@ ssh root@${__cdist_target_host} \
|
||||||
\"${__cdist_remote_explorer_dir}\" \"${__cdist_remote_cache_explorer}\""
|
\"${__cdist_remote_explorer_dir}\" \"${__cdist_remote_cache_explorer}\""
|
||||||
|
|
||||||
# Ensure local destination directory exists
|
# 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
|
# 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
|
# 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}/*" \
|
scp -r "root@${__cdist_target_host}:${__cdist_remote_cache_explorer}/*" \
|
||||||
"$(__cdist_cache_host)/$__cdist_name_explorer"
|
"$__cdist_output_dir"
|
||||||
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -24,6 +24,11 @@
|
||||||
|
|
||||||
. cdist-config
|
. cdist-config
|
||||||
|
|
||||||
[ "${__cdist_target_host}" ] || __cdist_usage "Need \$__cdist_target_host setup"
|
if [ $# -ne 2 ]; then
|
||||||
|
__cdist_usage "<target host> <outdir>"
|
||||||
|
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"
|
||||||
|
|
|
@ -24,14 +24,16 @@
|
||||||
|
|
||||||
. cdist-config
|
. cdist-config
|
||||||
|
|
||||||
if [ $# -ne 2 ]; then
|
if [ $# -ne 3 ]; then
|
||||||
__cdist_usage "<outdir> <manifest>"
|
__cdist_usage "<target host> <manifest> <outdir>"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
set -x
|
||||||
set -aeu
|
set -aeu
|
||||||
|
|
||||||
__cdist_output_dir="$1"; shift
|
export __cdist_target_host="$1"; shift
|
||||||
export __cdist_manifest="$1"; shift
|
export __cdist_manifest="$1"; shift
|
||||||
|
export __cdist_output_dir="$1"; shift
|
||||||
|
|
||||||
# Ensure binaries exist and are up-to-date
|
# Ensure binaries exist and are up-to-date
|
||||||
cdist-build-bin
|
cdist-build-bin
|
||||||
|
|
|
@ -35,14 +35,15 @@ echo "I am $__cdist_myname and have been called with $@"
|
||||||
export __cdist_object_id="$1"; shift
|
export __cdist_object_id="$1"; shift
|
||||||
export __cdist_type_current="$__cdist_myname"
|
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_tid="${__cdist_type_current}/${__cdist_object_id}"
|
||||||
__cdist_ddir="$(__cdist_cache_host)/${__cdist_name_object}/${__cdist_tid}"
|
__cdist_ddir="$__cdist_output_dir/${__cdist_tid}"
|
||||||
|
|
||||||
if [ -e "${__cdist_ddir}" ]; then
|
if [ -e "${__cdist_ddir}" ]; then
|
||||||
source="$(cat "${__cdist_ddir}/${__cdist_object_source}")"
|
source="$(__cdist_object_source "${__cdist_ddir}")"
|
||||||
__cdist_usage "${__cdist_tid} already exists (source: $source)"
|
__cdist_exit_err "${__cdist_tid} already exists (source: $source)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p "${__cdist_ddir}"
|
mkdir -p "${__cdist_ddir}"
|
||||||
|
|
Loading…
Reference in a new issue