1
0
mirror of https://github.com/limosek/zaf.git synced 2024-11-13 05:59:06 +01:00

Instalation works from dir, local repo and remote repo

This commit is contained in:
Lukas Macura 2016-03-24 17:46:37 +01:00
parent 29f85902de
commit 254f10834d
2 changed files with 23 additions and 9 deletions

View File

@ -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."

View File

@ -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}