diff --git a/install.sh b/install.sh index 239ad2a..92b033d 100755 --- a/install.sh +++ b/install.sh @@ -172,11 +172,9 @@ defconf) 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_exe $(zaf_getrest zaf) /usr/bin/zaf - /usr/bin/zaf install ${ZAF_TMP_DIR}/p/zaf/ + /usr/bin/zaf install zaf if ! /usr/bin/zaf check-agent-config; then echo "Something is wrong with zabbix agent config." echo "Ensure that zabbix_agentd reads ${ZAF_AGENT_CONFIG}" diff --git a/lib/zaf.lib.sh b/lib/zaf.lib.sh index adfa079..ca9b985 100644 --- a/lib/zaf.lib.sh +++ b/lib/zaf.lib.sh @@ -11,6 +11,10 @@ trap "rm -rif ${ZAF_TMP_DIR}" EXIT ############################################ Common routines +zaf_msg() { + [ "$ZAF_DEBUG" = "1" ] && echo $@ +} + # Fetch url to stdout # $1 url # It supports real file, file:// and other schemes known by curl @@ -27,6 +31,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" curl $insecure -f -s -L -o - "$1"; ;; esac @@ -219,7 +224,7 @@ zaf_install_plugin() { cp $control "$plugindir"/ zaf_fetch_url $url/template.xml >"$plugindir"/template.xml else - echo "Bad control file!" + echo "Bad control file $control ($url)!" cat $control exit 4 fi @@ -274,8 +279,11 @@ zaf_show_plugin() { echo echo "Supported items:" for i in $items; do - echo -n "$1.$i: " - [ -n "$tst" ] && ${ZAF_AGENT_BIN} -t "$1.$i" + if [ -n "$tst" ]; then + ${ZAF_AGENT_BIN} -t "$1.$i" + else + echo -n "$1.$i: " + fi echo zaf_ctrl_get_description "$cfile" "Item: $i"; echo diff --git a/zaf b/zaf index 9704e9a..6b71bf5 100755 --- a/zaf +++ b/zaf @@ -54,6 +54,15 @@ remove) self-upgrade) curl -s https://raw.githubusercontent.com/limosek/zaf/master/install.sh | sh ;; + +self-remove) + if [ "$2" = "force" ]; then + rm -rf /etc/zaf.conf ${ZAF_PLUGINS_DIR} ${ZAF_REPO_DIR} ${ZAF_LIB_DIR} /usr/bin/zaf ${ZAF_AGENT_CONFIGD}/zap_* + else + echo "This will remove zaf from this computer and erase all configuration." + echo "To continue, please do $0 self-remove force" + fi + ;; *) echo "$0 update To update repo"