mirror of
https://github.com/limosek/zaf.git
synced 2024-11-25 03:49:06 +01:00
Force preloading of env before script execution
Parameters are exported as variables
This commit is contained in:
parent
efd52abc62
commit
2bb33dc105
@ -209,13 +209,14 @@ zaf_ctrl_generate_cfg() {
|
|||||||
args=""
|
args=""
|
||||||
apos=1;
|
apos=1;
|
||||||
while read pname pdefault pregex prest; do
|
while read pname pdefault pregex prest; do
|
||||||
zafparams="$zafparams value=\"\$$apos\"; zaf_agentparm $pname $pdefault $pregex;"
|
zafparams="$zafparams value=\"\$$apos\"; zaf_agentparm $pname $pdefault $pregex; export $pname; "
|
||||||
args="$args \$$apos"
|
args="$args \$$apos"
|
||||||
apos=$(expr $apos + 1)
|
apos=$(expr $apos + 1)
|
||||||
done <$tmpfile
|
done <$tmpfile
|
||||||
else
|
else
|
||||||
ikey="$2.$i"
|
ikey="$2.$i"
|
||||||
fi
|
fi
|
||||||
|
env="export ITEM_KEY='$ikey'; export PATH=${ZAF_PLUGINS_DIR}/$2:$ZAF_LIB_DIR:\$PATH; cd ${ZAF_PLUGINS_DIR}/$2; . $ZAF_LIB_DIR/preload.sh; "
|
||||||
lock=$(zaf_ctrl_get_item_option $1 $i "Lock")
|
lock=$(zaf_ctrl_get_item_option $1 $i "Lock")
|
||||||
if [ -n "$lock" ]; then
|
if [ -n "$lock" ]; then
|
||||||
lock="${ZAF_LIB_DIR}/zaflock $lock "
|
lock="${ZAF_LIB_DIR}/zaflock $lock "
|
||||||
@ -225,24 +226,18 @@ zaf_ctrl_generate_cfg() {
|
|||||||
cache="${ZAF_LIB_DIR}/zafcache '$cache' "
|
cache="${ZAF_LIB_DIR}/zafcache '$cache' "
|
||||||
fi
|
fi
|
||||||
cmd=$(zaf_ctrl_get_item_option $1 $i "Cmd")
|
cmd=$(zaf_ctrl_get_item_option $1 $i "Cmd")
|
||||||
if [ -z "$cache" ] && [ -z "$lock" ]; then
|
|
||||||
preload="${ZAF_LIB_DIR}/preload.sh "
|
|
||||||
else
|
|
||||||
preload=""
|
|
||||||
fi
|
|
||||||
if [ -n "$cmd" ]; then
|
if [ -n "$cmd" ]; then
|
||||||
printf "%s" "UserParameter=$ikey,export ITEM_KEY='$ikey'; ${preload}${cache}${lock}${cmd}"; echo
|
printf "%s" "UserParameter=$ikey,${env}${zafparams}${preload}${cache}${lock}${cmd} ${args}"; echo
|
||||||
continue
|
continue
|
||||||
fi
|
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
|
||||||
( echo "#!/bin/sh"
|
( echo "#!/bin/sh"
|
||||||
echo ". $ZAF_LIB_DIR/preload.sh; "
|
echo ". $ZAF_LIB_DIR/preload.sh; "
|
||||||
echo "$zafparams"
|
|
||||||
zaf_ctrl_get_item_option $1 $i "Script"
|
zaf_ctrl_get_item_option $1 $i "Script"
|
||||||
) >${ZAF_TMP_DIR}/${iscript}.sh;
|
) >${ZAF_TMP_DIR}/${iscript}.sh;
|
||||||
[ -z "$3" ] && zaf_install_bin ${ZAF_TMP_DIR}/${iscript}.sh ${ZAF_PLUGINS_DIR}/$2/
|
[ -z "$3" ] && zaf_install_bin ${ZAF_TMP_DIR}/${iscript}.sh ${ZAF_PLUGINS_DIR}/$2/
|
||||||
printf "%s" "UserParameter=$ikey,export ITEM_KEY='$ikey'; ${preload}${cache}${lock}${ZAF_PLUGINS_DIR}/$2/${iscript}.sh $args"; echo
|
printf "%s" "UserParameter=$ikey,${env}${preload}${zafparams}${cache}${lock}${ZAF_PLUGINS_DIR}/$2/${iscript}.sh ${args}"; echo
|
||||||
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!"
|
||||||
|
Loading…
Reference in New Issue
Block a user