mirror of
https://github.com/limosek/zaf.git
synced 2024-11-24 03:19:05 +01:00
Repaired zabbix auto installation
This commit is contained in:
parent
99bd255e3f
commit
8188fdba93
15
install.sh
15
install.sh
@ -99,9 +99,17 @@ zaf_getrest(){
|
||||
# Set config option in zabbix agent
|
||||
# $1 option
|
||||
# $2 value
|
||||
zaf_agent_set_option() {
|
||||
# $3 if nonempty, do not remove opion from config, just add to the end
|
||||
zaf_set_agent_option() {
|
||||
local option="$1"
|
||||
local value="$2"
|
||||
if [ -n "$3" ]; then
|
||||
if ! grep -q "^$1=$2" $ZAF_AGENT_CONFIG; then
|
||||
zaf_dbg "Adding option $option to $ZAF_AGENT_CONFIG."
|
||||
echo "$option=$value" >>$ZAF_AGENT_CONFIG
|
||||
fi
|
||||
return
|
||||
fi
|
||||
if grep ^$option\= $ZAF_AGENT_CONFIG; then
|
||||
zaf_wrn "Moving option $option to zaf config part."
|
||||
sed -i "s/$option=/#$option=/" $ZAF_AGENT_CONFIG
|
||||
@ -122,7 +130,7 @@ zaf_configure_agent() {
|
||||
echo $pair | grep -q '^Z\_' || continue # Skip non Z_ vars
|
||||
option=$(echo $pair|cut -d '=' -f 1|cut -d '_' -f 2)
|
||||
value=$(echo $pair|cut -d '=' -f 2-)
|
||||
zaf_agent_set_option "$option" "$value"
|
||||
zaf_set_agent_option "$option" "$value"
|
||||
done
|
||||
}
|
||||
|
||||
@ -228,6 +236,7 @@ reconf)
|
||||
install)
|
||||
zaf_configure auto
|
||||
zaf_configure_agent "$@"
|
||||
zaf_set_agent_option "Include" "$ZAF_AGENT_CONFIGD" append
|
||||
rm -rif ${ZAF_TMP_DIR}
|
||||
mkdir -p ${ZAF_TMP_DIR}
|
||||
zaf_install_dir ${ZAF_LIB_DIR}
|
||||
@ -245,7 +254,7 @@ install)
|
||||
if zaf_is_root; then
|
||||
[ "${ZAF_GIT}" -eq 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_check_agent_config; then
|
||||
if zaf_is_root && ! zaf_test_item zaf.framework_version; then
|
||||
echo "Something is wrong with zabbix agent config."
|
||||
echo "Ensure that zabbix_agentd reads ${ZAF_AGENT_CONFIG}"
|
||||
echo "and there is Include=${ZAF_AGENT_CONFIGD} directive inside."
|
||||
|
@ -101,22 +101,31 @@ zaf_uninstall(){
|
||||
# Automaticaly install agent on debian
|
||||
# For another os, create similar function (install_zabbix_centos)
|
||||
zaf_install_agent_debian() {
|
||||
zaf_fetch_url "http://repo.zabbix.com/zabbix/3.0/debian/pool/main/z/zabbix-release/zabbix-release_3.0-1+${ZAF_CODENAME}_all.deb" >"/tmp/zaf-installer/zabbix-release_3.0-1+${ZAF_CODENAME}_all.deb" \
|
||||
&& dpkg -i "/tmp/zaf-installer/zabbix-release_3.0-1+${ZAF_CODENAME}_all.deb" \
|
||||
zaf_fetch_url "http://repo.zabbix.com/zabbix/3.0/debian/pool/main/z/zabbix-release/zabbix-release_3.0-1+${ZAF_OS_CODENAME}_all.deb" >"/tmp/zaf-installer/zabbix-release_3.0-1+${ZAF_OS_CODENAME}_all.deb" \
|
||||
&& dpkg -i "/tmp/zaf-installer/zabbix-release_3.0-1+${ZAF_OS_CODENAME}_all.deb" \
|
||||
&& apt-get update \
|
||||
&& apt-get install $ZAF_AGENT_PKG
|
||||
&& apt-get install -y -q $ZAF_AGENT_PKG
|
||||
}
|
||||
|
||||
zaf_install_agent_opkg() {
|
||||
opkg update && \
|
||||
opkg install $ZAF_AGENT_PKG
|
||||
}
|
||||
|
||||
# Check if dpkg dependency is met
|
||||
# $* - packages
|
||||
zaf_check_deps_dpkg() {
|
||||
dpkg-query -f '${Package}\n' -W $* >/dev/null
|
||||
for i in $*; do
|
||||
dpkg-query -f '${Status},${Package}\n' -W $* 2>/dev/null | grep -q "^install ok"
|
||||
done
|
||||
}
|
||||
|
||||
# Check if dpkg dependency is met
|
||||
# $* - packages
|
||||
zaf_check_deps_rpm() {
|
||||
rpm --quiet -qi $*
|
||||
for i in $*; do
|
||||
rpm --quiet -qi $i | grep -q $i
|
||||
done
|
||||
}
|
||||
|
||||
# Check if dpkg dependency is met
|
||||
|
@ -9,13 +9,13 @@ zaf_msg() {
|
||||
echo $@
|
||||
}
|
||||
zaf_dbg() {
|
||||
[ "$ZAF_DEBUG" -ge "2" ] && logger -s -t zaf $@
|
||||
[ "$ZAF_DEBUG" -ge "2" ] && logger -s -t zaf -- $@
|
||||
}
|
||||
zaf_wrn() {
|
||||
[ "$ZAF_DEBUG" -ge "1" ] && logger -s -t zaf $@
|
||||
[ "$ZAF_DEBUG" -ge "1" ] && logger -s -t zaf -- $@
|
||||
}
|
||||
zaf_err() {
|
||||
logger -s -t zaf $@
|
||||
logger -s -t zaf -- $@
|
||||
logger -s -t zaf "Exiting with error!"
|
||||
exit 1
|
||||
}
|
||||
@ -40,7 +40,7 @@ zaf_fetch_url() {
|
||||
case $scheme in
|
||||
http|https|ftp|file)
|
||||
[ "${ZAF_CURL_INSECURE}" = "1" ] && insecure="-k"
|
||||
zaf_msg curl $insecure -f -s -L -o - "$1"
|
||||
zaf_dbg curl $insecure -f -s -L -o - $1
|
||||
curl $insecure -f -s -L -o - "$1"
|
||||
;;
|
||||
esac
|
||||
|
Loading…
Reference in New Issue
Block a user