1
0
mirror of https://github.com/limosek/zaf.git synced 2024-11-13 05:59:06 +01:00

Simulate zaf_sudo if needed

Add plugin name as env var
This commit is contained in:
Lukas Macura 2016-05-13 18:00:19 +02:00
parent 658496e7cc
commit 7b07643be9
4 changed files with 15 additions and 2 deletions

View File

@ -338,6 +338,7 @@ fi
export ZAF_TMP_DIR="/tmp/zaf-installer"
export ZAF_DIR="$ZAF_TMP_DIR/zaf"
! [ -d $ZAF_TMP_DIR ] && mkdir -p $ZAF_TMP_DIR
zaf_debug_init stderr
zaf_tmp_init

View File

@ -218,7 +218,7 @@ zaf_ctrl_generate_cfg() {
zafparams=""
args=""
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; "
env="export ITEM_KEY='$ikey'; export PLUGIN='$2'; 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")
if [ -n "$lock" ]; then
lock="${ZAF_LIB_DIR}/zaflock $lock "

View File

@ -9,6 +9,9 @@
. ${ZAF_LIB_DIR}/zbxapi.lib.sh
. ${ZAF_LIB_DIR}/cache.lib.sh
# Plugin specific functions if exists
[ -f ./functions.sh ] && . ./functions.sh
if ! type zaf_version >/dev/null; then
echo "Problem loading libraries?"
exit 2
@ -23,7 +26,7 @@ export ZAF_CACHE_DIR
export ZAF_PLUGINS_DIR
export ZAF_DEBUG
unset ZAF_LOG_STDERR
export PATH=$ZAF_LIB_DIR:$ZAF_BIN_DIR:$PATH
export PATH
if [ "$(basename $0)" = "preload.sh" ] && [ -n "$*" ]; then
tmpf=$(zaf_tmpfile preload)

View File

@ -258,3 +258,12 @@ zaf_random() {
hexdump -n 2 -e '/2 "%u"' /dev/urandom
}
# Emulate sudo
zaf_sudo() {
if zaf_is_root || ! which sudo >/dev/null 2>/dev/null; then
$@
else
sudo $@
fi
}