From bd39d5c185c9d23a78da8ae64f41d6d83e78959f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 9 Aug 2011 17:23:05 +0200 Subject: [PATCH] finish __cdist_run_if_executable Signed-off-by: Nico Schottelius --- core/__cdist_run_if_executable | 46 ++++++++-------------------------- 1 file changed, 11 insertions(+), 35 deletions(-) diff --git a/core/__cdist_run_if_executable b/core/__cdist_run_if_executable index d8c63d0d..86732742 100755 --- a/core/__cdist_run_if_executable +++ b/core/__cdist_run_if_executable @@ -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 " " - # 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 " " - - __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