finish cdist-code-gen

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-02-16 19:43:11 +01:00
parent 709271fd2e
commit e4fbb1a5d8
1 changed files with 21 additions and 6 deletions

View File

@ -23,21 +23,36 @@
. cdist-config
[ $# -eq 2 ] || __cdist_usage "<target host>" "<object>"
[ $# -eq 3 ] || __cdist_usage "<target host>" "<object_base_dir>" "<object>"
set -ue
export __cdist_target_host="$1"; shift
export __cdist_object_base_dir="$1"; shift
export __cdist_object="$1"; shift
# Full path to object
export __cdist_object_dir="${__cdist_object_base_dir}/${__cdist_object}"
# Get type from object path
export __cdist_type=${__cdist_object%%/*}
export __cdist_type="${__cdist_object%%/*}"
# Full path to where the executable should exist, if the type has one
export __cdist_gencode="${__cdist_type_dir}/$__cdist_type/$__cdist_name_gencode"
# Get id from object path (i.e no type prefix)
export __cdist_object_id="${__cdist_object#*/}"
# Full path to where the executable of the type should exist, if the type has one
gencode="$(__cdist_type_gencode "$__cdist_type")"
cd "$__cdist_object_dir"
# Call gencode of type with __cdist_object
if [ -x "$__cdist_gencode" ]; then
"$__cdist_gencode"
if [ -x "$gencode" ]; then
cat << eof
#
# Code imported from $gencode
#
eof
"$gencode"
fi