1
0
mirror of https://github.com/limosek/zaf.git synced 2024-11-23 19:09:08 +01:00

Repaired ctrl functions (from trunk)

This commit is contained in:
Lukas Macura 2016-04-15 11:18:46 +02:00
parent c830d0e6a0
commit 45a072024c

View File

@ -22,7 +22,7 @@ zaf_ctrl_get_item_block() {
# Get global plugin block body from stdin # Get global plugin block body from stdin
# $1 itemname # $1 itemname
zaf_ctrl_get_global_block() { zaf_ctrl_get_global_block() {
grep -v '^#' | awk '{ i=0; grep -v '^#' | awk '{ i=0; print $0;
while (i==0) { while (i==0) {
getline; getline;
if (/^Item /) exit; if (/^Item /) exit;
@ -33,7 +33,7 @@ zaf_ctrl_get_global_block() {
# Get item multiline option # Get item multiline option
# $1 optionname # $1 optionname
zaf_block_get_moption() { zaf_block_get_moption() {
awk '/^'$1'::$/ { i=0; awk '/^'$1'::$/ { i=0; print $0;
while (i==0) { while (i==0) {
getline; getline;
if (/^::$/) {i=1; continue;}; if (/^::$/) {i=1; continue;};
@ -218,16 +218,13 @@ zaf_ctrl_generate_cfg() {
$(which echo) "UserParameter=$ikey,${ZAF_LIB_DIR}/preload.sh $cache $lock$cmd"; $(which echo) "UserParameter=$ikey,${ZAF_LIB_DIR}/preload.sh $cache $lock$cmd";
continue continue
fi 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") cmd=$(zaf_ctrl_get_item_option $1 $i "Script")
if [ -n "$cmd" ]; then 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/ 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; continue;
fi fi
zaf_err "Item $i declared in control file but has no Cmd, Function or Script!" zaf_err "Item $i declared in control file but has no Cmd, Function or Script!"