3 BASE_DIR=$(dirname "$0")
4 DEST_DIR="/usr/local/etc/zabbix/zabbix_agentd.conf.d"
5 ZABBIX_AGENT_OSX="/usr/local/sbin/zabbix_agentd"
7 # Include "ax-common.sh":
8 for dir in "$HOME/lib" "$HOME/.ax" /usr/local /opt/ax /usr; do
9 [ -z "$ax_common_sourced" ] || break
10 ax_common="${dir}/lib/ax/ax-common.sh"
11 [ -r "$ax_common" ] && . "$ax_common"
13 if [ -z "$ax_common_sourced" ]; then
19 unset dir ax_common ax_common_sourced
21 ax_msg - "Building project ..."
22 make all check || exit 1
26 echo "Restarting Zabbix agent ..."
27 ssh root@$1 "chmod -R a+rX '$DEST_DIR'; service zabbix-agent restart"
29 if [ $result -ne 0 ]; then
30 # Try OS X (Homebrew) variant
31 ssh root@$1 "su - admin -c 'pkill zabbix_agentd; $ZABBIX_AGENT_OSX'"
34 if [ $result -eq 0 ]; then
35 ax_msg 0 "Ok, agent restarted."
38 ax_msg 2 "FAILED to restart agent (code $result)!"
43 echo "Fixing sudo configuration file permissions ..."
44 ssh root@$1 "chown 0:0 /etc/sudoers.d/zabbix-extensions; chmod 440 /etc/sudoers.d/zabbix-extensions"
46 if [ $result -eq 0 ]; then
47 ax_msg 0 "Ok, permissions fixed."
50 ax_msg 2 "FAILED to fix sudo configuration permissions (code $result)!"
57 ssh root@$host mkdir -p /usr/local/etc/zabbix/zabbix_agentd.conf.d
59 # Zabbix agent configuration
60 out=$(rsync -rt --delete --log-format=%f -e ssh --exclude Makefile \
61 "$BASE_DIR/etc/zabbix_agentd.conf.d/" \
62 "root@$host:$DEST_DIR"
65 changes=$(printf "%s" "$out" | wc -c)
66 if [ $changes -gt 0 ]; then
67 ax_msg 1 "Ok, updated Zabbix configuration."
70 ax_msg 0 "Ok, no changes for Zabbix configuration."
73 ax_msg 2 "Failed to sync Zabbix configuration to $host!"
77 out=$(rsync -t --log-format=%f -e ssh \
78 "$BASE_DIR/etc/sudoers.d/zabbix-extensions" \
79 "root@$host:/etc/sudoers.d/zabbix-extensions"
82 changes=$(printf "%s" "$out" | wc -c)
83 if [ $changes -gt 0 ]; then
84 ax_msg 1 "Ok, updated sudo configuration."
87 ax_msg 0 "Ok, no changes for sudo configuration."
90 ax_msg 2 "Failed to sync sudo configuration to $host!"