mirror of
https://github.com/limosek/zaf.git
synced 2024-11-24 03:19:05 +01:00
Reworked install and shift parameters
This commit is contained in:
parent
1f42c13482
commit
8edce1bc43
@ -51,13 +51,13 @@ Next to this, you can pass ANY zaf config options by *ZAF_* prefix. Interresting
|
|||||||
ZAF_GIT='1'# Default
|
ZAF_GIT='1'# Default
|
||||||
|
|
||||||
# Git repository. Can be your local version
|
# Git repository. Can be your local version
|
||||||
ZAF_PLUGINS_GITURL='https://github.com/limosek/zaf-plugins.git'
|
ZAF_REPO_GITURL='https://github.com/limosek/zaf-plugins.git'
|
||||||
|
|
||||||
# Where to install plugins
|
# Where to install plugins
|
||||||
ZAF_PLUGINS_DIR='/usr/lib/zaf/plugins'
|
ZAF_PLUGINS_DIR='/usr/lib/zaf/plugins'
|
||||||
|
|
||||||
# Plugins can be downloaded from http[s] too
|
# Plugins can be downloaded from http[s] too
|
||||||
ZAF_PLUGINS_URL='https://raw.githubusercontent.com/limosek/zaf-plugins/master/'
|
ZAF_REPO_URL='https://raw.githubusercontent.com/limosek/zaf-plugins/master/'
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ curl -k https://raw.githubusercontent.com/limosek/zaf/1.0/install.sh | sh -s aut
|
|||||||
Z_Server=zabbix.server.local \
|
Z_Server=zabbix.server.local \
|
||||||
Z_ServerActive=zabbix.server.local \
|
Z_ServerActive=zabbix.server.local \
|
||||||
Z_HostnameItem=system.hostname Z_RefreshActiveChecks=60 \
|
Z_HostnameItem=system.hostname Z_RefreshActiveChecks=60 \
|
||||||
ZAF_PLUGINS_GITURL="git://gitserver.local"
|
ZAF_REPO_GITURL="git://gitserver.local"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Packaged version
|
### Packaged version
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
ZAF_PKG='dpkg'
|
|
||||||
ZAF_AGENT_PKG='zabbix-agent'
|
|
||||||
ZAF_TMP_BASE='/tmp/zaf'
|
|
||||||
ZAF_LIB_DIR='/usr/lib/zaf'
|
|
||||||
ZAF_BIN_DIR='/usr/bin'
|
|
||||||
ZAF_PLUGINS_DIR='/usr/lib/zaf/plugins'
|
|
||||||
ZAF_PLUGINS_URL='https://raw.githubusercontent.com/limosek/zaf-plugins/master/'
|
|
||||||
ZAF_PLUGINS_GITURL='https://github.com/limosek/zaf-plugins.git'
|
|
||||||
ZAF_REPO_DIR='/usr/lib/zaf/repo'
|
|
||||||
ZAF_AGENT_CONFIGD='/etc/zabbix/zabbix_agentd.d'
|
|
||||||
ZAF_AGENT_BIN='/usr/sbin/zabbix_agentd'
|
|
||||||
ZAF_AGENT_RESTART='service zabbix-agent restart'
|
|
19
install.sh
19
install.sh
@ -99,9 +99,10 @@ zaf_set_option(){
|
|||||||
local description
|
local description
|
||||||
if ! grep -q "^$1=" ${ZAF_CFG_FILE}; then
|
if ! grep -q "^$1=" ${ZAF_CFG_FILE}; then
|
||||||
echo "$1='$2'" >>${ZAF_CFG_FILE}
|
echo "$1='$2'" >>${ZAF_CFG_FILE}
|
||||||
zaf_dbg "Saving $1 to $2 in ${ZAF_CFG_FILE}" >&2
|
zaf_dbg "Saving $1 to $2 in ${ZAF_CFG_FILE}"
|
||||||
else
|
else
|
||||||
zaf_wrn "Preserving $1 to $2 in ${ZAF_CFG_FILE}" >&2
|
sed -i "s#^$1=\(.*\)#$1='$2'#" ${ZAF_CFG_FILE}
|
||||||
|
zaf_dbg "Changing $1 to $2 in ${ZAF_CFG_FILE}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,8 +216,8 @@ zaf_configure(){
|
|||||||
zaf_get_option ZAF_LIB_DIR "Libraries directory" "/usr/lib/zaf" "$INSTALL_MODE"
|
zaf_get_option ZAF_LIB_DIR "Libraries directory" "/usr/lib/zaf" "$INSTALL_MODE"
|
||||||
zaf_get_option ZAF_BIN_DIR "Directory to put binaries" "/usr/bin" "$INSTALL_MODE"
|
zaf_get_option ZAF_BIN_DIR "Directory to put binaries" "/usr/bin" "$INSTALL_MODE"
|
||||||
zaf_get_option ZAF_PLUGINS_DIR "Plugins directory" "${ZAF_LIB_DIR}/plugins" "$INSTALL_MODE"
|
zaf_get_option ZAF_PLUGINS_DIR "Plugins directory" "${ZAF_LIB_DIR}/plugins" "$INSTALL_MODE"
|
||||||
[ "${ZAF_GIT}" = 1 ] && zaf_get_option ZAF_PLUGINS_GITURL "Git plugins repository" "https://github.com/limosek/zaf-plugins.git" "$INSTALL_MODE"
|
[ "${ZAF_GIT}" = 1 ] && zaf_get_option ZAF_REPO_GITURL "Git plugins repository" "https://github.com/limosek/zaf-plugins.git" "$INSTALL_MODE"
|
||||||
zaf_get_option ZAF_PLUGINS_URL "Plugins http[s] repository" "https://raw.githubusercontent.com/limosek/zaf-plugins/master/" "$INSTALL_MODE"
|
zaf_get_option ZAF_REPO_URL "Plugins http[s] repository" "https://raw.githubusercontent.com/limosek/zaf-plugins/master/" "$INSTALL_MODE"
|
||||||
zaf_get_option ZAF_REPO_DIR "Plugins directory" "${ZAF_LIB_DIR}/repo" "$INSTALL_MODE"
|
zaf_get_option ZAF_REPO_DIR "Plugins directory" "${ZAF_LIB_DIR}/repo" "$INSTALL_MODE"
|
||||||
zaf_get_option ZAF_AGENT_CONFIG "Zabbix agent config" "/etc/zabbix/zabbix_agentd.conf" "$INSTALL_MODE"
|
zaf_get_option ZAF_AGENT_CONFIG "Zabbix agent config" "/etc/zabbix/zabbix_agentd.conf" "$INSTALL_MODE"
|
||||||
! [ -d "${ZAF_AGENT_CONFIGD}" ] && [ -d "/etc/zabbix/zabbix_agentd.d" ] && ZAF_AGENT_CONFIGD="/etc/zabbix/zabbix_agentd.d"
|
! [ -d "${ZAF_AGENT_CONFIGD}" ] && [ -d "/etc/zabbix/zabbix_agentd.d" ] && ZAF_AGENT_CONFIGD="/etc/zabbix/zabbix_agentd.d"
|
||||||
@ -243,15 +244,14 @@ zaf_configure(){
|
|||||||
zaf_set_option ZAF_LIB_DIR "$ZAF_LIB_DIR"
|
zaf_set_option ZAF_LIB_DIR "$ZAF_LIB_DIR"
|
||||||
zaf_set_option ZAF_BIN_DIR "$ZAF_BIN_DIR"
|
zaf_set_option ZAF_BIN_DIR "$ZAF_BIN_DIR"
|
||||||
zaf_set_option ZAF_PLUGINS_DIR "$ZAF_PLUGINS_DIR"
|
zaf_set_option ZAF_PLUGINS_DIR "$ZAF_PLUGINS_DIR"
|
||||||
zaf_set_option ZAF_PLUGINS_URL "$ZAF_PLUGINS_URL"
|
zaf_set_option ZAF_REPO_URL "$ZAF_REPO_URL"
|
||||||
[ "${ZAF_GIT}" = 1 ] && zaf_set_option ZAF_PLUGINS_GITURL "$ZAF_PLUGINS_GITURL"
|
[ "${ZAF_GIT}" = 1 ] && zaf_set_option ZAF_REPO_GITURL "$ZAF_REPO_GITURL"
|
||||||
zaf_set_option ZAF_REPO_DIR "$ZAF_REPO_DIR"
|
zaf_set_option ZAF_REPO_DIR "$ZAF_REPO_DIR"
|
||||||
zaf_set_option ZAF_AGENT_CONFIG "$ZAF_AGENT_CONFIG"
|
zaf_set_option ZAF_AGENT_CONFIG "$ZAF_AGENT_CONFIG"
|
||||||
zaf_set_option ZAF_AGENT_CONFIGD "$ZAF_AGENT_CONFIGD"
|
zaf_set_option ZAF_AGENT_CONFIGD "$ZAF_AGENT_CONFIGD"
|
||||||
zaf_set_option ZAF_AGENT_BIN "$ZAF_AGENT_BIN"
|
zaf_set_option ZAF_AGENT_BIN "$ZAF_AGENT_BIN"
|
||||||
zaf_set_option ZAF_AGENT_RESTART "$ZAF_AGENT_RESTART"
|
zaf_set_option ZAF_AGENT_RESTART "$ZAF_AGENT_RESTART"
|
||||||
[ -n "$ZAF_PREPACKAGED_DIR" ] && zaf_set_option ZAF_PREPACKAGED_DIR "$ZAF_PREPACKAGED_DIR"
|
[ -n "$ZAF_PREPACKAGED_DIR" ] && zaf_set_option ZAF_PREPACKAGED_DIR "$ZAF_PREPACKAGED_DIR"
|
||||||
ZAF_TMP_DIR="${ZAF_TMP_BASE}-${USER}-$$"
|
|
||||||
|
|
||||||
if zaf_is_root; then
|
if zaf_is_root; then
|
||||||
zaf_configure_agent $ZAF_AGENT_OPTIONS "$@"
|
zaf_configure_agent $ZAF_AGENT_OPTIONS "$@"
|
||||||
@ -274,7 +274,6 @@ zaf_install_all() {
|
|||||||
zaf_install_bin $i ${ZAF_BIN_DIR}/
|
zaf_install_bin $i ${ZAF_BIN_DIR}/
|
||||||
done
|
done
|
||||||
zaf_install_dir ${ZAF_PLUGINS_DIR}
|
zaf_install_dir ${ZAF_PLUGINS_DIR}
|
||||||
zaf_install_dir ${ZAF_TMP_DIR}/p/zaf
|
|
||||||
zaf_install_dir ${ZAF_PLUGINS_DIR}
|
zaf_install_dir ${ZAF_PLUGINS_DIR}
|
||||||
zaf_install_dir ${ZAF_BIN_DIR}
|
zaf_install_dir ${ZAF_BIN_DIR}
|
||||||
}
|
}
|
||||||
@ -291,7 +290,7 @@ zaf_postconfigure() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
[ "${ZAF_GIT}" = 1 ] && [ -n "${INSTALL_PREFIX}" ] && git clone "${ZAF_PLUGINS_GITURL}" "${INSTALL_PREFIX}/${ZAF_REPO_DIR}"
|
[ "${ZAF_GIT}" = 1 ] && [ -n "${INSTALL_PREFIX}" ] && git clone "${ZAF_REPO_GITURL}" "${INSTALL_PREFIX}/${ZAF_REPO_DIR}"
|
||||||
fi
|
fi
|
||||||
zaf_wrn "Install done. Use 'zaf' to get started."
|
zaf_wrn "Install done. Use 'zaf' to get started."
|
||||||
true
|
true
|
||||||
@ -300,7 +299,7 @@ zaf_postconfigure() {
|
|||||||
if [ -f "${ZAF_CFG_FILE}" ]; then
|
if [ -f "${ZAF_CFG_FILE}" ]; then
|
||||||
. "${ZAF_CFG_FILE}"
|
. "${ZAF_CFG_FILE}"
|
||||||
fi
|
fi
|
||||||
ZAF_TMP_DIR="${ZAF_TMP_BASE-/tmp/zaf}-${USER}-$$"
|
ZAF_TMP_DIR="/tmp/zaf-installer/"
|
||||||
|
|
||||||
# If debug is on, do not remove tmp dir
|
# If debug is on, do not remove tmp dir
|
||||||
if [ "$ZAF_DEBUG" -le 3 ]; then
|
if [ "$ZAF_DEBUG" -le 3 ]; then
|
||||||
|
@ -71,12 +71,13 @@ zaf_ctrl_get_item_option() {
|
|||||||
zaf_ctrl_check_deps() {
|
zaf_ctrl_check_deps() {
|
||||||
local deps
|
local deps
|
||||||
deps=$(zaf_ctrl_get_global_block <$1 | zaf_block_get_option "Depends-${ZAF_PKG}" )
|
deps=$(zaf_ctrl_get_global_block <$1 | zaf_block_get_option "Depends-${ZAF_PKG}" )
|
||||||
zaf_os_specific zaf_check_deps $deps
|
if ! zaf_os_specific zaf_check_deps $deps; then
|
||||||
|
zaf_err "Missing one of dependend system packages: $deps"
|
||||||
|
fi
|
||||||
deps=$(zaf_ctrl_get_global_block <$1 | zaf_block_get_option "Depends-bin" )
|
deps=$(zaf_ctrl_get_global_block <$1 | zaf_block_get_option "Depends-bin" )
|
||||||
for cmd in $deps; do
|
for cmd in $deps; do
|
||||||
if ! which $cmd >/dev/null; then
|
if ! which $cmd >/dev/null; then
|
||||||
zaf_wrn "Missing binary dependency $cmd. Please install it first."
|
zaf_err "Missing binary dependency $cmd. Please install it first."
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ zaf_check_deps_rpm() {
|
|||||||
zaf_check_deps_opkg() {
|
zaf_check_deps_opkg() {
|
||||||
local p
|
local p
|
||||||
for p in $*; do
|
for p in $*; do
|
||||||
opkg info $p | grep -q 'Package:' || { echo "Missing package $p" >&2; return 1; }
|
opkg info $p | grep -q 'Package:' || { return 1; }
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ zaf_check_deps_opkg() {
|
|||||||
zaf_check_deps_pkg() {
|
zaf_check_deps_pkg() {
|
||||||
local p
|
local p
|
||||||
for p in $*; do
|
for p in $*; do
|
||||||
pkg query -x "Package: %n" $p| grep -q 'Package:' || { echo "Missing package $p" >&2; return 1; }
|
pkg query -x "Package: %n" $p| grep -q 'Package:' || { return 1; }
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,10 +144,10 @@ zaf_check_agent_config() {
|
|||||||
# Update repo
|
# Update repo
|
||||||
zaf_update_repo() {
|
zaf_update_repo() {
|
||||||
[ "$ZAF_GIT" != 1 ] && { zaf_err "Git is disabled or is not installed. Exiting."; }
|
[ "$ZAF_GIT" != 1 ] && { zaf_err "Git is disabled or is not installed. Exiting."; }
|
||||||
if [ -z "${ZAF_PLUGINS_GITURL}" ] || [ -z "${ZAF_REPO_DIR}" ]; then
|
if [ -z "${ZAF_REPO_GITURL}" ] || [ -z "${ZAF_REPO_DIR}" ]; then
|
||||||
zaf_err "This system is not configured for git repository."
|
zaf_err "This system is not configured for git repository."
|
||||||
else
|
else
|
||||||
[ ! -d "${ZAF_REPO_DIR}" ] && git clone "${ZAF_PLUGINS_GITURL}" "${ZAF_REPO_DIR}"
|
[ ! -d "${ZAF_REPO_DIR}" ] && git clone "${ZAF_REPO_GITURL}" "${ZAF_REPO_DIR}"
|
||||||
(cd ${ZAF_REPO_DIR} && git pull)
|
(cd ${ZAF_REPO_DIR} && git pull)
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -171,7 +171,11 @@ zaf_get_plugin_url() {
|
|||||||
if [ -n "${ZAF_PREPACKAGED_DIR}" ] && [ -d "${ZAF_PREPACKAGED_DIR}/$1" ]; then
|
if [ -n "${ZAF_PREPACKAGED_DIR}" ] && [ -d "${ZAF_PREPACKAGED_DIR}/$1" ]; then
|
||||||
url="${ZAF_PREPACKAGED_DIR}/$1"
|
url="${ZAF_PREPACKAGED_DIR}/$1"
|
||||||
else
|
else
|
||||||
zaf_err "Plugin $1 not found."
|
if [ -n "${ZAF_REPO_URL}" ]; then
|
||||||
|
url="${ZAF_REPO_URL}/$1"
|
||||||
|
else
|
||||||
|
zaf_err "Cannot find plugin $1"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -183,6 +187,7 @@ zaf_get_plugin_url() {
|
|||||||
zaf_plugin_info() {
|
zaf_plugin_info() {
|
||||||
local control="$1"
|
local control="$1"
|
||||||
|
|
||||||
|
! [ -f "$control" ] && zaf_err "Control file $control not found."
|
||||||
plugin=$(zaf_ctrl_get_global_block <"${control}" | zaf_block_get_option Plugin)
|
plugin=$(zaf_ctrl_get_global_block <"${control}" | zaf_block_get_option Plugin)
|
||||||
pdescription=$(zaf_ctrl_get_global_block <"${control}" | zaf_block_get_moption Description)
|
pdescription=$(zaf_ctrl_get_global_block <"${control}" | zaf_block_get_moption Description)
|
||||||
pmaintainer=$(zaf_ctrl_get_global_block <"${control}" | zaf_block_get_option Maintainer)
|
pmaintainer=$(zaf_ctrl_get_global_block <"${control}" | zaf_block_get_option Maintainer)
|
||||||
@ -209,7 +214,7 @@ zaf_prepare_plugin() {
|
|||||||
local plugindir
|
local plugindir
|
||||||
local control
|
local control
|
||||||
|
|
||||||
url=$(zaf_get_plugin_url "$1")/control.zaf
|
url=$(zaf_get_plugin_url "$1")/control.zaf || exit $?
|
||||||
plugindir="$2"
|
plugindir="$2"
|
||||||
control=${plugindir}/control.zaf
|
control=${plugindir}/control.zaf
|
||||||
zaf_install_dir "$plugindir"
|
zaf_install_dir "$plugindir"
|
||||||
@ -217,7 +222,7 @@ zaf_prepare_plugin() {
|
|||||||
if zaf_fetch_url "$url" >"${control}"; then
|
if zaf_fetch_url "$url" >"${control}"; then
|
||||||
zaf_ctrl_check_deps "${control}"
|
zaf_ctrl_check_deps "${control}"
|
||||||
else
|
else
|
||||||
zaf_err "Cannot fetch or write control file!"
|
zaf_err "prepare_plugin: Cannot fetch or write control file $control from url $url!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,7 +236,7 @@ zaf_install_plugin() {
|
|||||||
url=$(zaf_get_plugin_url "$1")
|
url=$(zaf_get_plugin_url "$1")
|
||||||
plugin=$(zaf_ctrl_get_global_block <"${ZAF_TMP_DIR}/plugin/control.zaf" | zaf_block_get_option Plugin)
|
plugin=$(zaf_ctrl_get_global_block <"${ZAF_TMP_DIR}/plugin/control.zaf" | zaf_block_get_option Plugin)
|
||||||
plugindir="${ZAF_PLUGINS_DIR}"/$plugin
|
plugindir="${ZAF_PLUGINS_DIR}"/$plugin
|
||||||
if zaf_prepare_plugin "$1" $plugindir; then
|
if [ -n "$plugin" ] && zaf_prepare_plugin "$1" $plugindir; then
|
||||||
control=${plugindir}/control.zaf
|
control=${plugindir}/control.zaf
|
||||||
[ "$ZAF_DEBUG" -gt 0 ] && zaf_plugin_info "${control}"
|
[ "$ZAF_DEBUG" -gt 0 ] && zaf_plugin_info "${control}"
|
||||||
zaf_ctrl_check_deps "${control}"
|
zaf_ctrl_check_deps "${control}"
|
||||||
@ -240,7 +245,7 @@ zaf_install_plugin() {
|
|||||||
| zaf_far '{PLUGINDIR}' "${plugindir}" >${ZAF_AGENT_CONFIGD}/zaf_${plugin}.conf
|
| zaf_far '{PLUGINDIR}' "${plugindir}" >${ZAF_AGENT_CONFIGD}/zaf_${plugin}.conf
|
||||||
zaf_dbg "Generated ${ZAF_AGENT_CONFIGD}/zaf_${plugin}.conf"
|
zaf_dbg "Generated ${ZAF_AGENT_CONFIGD}/zaf_${plugin}.conf"
|
||||||
else
|
else
|
||||||
zaf_err "Cannot install plugin $plugin to $plugindir!"
|
zaf_err "Cannot install plugin '$plugin' to $plugindir!"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
zaf_err "Cannot prepare plugin $1"
|
zaf_err "Cannot prepare plugin $1"
|
||||||
|
80
zaf
80
zaf
@ -19,6 +19,7 @@ done
|
|||||||
[ -z "$ZAF_TMP_BASE" ] && ZAF_TMP_BASE=/tmp/zaf
|
[ -z "$ZAF_TMP_BASE" ] && ZAF_TMP_BASE=/tmp/zaf
|
||||||
ZAF_TMP_DIR="${ZAF_TMP_BASE}-${USER}"
|
ZAF_TMP_DIR="${ZAF_TMP_BASE}-${USER}"
|
||||||
[ -z "$ZAF_DEBUG" ] && ZAF_DEBUG=1
|
[ -z "$ZAF_DEBUG" ] && ZAF_DEBUG=1
|
||||||
|
export ZAF_DEBUG
|
||||||
|
|
||||||
# If debug is on, do not remove tmp dir
|
# If debug is on, do not remove tmp dir
|
||||||
if [ "$ZAF_DEBUG" -le 3 ]; then
|
if [ "$ZAF_DEBUG" -le 3 ]; then
|
||||||
@ -39,6 +40,25 @@ else
|
|||||||
[ -f ${ZAF_LIB_DIR}/zaf.${ZAF_OS}.sh ] && . ${ZAF_LIB_DIR}/zaf.${ZAF_OS}.sh
|
[ -f ${ZAF_LIB_DIR}/zaf.${ZAF_OS}.sh ] && . ${ZAF_LIB_DIR}/zaf.${ZAF_OS}.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
zaf_shift(){
|
||||||
|
local s
|
||||||
|
|
||||||
|
if echo $1 |grep -q "="; then
|
||||||
|
if echo $2 |grep -q "="; then
|
||||||
|
if echo $3 |grep -q "="; then
|
||||||
|
s=3
|
||||||
|
else
|
||||||
|
s=2
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
s=1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
s=0
|
||||||
|
fi
|
||||||
|
echo $s
|
||||||
|
}
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
|
|
||||||
check-agent-config)
|
check-agent-config)
|
||||||
@ -46,24 +66,25 @@ check-agent-config)
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
update)
|
update)
|
||||||
zaf_wrn "Updating repository ${ZAF_PLUGINS_GITURL}..."
|
zaf_wrn "Updating repository ${ZAF_REPO_GITURL}..."
|
||||||
zaf_update_repo
|
zaf_update_repo
|
||||||
;;
|
;;
|
||||||
|
|
||||||
show)
|
show)
|
||||||
if [ -z "$2" ]; then
|
shift $(zaf_shift "$@")
|
||||||
|
if [ -z "$1" ]; then
|
||||||
zaf_list_plugins | while read plugin; do
|
zaf_list_plugins | while read plugin; do
|
||||||
zaf_plugin_info $ZAF_PLUGINS_DIR/$plugin/control.zaf
|
zaf_plugin_info $ZAF_PLUGINS_DIR/$plugin/control.zaf
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
if zaf_list_plugins | grep -q "^$2"; then
|
if zaf_list_plugins | grep -q "^$1"; then
|
||||||
zaf_plugin_info $ZAF_PLUGINS_DIR/$2/control.zaf
|
[ -f $ZAF_PLUGINS_DIR/$1/control.zaf ] && zaf_plugin_info $ZAF_PLUGINS_DIR/$1/control.zaf || zaf_err "Plugin $1 not installed."
|
||||||
else
|
else
|
||||||
if echo $2 |grep -q ^http; then
|
if echo $1 |grep -q ^http; then
|
||||||
zaf_prepare_plugin "$2" "$ZAF_TMP_DIR/plugin"
|
zaf_prepare_plugin "$1" "$ZAF_TMP_DIR/plugin"
|
||||||
zaf_plugin_info "$ZAF_TMP_DIR/plugin/control.zaf"
|
zaf_plugin_info "$ZAF_TMP_DIR/plugin/control.zaf"
|
||||||
else
|
else
|
||||||
zaf_err "Plugin $2 not installed."
|
zaf_err "Plugin $1 not installed."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -74,37 +95,39 @@ plugins)
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
items)
|
items)
|
||||||
if [ -z "$2" ]; then
|
shift $(zaf_shift "$@")
|
||||||
|
if [ -z "$1" ]; then
|
||||||
zaf_list_items
|
zaf_list_items
|
||||||
else
|
else
|
||||||
zaf_list_plugin_items "$2"
|
zaf_list_plugin_items "$1"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
test)
|
test)
|
||||||
if echo $2|grep -q '\.'; then
|
shift $(zaf_shift "$@")
|
||||||
zaf_test_item "$2"
|
if echo $1|grep -q '\.'; then
|
||||||
|
zaf_test_item "$1"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
if [ -n "$2" ]; then
|
if [ -n "$1" ]; then
|
||||||
shift
|
|
||||||
plugins="$@"
|
plugins="$@"
|
||||||
else
|
else
|
||||||
plugins="$(zaf_list_plugins)"
|
plugins="$(zaf_list_plugins)"
|
||||||
fi
|
fi
|
||||||
for p in $plugins; do
|
for p in $plugins; do
|
||||||
|
! zaf_is_plugin $p && zaf_err "Unknown plugin $p"
|
||||||
for i in $(zaf_list_plugin_items $p); do
|
for i in $(zaf_list_plugin_items $p); do
|
||||||
echo $i: $(zaf_test_item $i)
|
echo $i: $(zaf_test_item $i)
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
get)
|
get)
|
||||||
if echo $2|grep -q '\.'; then
|
shift $(zaf_shift "$@")
|
||||||
zaf_get_item "$2"
|
if echo $1|grep -q '\.'; then
|
||||||
|
zaf_get_item "$1"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
if [ -n "$2" ]; then
|
if [ -n "$1" ]; then
|
||||||
shift
|
|
||||||
plugins="$@"
|
plugins="$@"
|
||||||
else
|
else
|
||||||
plugins="$(zaf_list_plugins)"
|
plugins="$(zaf_list_plugins)"
|
||||||
@ -116,7 +139,7 @@ get)
|
|||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
install)
|
install)
|
||||||
shift;
|
shift $(zaf_shift "$@")
|
||||||
[ -z "$1" ] && echo "$0 install plugin [plugin]..."
|
[ -z "$1" ] && echo "$0 install plugin [plugin]..."
|
||||||
for p in $@; do
|
for p in $@; do
|
||||||
if zaf_is_plugin "$p"; then
|
if zaf_is_plugin "$p"; then
|
||||||
@ -130,7 +153,8 @@ install)
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
reinstall)
|
reinstall)
|
||||||
shift;
|
shift $(zaf_shift "$@")
|
||||||
|
shift
|
||||||
[ -z "$1" ] && echo "$0 reinstall plugin [plugin]..."
|
[ -z "$1" ] && echo "$0 reinstall plugin [plugin]..."
|
||||||
for p in $@; do
|
for p in $@; do
|
||||||
if zaf_is_plugin "$p"; then
|
if zaf_is_plugin "$p"; then
|
||||||
@ -144,7 +168,7 @@ reinstall)
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
remove)
|
remove)
|
||||||
shift;
|
shift $(zaf_shift "$@")
|
||||||
[ -z "$1" ] && echo "$0 remove plugin [plugin]..."
|
[ -z "$1" ] && echo "$0 remove plugin [plugin]..."
|
||||||
for p in $@; do
|
for p in $@; do
|
||||||
if zaf_is_plugin "$p"; then
|
if zaf_is_plugin "$p"; then
|
||||||
@ -156,26 +180,23 @@ remove)
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
self-upgrade)
|
self-upgrade)
|
||||||
|
shift $(zaf_shift "$@")
|
||||||
zaf_os_specific zaf_check_deps zaf && zaf_err "Zaf is installed as system package. Cannot self-upgrade."
|
zaf_os_specific zaf_check_deps zaf && zaf_err "Zaf is installed as system package. Cannot self-upgrade."
|
||||||
rm -rf /tmp/zaf-installer && mkdir /tmp/zaf-installer
|
rm -rf /tmp/zaf-installer && mkdir /tmp/zaf-installer
|
||||||
if ! which curl >/dev/null;
|
if ! which curl >/dev/null;
|
||||||
then
|
then
|
||||||
zaf_err "Curl not found. Cannot continue. Please install it."
|
zaf_err "Curl not found. Cannot continue. Please install it."
|
||||||
fi
|
fi
|
||||||
[ -z "$2" ] && auto=auto
|
[ -z "$1" ] && auto=auto
|
||||||
set -e
|
zaf_fetch_url $ZAF_URL/$ZAF_VERSION/install.sh | exec sh -s "$@"
|
||||||
mkdir -p /tmp/zaf-installer \
|
|
||||||
&& cd /tmp/zaf-installer \
|
|
||||||
&& (for i in lib/zaf.lib.sh lib/os.lib.sh lib/ctrl.lib.sh install.sh ; do echo curl -f -k -s -L -o - "$ZAF_URL/$i" >&2; curl -f -k -s -L -o - "$ZAF_URL/$i"; done) >install.sh \
|
|
||||||
&& chmod +x install.sh \
|
|
||||||
&& exec ./install.sh $auto "$@"
|
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
self-remove)
|
self-remove)
|
||||||
|
shift $(zaf_shift "$@")
|
||||||
zaf_os_specific zaf_check_deps zaf && zaf_err "Zaf is installed as system package. Cannot self-remove."
|
zaf_os_specific zaf_check_deps zaf && zaf_err "Zaf is installed as system package. Cannot self-remove."
|
||||||
. /etc/zaf.conf
|
. /etc/zaf.conf
|
||||||
if [ "$2" = "force" ]; then
|
if [ "$1" = "force" ]; then
|
||||||
rm -rf /etc/zaf.conf ${ZAF_PLUGINS_DIR} ${ZAF_REPO_DIR} ${ZAF_LIB_DIR} \
|
rm -rf /etc/zaf.conf ${ZAF_PLUGINS_DIR} ${ZAF_REPO_DIR} ${ZAF_LIB_DIR} \
|
||||||
${ZAF_BIN_DIR}/zaf ${ZAF_AGENT_CONFIGD}/zaf_*
|
${ZAF_BIN_DIR}/zaf ${ZAF_AGENT_CONFIGD}/zaf_*
|
||||||
else
|
else
|
||||||
@ -190,6 +211,8 @@ self-remove)
|
|||||||
|
|
||||||
*)
|
*)
|
||||||
echo "$0 Version ${ZAF_VERSION}. Please use some of this commands:"
|
echo "$0 Version ${ZAF_VERSION}. Please use some of this commands:"
|
||||||
|
echo "$0 Cmd [ZAF_OPTION=value] ..."
|
||||||
|
echo "Commands:"
|
||||||
echo "$0 update To update repo"
|
echo "$0 update To update repo"
|
||||||
echo "$0 plugins To list installed plugins"
|
echo "$0 plugins To list installed plugins"
|
||||||
echo "$0 show [plugin] To show installed plugins or plugin info"
|
echo "$0 show [plugin] To show installed plugins or plugin info"
|
||||||
@ -200,6 +223,7 @@ self-remove)
|
|||||||
echo "$0 remove plugin To remove plugin"
|
echo "$0 remove plugin To remove plugin"
|
||||||
echo "$0 self-upgrade To self-upgrade zaf"
|
echo "$0 self-upgrade To self-upgrade zaf"
|
||||||
echo "$0 self-remove To self-remove zaf and its config"
|
echo "$0 self-remove To self-remove zaf and its config"
|
||||||
|
echo
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user