From 45a072024ce3d6214901949670dc94a276bd4d98 Mon Sep 17 00:00:00 2001 From: Lukas Macura Date: Fri, 15 Apr 2016 11:18:46 +0200 Subject: [PATCH] Repaired ctrl functions (from trunk) --- lib/ctrl.lib.sh | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/ctrl.lib.sh b/lib/ctrl.lib.sh index e5ee3f6..8386ba6 100644 --- a/lib/ctrl.lib.sh +++ b/lib/ctrl.lib.sh @@ -22,7 +22,7 @@ zaf_ctrl_get_item_block() { # Get global plugin block body from stdin # $1 itemname zaf_ctrl_get_global_block() { - grep -v '^#' | awk '{ i=0; + grep -v '^#' | awk '{ i=0; print $0; while (i==0) { getline; if (/^Item /) exit; @@ -33,7 +33,7 @@ zaf_ctrl_get_global_block() { # Get item multiline option # $1 optionname zaf_block_get_moption() { - awk '/^'$1'::$/ { i=0; + awk '/^'$1'::$/ { i=0; print $0; while (i==0) { getline; if (/^::$/) {i=1; continue;}; @@ -218,16 +218,13 @@ zaf_ctrl_generate_cfg() { $(which echo) "UserParameter=$ikey,${ZAF_LIB_DIR}/preload.sh $cache $lock$cmd"; continue fi - cmd=$(zaf_ctrl_get_item_option $1 $i "Function") - if [ -n "$cmd" ]; then - $(which echo) "UserParameter=$ikey,${ZAF_LIB_DIR}/preload.sh $cache $lock$cmd"; - continue; - fi cmd=$(zaf_ctrl_get_item_option $1 $i "Script") if [ -n "$cmd" ]; then - zaf_ctrl_get_item_option $1 $i "Script" >${ZAF_TMP_DIR}/${iscript}.sh; + zaf_ctrl_get_item_option $1 $i "Script" | \ + zaf_far '{INCLUDES}' '. /etc/zaf.conf; . ${ZAF_LIB_DIR}/zaf.lib.sh; . ${ZAF_LIB_DIR}/ctrl.lib.sh; . ${ZAF_LIB_DIR}/zbxapi.lib.sh; . ${ZAF_LIB_DIR}/cache.lib.sh; ' \ + >${ZAF_TMP_DIR}/${iscript}.sh; zaf_install_bin ${ZAF_TMP_DIR}/${iscript}.sh ${ZAF_PLUGINS_DIR}/$2/ - $(which echo) "UserParameter=$ikey,${ZAF_LIB_DIR}/preload.sh $cache $lock${ZAF_PLUGINS_DIR}/$2/${iscript}.sh $args"; + $(which echo) "UserParameter=$ikey,$cache $lock${ZAF_PLUGINS_DIR}/$2/${iscript}.sh $args"; continue; fi zaf_err "Item $i declared in control file but has no Cmd, Function or Script!"