mirror of
https://github.com/limosek/zaf.git
synced 2024-11-24 19:39:08 +01:00
Repaired plugin (re)installation
This commit is contained in:
parent
0ef05853a4
commit
9ac7bd34d4
@ -104,14 +104,13 @@ git clone https://github.com/limosek/zaf.git \
|
|||||||
&& cd zaf \
|
&& cd zaf \
|
||||||
&& git checkout master \
|
&& git checkout master \
|
||||||
&& git clone https://github.com/limosek/zaf-plugins.git \
|
&& git clone https://github.com/limosek/zaf-plugins.git \
|
||||||
&& make deb PLUGINS="./zaf-plugins/fsx" IPLUGINS="zaf" ZAF_OPTIONS="ZAF_GIT=0" AGENT_OPTIONS="Z_Server=zabbix.server Z_ServerActive=zabbix.server Z_StartAgents=8"
|
&& make deb PLUGINS="./zaf-plugins/fsx" ZAF_PLUGINS="zaf" ZAF_OPTIONS="ZAF_GIT=0" AGENT_OPTIONS="Z_Server=zabbix.server Z_ServerActive=zabbix.server Z_StartAgents=8"
|
||||||
sudo dpkg -i out/zaf-1.3master.deb
|
sudo dpkg -i out/zaf-1.3master.deb
|
||||||
```
|
```
|
||||||
General usage:
|
General usage:
|
||||||
```
|
```
|
||||||
make {deb|ipk|rpm} [PLUGINS="/dir/plg1 [/dir2]...] [IPLUGINS="plg1 [plg2]..."] [ZAF_OPTIONS="ZAF_cfg=val ..."] [AGENT_OPTIONS="Z_Server=host ..."]
|
make {deb|ipk|rpm} [ZAF_PLUGINS="plg1 [plg2]" [ZAF_OPTIONS="ZAF_cfg=val ..."] [AGENT_OPTIONS="Z_Server=host ..."]
|
||||||
PLUGINS are embedded into package. Has to be local directories accessible during build.
|
ZAF_PLUGINS are embedded into package. Has to be local directories accessible during build.
|
||||||
IPLUGINS will be downloaded and installed after package is installed. Can be name or url accessible after package installation.
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Zaf plugin
|
## Zaf plugin
|
||||||
|
@ -56,7 +56,7 @@ zaf_cache_unlock(){
|
|||||||
# $2 value
|
# $2 value
|
||||||
# $3 lifetime in seconds
|
# $3 lifetime in seconds
|
||||||
zaf_tocache(){
|
zaf_tocache(){
|
||||||
! [ -w $ZAF_CACHE_DIR ] && return 1
|
! [ -w $ZAF_CACHE_DIR ] && return
|
||||||
local key
|
local key
|
||||||
local value
|
local value
|
||||||
local expiry
|
local expiry
|
||||||
@ -82,7 +82,7 @@ zaf_tocache(){
|
|||||||
# $1 key
|
# $1 key
|
||||||
# $2 lifetime in seconds
|
# $2 lifetime in seconds
|
||||||
zaf_tocache_stdin(){
|
zaf_tocache_stdin(){
|
||||||
! [ -w $ZAF_CACHE_DIR ] && { cat; return 1; }
|
! [ -w $ZAF_CACHE_DIR ] && { cat; return; }
|
||||||
local key
|
local key
|
||||||
local expiry
|
local expiry
|
||||||
local infofile
|
local infofile
|
||||||
|
@ -219,8 +219,6 @@ zaf_ctrl_install() {
|
|||||||
zaf_fetch_url "$1/$b" >"${ZAF_TMP_DIR}/$b"
|
zaf_fetch_url "$1/$b" >"${ZAF_TMP_DIR}/$b"
|
||||||
zaf_install "${ZAF_TMP_DIR}/$b" "$pdir"
|
zaf_install "${ZAF_TMP_DIR}/$b" "$pdir"
|
||||||
done
|
done
|
||||||
script=$(zaf_ctrl_get_global_option $2 "Install-script")
|
|
||||||
[ -n "$script" ] && eval "$script"
|
|
||||||
true
|
true
|
||||||
) || zaf_err "Error during zaf_ctrl_install"
|
) || zaf_err "Error during zaf_ctrl_install"
|
||||||
}
|
}
|
||||||
|
@ -18,24 +18,16 @@ zaf_update_repo() {
|
|||||||
zaf_get_plugin_url() {
|
zaf_get_plugin_url() {
|
||||||
local url
|
local url
|
||||||
|
|
||||||
if echo "$1" | grep -q '/'; then
|
if [ "$(zaf_url_info $1)" = "path" ]; then
|
||||||
url="$1" # plugin with path - from directory
|
url="$1" # plugin with path - from directory
|
||||||
else
|
else
|
||||||
if echo "$1" | grep -q ^http; then
|
if [ "$(zaf_url_info $1)" = "url" ]; then
|
||||||
url="$1" # plugin with http[s] url
|
url="$1" # plugin with http[s] url
|
||||||
else
|
else
|
||||||
if [ -d "${ZAF_REPO_DIR}/$1" ]; then
|
if [ -n "${ZAF_REPO_URL}" ]; then
|
||||||
url="${ZAF_REPO_DIR}/$1"
|
url="${ZAF_REPO_URL}/$1"
|
||||||
else
|
else
|
||||||
if [ -n "${ZAF_PREPACKAGED_DIR}" ] && [ -d "${ZAF_PREPACKAGED_DIR}/$1" ]; then
|
zaf_err "Cannot find plugin $1"
|
||||||
url="${ZAF_PREPACKAGED_DIR}/$1"
|
|
||||||
else
|
|
||||||
if [ -n "${ZAF_REPO_URL}" ]; then
|
|
||||||
url="${ZAF_REPO_URL}/$1"
|
|
||||||
else
|
|
||||||
zaf_err "Cannot find plugin $1"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -89,14 +81,18 @@ zaf_prepare_plugin() {
|
|||||||
url=$(zaf_get_plugin_url "$1")/control.zaf || exit $?
|
url=$(zaf_get_plugin_url "$1")/control.zaf || exit $?
|
||||||
plugindir="$2"
|
plugindir="$2"
|
||||||
control=${plugindir}/control.zaf
|
control=${plugindir}/control.zaf
|
||||||
|
if [ "$(zaf_url_info $1)" = "path" ] && cmp -s "$url" "$control"; then
|
||||||
|
zaf_err "prepare_plugin: Cannot install from itself!"
|
||||||
|
fi
|
||||||
zaf_install_dir "$plugindir"
|
zaf_install_dir "$plugindir"
|
||||||
zaf_dbg "Fetching control file from $url ..."
|
zaf_dbg "Fetching control file from $url ..."
|
||||||
if zaf_fetch_url "$url" >"${INSTALL_PREFIX}/${control}"; then
|
if zaf_fetch_url "$url" >"${INSTALL_PREFIX}/${control}"; then
|
||||||
[ -z "${INSTALL_PREFIX}" ] && zaf_ctrl_check_deps "${control}"
|
[ -z "${INSTALL_PREFIX}" ] && zaf_ctrl_check_deps "${control}"
|
||||||
pluginname=$(zaf_ctrl_get_global_block <"${INSTALL_PREFIX}/${control}" | zaf_block_get_option Plugin)
|
pluginname=$(zaf_ctrl_get_global_block <"${INSTALL_PREFIX}/${control}" | zaf_block_get_option Plugin)
|
||||||
[ "$(basename $plugindir)" != "$pluginname" ] && zaf_err "prepare_plugin: Plugin name mismach ($plugindir vs $pluginname)!"
|
[ "$(basename $plugindir)" != "$pluginname" ] && zaf_err "prepare_plugin: Plugin name mismach ($plugindir vs ${INSTALL_PREFIX}/${control})!"
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
|
rm -rf "$plugindir"
|
||||||
zaf_err "prepare_plugin: Cannot fetch or write control file ${INSTALL_PREFIX}/$control from url $url!"
|
zaf_err "prepare_plugin: Cannot fetch or write control file ${INSTALL_PREFIX}/$control from url $url!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -112,6 +108,7 @@ zaf_install_plugin() {
|
|||||||
plugin=$(basename "$1")
|
plugin=$(basename "$1")
|
||||||
plugindir="${ZAF_PLUGINS_DIR}/${plugin}"
|
plugindir="${ZAF_PLUGINS_DIR}/${plugin}"
|
||||||
if [ -n "$plugin" ] && zaf_prepare_plugin "$1" $plugindir; then
|
if [ -n "$plugin" ] && zaf_prepare_plugin "$1" $plugindir; then
|
||||||
|
url=$(zaf_get_plugin_url "$1")
|
||||||
zaf_wrn "Installing plugin $plugin"
|
zaf_wrn "Installing plugin $plugin"
|
||||||
zaf_dbg "Source url: $url, Destination dir: $plugindir"
|
zaf_dbg "Source url: $url, Destination dir: $plugindir"
|
||||||
control=${plugindir}/control.zaf
|
control=${plugindir}/control.zaf
|
||||||
@ -125,7 +122,7 @@ zaf_install_plugin() {
|
|||||||
zaf_dbg "Generated ${ZAF_AGENT_CONFIGD}/zaf_${plugin}.conf"
|
zaf_dbg "Generated ${ZAF_AGENT_CONFIGD}/zaf_${plugin}.conf"
|
||||||
zaf_ctrl_generate_extitems_cfg "${control}" "${plugin}"
|
zaf_ctrl_generate_extitems_cfg "${control}" "${plugin}"
|
||||||
else
|
else
|
||||||
zaf_touch "${plugindir}/needinstall"
|
zaf_touch "${plugindir}/postinst.need"
|
||||||
fi
|
fi
|
||||||
zaf_ctrl_install "$url" "${control}" "${plugindir}"
|
zaf_ctrl_install "$url" "${control}" "${plugindir}"
|
||||||
else
|
else
|
||||||
@ -152,7 +149,6 @@ zaf_postinstall_plugin() {
|
|||||||
| zaf_far '{PLUGINDIR}' "${plugindir}" >${ZAF_AGENT_CONFIGD}/zaf_${plugin}.conf
|
| zaf_far '{PLUGINDIR}' "${plugindir}" >${ZAF_AGENT_CONFIGD}/zaf_${plugin}.conf
|
||||||
zaf_dbg "Generated ${ZAF_AGENT_CONFIGD}/zaf_${plugin}.conf"
|
zaf_dbg "Generated ${ZAF_AGENT_CONFIGD}/zaf_${plugin}.conf"
|
||||||
zaf_ctrl_generate_extitems_cfg "${control}" "${plugin}"
|
zaf_ctrl_generate_extitems_cfg "${control}" "${plugin}"
|
||||||
zaf_ctrl_install "$url" "${control}" "${plugindir}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,6 +109,20 @@ zaf_fetch_url() {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Get info about url
|
||||||
|
# returns path or url
|
||||||
|
zaf_url_info() {
|
||||||
|
if echo "$1" | grep -q '^/'; then
|
||||||
|
echo "path"
|
||||||
|
else
|
||||||
|
if echo "$1" | grep -q ^http; then
|
||||||
|
echo "url"
|
||||||
|
else
|
||||||
|
echo "unknown"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Find and replace string
|
# Find and replace string
|
||||||
zaf_far(){
|
zaf_far(){
|
||||||
local f
|
local f
|
||||||
|
8
zaf
8
zaf
@ -88,17 +88,19 @@ userparms)
|
|||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
agent-config)
|
agent-config)
|
||||||
|
[ -n "$2" ] && force=yes
|
||||||
for p in $(zaf_list_plugins); do
|
for p in $(zaf_list_plugins); do
|
||||||
if [ -f "$ZAF_PLUGINS_DIR/$p/needinstall" ]; then
|
if [ -f "$ZAF_PLUGINS_DIR/$p/postinst.need" ]; then
|
||||||
zaf_wrn "Calling postinstalation of plugin $p"
|
zaf_wrn "Calling postinstalation of plugin $p"
|
||||||
zaf_postinstall_plugin $p && rm -f "$ZAF_PLUGINS_DIR/$p/needinstall"
|
zaf_postinstall_plugin $p && rm -f "$ZAF_PLUGINS_DIR/$p/postinst.need"
|
||||||
|
force=yes
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
zaf_wrn "Generating config files in $ZAF_AGENT_CONFIGD ..."
|
zaf_wrn "Generating config files in $ZAF_AGENT_CONFIGD ..."
|
||||||
for plugin in $(zaf_list_plugins); do
|
for plugin in $(zaf_list_plugins); do
|
||||||
plugindir=$ZAF_PLUGINS_DIR/$plugin
|
plugindir=$ZAF_PLUGINS_DIR/$plugin
|
||||||
control=$plugindir/control.zaf
|
control=$plugindir/control.zaf
|
||||||
if ! [ -f "${ZAF_AGENT_CONFIGD}/zaf_${plugin}.conf" ] || [ "$control" -nt "${ZAF_AGENT_CONFIGD}/zaf_${plugin}.conf" ] || [ -n "$2" ]; then
|
if ! [ -f "${ZAF_AGENT_CONFIGD}/zaf_${plugin}.conf" ] || [ "$control" -nt "${ZAF_AGENT_CONFIGD}/zaf_${plugin}.conf" ] || [ -n "$force" ]; then
|
||||||
zaf_dbg "Generating ${ZAF_AGENT_CONFIGD}/zaf_${plugin}.conf"
|
zaf_dbg "Generating ${ZAF_AGENT_CONFIGD}/zaf_${plugin}.conf"
|
||||||
zaf_ctrl_generate_items_cfg "${control}" "${plugin}" \
|
zaf_ctrl_generate_items_cfg "${control}" "${plugin}" \
|
||||||
| zaf_far '{PLUGINDIR}' "${plugindir}" >${ZAF_AGENT_CONFIGD}/zaf_${plugin}.conf
|
| zaf_far '{PLUGINDIR}' "${plugindir}" >${ZAF_AGENT_CONFIGD}/zaf_${plugin}.conf
|
||||||
|
Loading…
Reference in New Issue
Block a user