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

Repaired bugs

This commit is contained in:
Lukas Macura 2016-04-04 14:00:44 +02:00
parent 8188fdba93
commit f0988cf5ee
5 changed files with 32 additions and 13 deletions

View File

@ -162,7 +162,7 @@ zaf_configure(){
zaf_get_option ZAF_LIB_DIR "Libraries directory" "/usr/lib/zaf" "$1"
zaf_get_option ZAF_BIN_DIR "Directory to put binaries" "/usr/bin" "$1"
zaf_get_option ZAF_PLUGINS_DIR "Plugins directory" "${ZAF_LIB_DIR}/plugins" "$1"
[ "${ZAF_GIT}" -eq 1 ] && zaf_get_option ZAF_PLUGINS_GITURL "Git plugins repository" "https://github.com/limosek/zaf-plugins.git" "$1"
[ "${ZAF_GIT}" = 1 ] && zaf_get_option ZAF_PLUGINS_GITURL "Git plugins repository" "https://github.com/limosek/zaf-plugins.git" "$1"
zaf_get_option ZAF_PLUGINS_URL "Plugins http[s] repository" "https://raw.githubusercontent.com/limosek/zaf-plugins/master/" "$1"
zaf_get_option ZAF_REPO_DIR "Plugins directory" "${ZAF_LIB_DIR}/repo" "$1"
zaf_get_option ZAF_AGENT_CONFIG "Zabbix agent config" "/etc/zabbix/zabbix_agentd.conf" "$1"
@ -191,7 +191,7 @@ zaf_configure(){
zaf_set_option ZAF_BIN_DIR "$ZAF_BIN_DIR"
zaf_set_option ZAF_PLUGINS_DIR "$ZAF_PLUGINS_DIR"
zaf_set_option ZAF_PLUGINS_URL "$ZAF_PLUGINS_URL"
[ "${ZAF_GIT}" -eq 1 ] && zaf_set_option ZAF_PLUGINS_GITURL "$ZAF_PLUGINS_GITURL"
[ "${ZAF_GIT}" = 1 ] && zaf_set_option ZAF_PLUGINS_GITURL "$ZAF_PLUGINS_GITURL"
zaf_set_option ZAF_REPO_DIR "$ZAF_REPO_DIR"
zaf_set_option ZAF_AGENT_CONFIG "$ZAF_AGENT_CONFIG"
zaf_set_option ZAF_AGENT_CONFIGD "$ZAF_AGENT_CONFIGD"
@ -252,7 +252,7 @@ install)
zaf_install_bin $(zaf_getrest zaf) ${ZAF_BIN_DIR}
export INSTALL_PREFIX ZAF_CFG_FILE
if zaf_is_root; then
[ "${ZAF_GIT}" -eq 1 ] && ${INSTALL_PREFIX}/${ZAF_BIN_DIR}/zaf update
[ "${ZAF_GIT}" = 1 ] && ${INSTALL_PREFIX}/${ZAF_BIN_DIR}/zaf update
${INSTALL_PREFIX}/${ZAF_BIN_DIR}/zaf reinstall zaf || zaf_err "Error installing zaf plugin."
if zaf_is_root && ! zaf_test_item zaf.framework_version; then
echo "Something is wrong with zabbix agent config."

View File

@ -119,6 +119,12 @@ zaf_ctrl_generate_cfg() {
params=$(zaf_ctrl_get_item_option $1 $i "Parameters")
if [ -n "$params" ]; then
ikey="$2.$i[*]"
args=""
apos=1;
for p in $params; do
args="$args \$$apos"
apos=$(expr $apos + 1)
done
else
ikey="$2.$i"
fi
@ -128,19 +134,19 @@ zaf_ctrl_generate_cfg() {
fi
cmd=$(zaf_ctrl_get_item_option $1 $i "Cmd")
if [ -n "$cmd" ]; then
echo "UserParameter=$ikey,${ZAF_LIB_DIR}/preload.sh $lock$cmd";
$(which echo) "UserParameter=$ikey,${ZAF_LIB_DIR}/preload.sh $lock$cmd $args";
continue
fi
cmd=$(zaf_ctrl_get_item_option $1 $i "Function")
if [ -n "$cmd" ]; then
echo "UserParameter=$ikey,${ZAF_LIB_DIR}/preload.sh $lock$cmd";
$(which echo) -E "UserParameter=$ikey,${ZAF_LIB_DIR}/preload.sh $lock$cmd $args";
continue;
fi
cmd=$(zaf_ctrl_get_item_option $1 $i "Script")
if [ -n "$cmd" ]; then
zaf_ctrl_get_item_option $1 $i "Script" >${ZAF_TMP_DIR}/${iscript}.sh;
zaf_install_bin ${ZAF_TMP_DIR}/${ikey}.sh ${ZAF_PLUGINS_DIR}/$2/
echo "UserParameter=$ikey,${ZAF_LIB_DIR}/preload.sh $lock${ZAF_PLUGINS_DIR}/$2/${iscript}.sh";
zaf_install_bin ${ZAF_TMP_DIR}/${iscript}.sh ${ZAF_PLUGINS_DIR}/$2/
$(which echo) "UserParameter=$ikey,${ZAF_LIB_DIR}/preload.sh $lock${ZAF_PLUGINS_DIR}/$2/${iscript}.sh $args";
continue;
fi
zaf_err "Item $i declared in control file but has no Cmd, Function or Script!"

View File

@ -16,6 +16,7 @@ export ZAF_LIB_DIR
export ZAF_TMP_DIR
export ZAF_PLUGINS_DIR
[ -n "$*" ] && $@
[ "$(basename $0)" = "preload.sh" ] && [ -n "$*" ] && $@

View File

@ -199,6 +199,10 @@ zaf_plugin_info() {
# $1 is url, directory or plugin name (will be searched in default plugin dir).
# $2 is directory to prepare.
zaf_prepare_plugin() {
local url
local plugindir
local control
url=$(zaf_get_plugin_url "$1")/control.zaf
plugindir="$2"
control=${plugindir}/control.zaf
@ -212,13 +216,20 @@ zaf_prepare_plugin() {
}
zaf_install_plugin() {
local url
local plugin
local plugindir
local control
if zaf_prepare_plugin "$1" "${ZAF_TMP_DIR}/plugin"; then
url=$(zaf_get_plugin_url "$1")
plugin=$(zaf_ctrl_get_global_block <"${ZAF_TMP_DIR}/plugin/control.zaf" | zaf_block_get_option Plugin)
plugindir="${ZAF_PLUGINS_DIR}"/$plugin
if zaf_prepare_plugin "$1" $plugindir; then
control=${plugindir}/control.zaf
[ "$ZAF_DEBUG" -gt 0 ] && zaf_plugin_info "${control}"
zaf_ctrl_check_deps "${control}"
zaf_ctrl_install "$1" "${control}" "${plugindir}"
zaf_ctrl_install "$url" "${control}" "${plugindir}"
zaf_ctrl_generate_cfg "${control}" "${plugin}" \
| zaf_far '{PLUGINDIR}' "${plugindir}" >${ZAF_AGENT_CONFIGD}/zaf_${plugin}.conf
zaf_dbg "Generated ${ZAF_AGENT_CONFIGD}/zaf_${plugin}.conf"

9
zaf
View File

@ -83,7 +83,7 @@ test)
install)
shift;
[ -z "$@" ] && echo "$0 install plugin [plugin]..."
[ -z "$1" ] && echo "$0 install plugin [plugin]..."
for p in $@; do
if zaf_is_plugin "$p"; then
zaf_wrn "Plugin $p already installed. Skipping installation."
@ -97,7 +97,7 @@ install)
reinstall)
shift;
[ -z "$@" ] && echo "$0 reinstall plugin [plugin]..."
[ -z "$1" ] && echo "$0 reinstall plugin [plugin]..."
for p in $@; do
if zaf_is_plugin "$p"; then
zaf_remove_plugin "$(basename $p)"
@ -111,7 +111,7 @@ reinstall)
remove)
shift;
[ -z "$@" ] && echo "$0 remove plugin [plugin]..."
[ -z "$1" ] && echo "$0 remove plugin [plugin]..."
for p in $@; do
if zaf_is_plugin "$p"; then
zaf_remove_plugin "$p"
@ -124,7 +124,7 @@ remove)
self-upgrade)
rm -rf /tmp/zaf-installer && mkdir /tmp/zaf-installer
if zaf_fetch_url $ZAF_URL/install.sh >/tmp/zaf-installer/install.sh; then
cd /tmp/zaf-installer && ./install.sh
cd /tmp/zaf-installer && exec ./install.sh
else
echo "Cannot fetch uri $ZAF_URL/install.sh!";
fi
@ -146,6 +146,7 @@ self-remove)
;;
*)
echo "$0 Version ${ZAF_VERSION}. Please use some of this commands:"
echo "$0 update To update repo"
echo "$0 plugins To list installed plugins"
echo "$0 show [plugin] To show installed plugins or plugin info"