mirror of
https://github.com/limosek/zaf.git
synced 2024-11-24 19:39:08 +01:00
Simulate zaf_sudo if needed
Add plugin name as env var
This commit is contained in:
parent
658496e7cc
commit
7b07643be9
@ -338,6 +338,7 @@ fi
|
|||||||
export ZAF_TMP_DIR="/tmp/zaf-installer"
|
export ZAF_TMP_DIR="/tmp/zaf-installer"
|
||||||
export ZAF_DIR="$ZAF_TMP_DIR/zaf"
|
export ZAF_DIR="$ZAF_TMP_DIR/zaf"
|
||||||
|
|
||||||
|
! [ -d $ZAF_TMP_DIR ] && mkdir -p $ZAF_TMP_DIR
|
||||||
zaf_debug_init stderr
|
zaf_debug_init stderr
|
||||||
zaf_tmp_init
|
zaf_tmp_init
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ zaf_ctrl_generate_cfg() {
|
|||||||
zafparams=""
|
zafparams=""
|
||||||
args=""
|
args=""
|
||||||
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; "
|
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")
|
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 "
|
||||||
|
@ -9,6 +9,9 @@
|
|||||||
. ${ZAF_LIB_DIR}/zbxapi.lib.sh
|
. ${ZAF_LIB_DIR}/zbxapi.lib.sh
|
||||||
. ${ZAF_LIB_DIR}/cache.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
|
if ! type zaf_version >/dev/null; then
|
||||||
echo "Problem loading libraries?"
|
echo "Problem loading libraries?"
|
||||||
exit 2
|
exit 2
|
||||||
@ -23,7 +26,7 @@ export ZAF_CACHE_DIR
|
|||||||
export ZAF_PLUGINS_DIR
|
export ZAF_PLUGINS_DIR
|
||||||
export ZAF_DEBUG
|
export ZAF_DEBUG
|
||||||
unset ZAF_LOG_STDERR
|
unset ZAF_LOG_STDERR
|
||||||
export PATH=$ZAF_LIB_DIR:$ZAF_BIN_DIR:$PATH
|
export PATH
|
||||||
|
|
||||||
if [ "$(basename $0)" = "preload.sh" ] && [ -n "$*" ]; then
|
if [ "$(basename $0)" = "preload.sh" ] && [ -n "$*" ]; then
|
||||||
tmpf=$(zaf_tmpfile preload)
|
tmpf=$(zaf_tmpfile preload)
|
||||||
|
@ -258,3 +258,12 @@ zaf_random() {
|
|||||||
hexdump -n 2 -e '/2 "%u"' /dev/urandom
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user