1
0
mirror of https://github.com/limosek/zaf.git synced 2024-11-10 20:57:21 +01:00
limosek-zaf/lib/preload.sh

48 lines
1.0 KiB
Bash
Raw Normal View History

2016-04-01 12:20:23 +02:00
#!/bin/sh
. /etc/zaf.conf
2016-04-01 15:51:45 +02:00
2016-04-21 15:29:48 +02:00
. ${ZAF_LIB_DIR}/zaf.lib.sh
. ${ZAF_LIB_DIR}/plugin.lib.sh
. ${ZAF_LIB_DIR}/ctrl.lib.sh
. ${ZAF_LIB_DIR}/os.lib.sh
. ${ZAF_LIB_DIR}/zbxapi.lib.sh
. ${ZAF_LIB_DIR}/cache.lib.sh
2016-04-01 15:51:45 +02:00
[ -z "$ZAF_TMP_BASE" ] && ZAF_TMP_BASE=/tmp/zaf
2016-04-21 15:29:48 +02:00
[ -z "$ZAF_TMP_DIR" ] && ZAF_TMP_DIR="${ZAF_TMP_BASE}-$(zaf_random)"
[ -z "$ZAF_CACHE_DIR" ] && ZAF_CACHE_DIR=${ZAF_TMP_BASE}c
2016-04-21 15:29:48 +02:00
rm -rf "${ZAF_TMP_DIR}"
if ! [ -d "${ZAF_TMP_DIR}" ]; then
mkdir "${ZAF_TMP_DIR}"
fi
! [ -d "${ZAF_CACHE_DIR}" ] && mkdir "${ZAF_CACHE_DIR}"
2016-04-01 15:51:45 +02:00
[ -z "$ZAF_DEBUG" ] && ZAF_DEBUG=1
2016-04-21 15:29:48 +02:00
if [ "$ZAF_DEBUG" -le 3 ]; then
trap "rm -rf ${ZAF_TMP_DIR}" EXIT
else
trap 'zaf_wrn "Leaving $ZAF_TMP_DIR" contents due to ZAF_DEBUG.' EXIT
fi
#trap 'touch /tmp/aaaa' ALARM
2016-04-01 15:51:45 +02:00
export ZAF_LIB_DIR
export ZAF_TMP_DIR
export ZAF_CACHE_DIR
2016-04-01 15:51:45 +02:00
export ZAF_PLUGINS_DIR
2016-04-21 15:29:48 +02:00
export ZAF_DEBUG
unset ZAF_LOG_STDERR
export PATH=$ZAF_LIB_DIR:$ZAF_BIN_DIR:$PATH
if [ "$(basename $0)" = "preload.sh" ] && [ -n "$*" ]; then
tmpf=$(zaf_tmpfile preload)
$@ 2>$tmpf
[ -s $tmpf ] && zaf_wrn <$tmpf
fi
2016-04-01 12:20:23 +02:00