hassio-zabbix-agent2/rootfs/etc/services.d/zabbix-agent2/run
Paolo Asperti aac9975a01
All checks were successful
continuous-integration/drone/push Build is passing
fix s6
2022-06-13 09:14:07 +02:00

39 lines
907 B
Plaintext
Executable File

#!/usr/bin/with-contenv bashio
# ==============================================================================
# Start zabbix-agent2 service if enabled
# ==============================================================================
set -e
CUSTOM_CFG_PATH=/share/zabbix-agent2
SERVER="$(bashio::config 'server')"
HOSTNAME="$(bashio::config 'hostname')"
if [ ! -d "$CUSTOM_CFG_PATH" ] ; then
bashio::log.info "Creating a folder for custom configuration"
mkdir -p "$CUSTOM_CFG_PATH"
fi
echo "
Server=$SERVER
ServerActive=$SERVER
Hostname=$HOSTNAME
LogType=console
PidFile=/var/run/zabbix/zabbix_agent2.pid
Include=${CUSTOM_CFG_PATH}/*.conf
" > /etc/zabbix/zabbix_agent2.conf
bashio::log.info "Starting zabbix-agent2"
sudo -u zabbix zabbix_agent2 -f &
AGENT_PID=$!
# Register stop
function stop_agent() {
killall zabbix_agent2
exit 0
}
trap "stop_agent" SIGTERM SIGHUP
wait "${AGENT_PID}"