From 58382928569d323e035a3f5555ddb5616995a907 Mon Sep 17 00:00:00 2001 From: Lukas Macura Date: Tue, 22 Nov 2016 14:27:44 +0100 Subject: [PATCH] Added postconf hook for openwrt systems --- install.sh | 3 ++- lib/os.lib.sh | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 2fd622e..705acc3 100755 --- a/install.sh +++ b/install.sh @@ -222,7 +222,7 @@ zaf_configure_server() { zaf_preconfigure(){ zaf_detect_system - zaf_os_specific zaf_configure_os + zaf_os_specific zaf_preconfigure_os if ! zaf_is_root; then [ -z "$INSTALL_PREFIX" ] && zaf_err "We are not root. Use INSTALL_PREFIX or become root." else @@ -372,6 +372,7 @@ zaf_postconfigure() { [ "${ZAF_GIT}" = 1 ] && ${INSTALL_PREFIX}/${ZAF_BIN_DIR}/zaf update ${INSTALL_PREFIX}/${ZAF_BIN_DIR}/zaf reinstall zaf || zaf_err "Error installing zaf plugin." ${INSTALL_PREFIX}/${ZAF_BIN_DIR}/zaf agent-config || zaf_err "Error configuring agent." + zaf_os_specific zaf_postconfigure_os 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}" diff --git a/lib/os.lib.sh b/lib/os.lib.sh index 1948e14..4e8b8ad 100644 --- a/lib/os.lib.sh +++ b/lib/os.lib.sh @@ -1,17 +1,17 @@ # Os related functions -zaf_configure_os_openwrt() { +zaf_preconfigure_os_openwrt() { ZAF_AGENT_RESTART="zaf agent-config ; /etc/init.d/zabbix_agentd restart" ZAF_AGENT_CONFIGD="/var/run/zabbix_agentd.conf.d/" ZAF_AGENT_CONFIG="/etc/zabbix_agentd.conf" ZAF_AGENT_PKG="zabbix-agentd" ZAF_CURL_INSECURE=1 } -zaf_configure_os_beesip() { - zaf_configure_os_openwrt +zaf_preconfigure_os_beesip() { + zaf_preconfigure_os_openwrt } -zaf_configure_os_freebsd() { +zaf_preconfigure_os_freebsd() { ZAF_AGENT_PKG="zabbix3-agent" ZAF_AGENT_CONFIG="/usr/local/etc/zabbix3/zabbix_agentd.conf" ZAF_AGENT_CONFIGD="/usr/local/etc/zabbix3/zabbix_agentd.conf.d/" @@ -20,6 +20,16 @@ zaf_configure_os_freebsd() { ZAF_SUDOERSD="/usr/local/etc/sudoers.d" } +zaf_postconfigure_os_openwrt() { + if ! grep -q "zaf agent-config" /etc/init.d/zabbix_agentd; then + sed -i 's/uci2config $NAME/uci2config $NAME; zaf agent-config/' /etc/init.d/zabbix_agentd + fi +} + +zaf_postconfigure_os_beesip() { + zaf_postconfigure_os_openwrt +} + zaf_which() { if which >/dev/null 2>/dev/null; then which "$1"