From 254f10834de5c9d12ba179274af56b163156cd6f Mon Sep 17 00:00:00 2001 From: Lukas Macura Date: Thu, 24 Mar 2016 17:46:37 +0100 Subject: [PATCH] Instalation works from dir, local repo and remote repo --- install.sh | 14 +++++++++----- lib/zaf.lib.sh | 18 ++++++++++++++---- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/install.sh b/install.sh index 1b74980..b622d62 100755 --- a/install.sh +++ b/install.sh @@ -70,6 +70,10 @@ zaf_getrest(){ zaf_install(){ cp "$1" "$2" +} + +zaf_install_exe(){ + cp "$1" "$2" chmod +x "$2" } @@ -107,7 +111,7 @@ zaf_configure(){ zaf_get_option ZAF_TMP_BASE "Tmp directory prefix (\$USER will be added)" "/tmp/zaf" "$1" zaf_get_option ZAF_LIB_DIR "Libraries directory" "/usr/lib/zaf" "$1" zaf_get_option ZAF_PLUGINS_DIR "Plugins directory" "${ZAF_LIB_DIR}/plugins" "$1" - zaf_get_option ZAF_PLUGINS_REPO "Plugins reposiory" "git://github.com/limosek/zaf-plugins.git" "$1" + zaf_get_option ZAF_PLUGINS_REPO "Plugins reposiory" "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" zaf_get_option ZAF_AGENT_CONFIGD "Zabbix agent config.d" "/etc/zabbix/zabbix_agentd.conf.d/" "$1" @@ -163,14 +167,14 @@ defconf) mkdir -p ${ZAF_TMP_DIR} mkdir -p ${ZAF_LIB_DIR} mkdir -p ${ZAF_PLUGINS_DIR} - zaf_install $(zaf_getrest lib/zaf.lib.sh) ${ZAF_LIB_DIR}/ - zaf_install $(zaf_getrest lib/jshn.sh) ${ZAF_LIB_DIR}/ - zaf_install $(zaf_getrest lib/zaflock) ${ZAF_LIB_DIR}/ + zaf_install $(zaf_getrest lib/zaf.lib.sh) ${ZAF_LIB_DIR}/zaf.lib.sh + zaf_install $(zaf_getrest lib/jshn.sh) ${ZAF_LIB_DIR}/jshn.sh + zaf_install_exe $(zaf_getrest lib/zaflock) ${ZAF_LIB_DIR}/zaflock mkdir -p ${ZAF_TMP_DIR}/p/zaf zaf_install $(zaf_getrest control) ${ZAF_TMP_DIR}/p/zaf/ zaf_install $(zaf_getrest template.xml) ${ZAF_TMP_DIR}/p/zaf/ mkdir -p ${ZAF_PLUGINS_DIR} - zaf_install $(zaf_getrest zaf) /usr/bin/zaf + zaf_install_exe $(zaf_getrest zaf) /usr/bin/zaf /usr/bin/zaf install ${ZAF_TMP_DIR}/p/zaf/ if ! /usr/bin/zaf check-agent-config; then echo "Something is wrong with zabbix agent config." diff --git a/lib/zaf.lib.sh b/lib/zaf.lib.sh index 39a5bf9..adfa079 100644 --- a/lib/zaf.lib.sh +++ b/lib/zaf.lib.sh @@ -17,6 +17,7 @@ trap "rm -rif ${ZAF_TMP_DIR}" EXIT zaf_fetch_url() { local scheme local uri + local insecure scheme=$(echo $1|cut -d ':' -f 1) uri=$(echo $1|cut -d '/' -f 3-) @@ -25,7 +26,8 @@ zaf_fetch_url() { fi case $scheme in http|https|ftp|file) - curl -f -s -L -o - "$1"; + [ "${ZAF_CURL_INSECURE}" = "1" ] && insecure="-k" + curl $insecure -f -s -L -o - "$1"; ;; esac } @@ -181,10 +183,18 @@ zaf_install_plugin() { local plugin local plugindir - if echo "$1" | grep -qv '/'; then - url="${ZAF_REPO_DIR}/$1" + if echo "$1" | grep -q '/'; then + url="$1" # plugin with path - installing from directory else - url="$1" + if echo "$1" | grep -q ^http; then + url="$1" # plugin with http[s] url + else + if [ -d "${ZAF_REPO_DIR}/$1" ]; then + url="${ZAF_REPO_DIR}/$1" + else + url="${ZAF_PLUGINS_REPO}/$1"; + fi + fi fi plugin="plug$$" rm -rf ${ZAF_TMP_DIR}/${plugin}