finish __cdist_run_if_executable

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-08-09 17:23:05 +02:00
parent f6d7a3e478
commit bd39d5c185

View file

@ -1,7 +1,6 @@
#!/bin/sh
#
# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org)
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@ -22,45 +21,22 @@
# Exec the code for the given object locally and remote
#
__cdist_object_code_run()
__cdist_run_if_executable()
{
set -x
__cdist_object_code_run_object="$1"; shift
[ $# -gt 1 ] || __cdist_exit_err "<executable> <command> <args>"
# Code local
export __cdist_out_object_dir="$__cdist_out_object_dir"
__cdist_code_run "$__cdist_object_code_run_object" "${__cdist_name_gencode_local}"
__cdist_run_if_executable_exec="$1"; shift
# Code remote
#__cdist_run_remote "__cdist_code_run" \
# "$__cdist_object_code_run_object" "${__cdist_name_gencode_remote}"
__cdist_run_remote "echo" "__cdist_code_run" \
"$__cdist_object_code_run_object" "${__cdist_name_gencode_remote}; exit 1"
# [ $# -eq 2 ] || __cdist_usage "<object> <type>"
__cdist_object_code_run_object="$1"; shift
__cdist_code_type="$1"; shift
if [ ! -d "$(__cdist_object_dir "$__cdist_object_code_run_object")" ]; then
__cdist_exit_err "Object undefined"
fi
__cdist_code="$(__cdist_object_code "$__cdist_object_code_run_object" "${__cdist_code_type}")"
__cdist_echo info "Checking code-${__cdist_code_type}"
if [ -e "$__cdist_code" ]; then
if [ -f "$__cdist_code" ]; then
if [ -x "$__cdist_code" ]; then
__cdist_echo info "Executing code-${__cdist_code_type}"
__cdist_run_shell "$__cdist_code"
if [ -e "$__cdist_run_if_executable_exec" ]; then
if [ -f "$__cdist_run_if_executable_exec" ]; then
if [ -x "$__cdist_run_if_executable_exec" ]; then
__cdist_echo debug "Running $@ ..."
"$@"
else
__cdist_exit_err "$__cdist_code exists, but is not executable."
__cdist_exit_err "$__cdist_run_if_executable_exec exists, but is not executable."
fi
else
__cdist_exit_err "$__cdist_code exists, but is not a file."
__cdist_exit_err "$__cdist_run_if_executable_exec exists, but is not a file."
fi
fi