This commit is contained in:
parent
e09df09c87
commit
aac9975a01
@ -3,10 +3,6 @@ FROM $BUILD_FROM
|
|||||||
|
|
||||||
ENV LANG C.UTF-8
|
ENV LANG C.UTF-8
|
||||||
|
|
||||||
# Copy scripts for add-on
|
COPY rootfs /
|
||||||
COPY run.sh /
|
|
||||||
|
|
||||||
RUN apk add -U jq zabbix-agent2=6.0.5-r0 sudo && \
|
RUN apk add -U zabbix-agent2=6.0.5-r0 sudo
|
||||||
chmod a+x /run.sh
|
|
||||||
|
|
||||||
CMD [ "/run.sh" ]
|
|
||||||
|
@ -3,10 +3,6 @@ FROM $BUILD_FROM
|
|||||||
|
|
||||||
ENV LANG C.UTF-8
|
ENV LANG C.UTF-8
|
||||||
|
|
||||||
# Copy scripts for add-on
|
COPY rootfs /
|
||||||
COPY run.sh /
|
|
||||||
|
|
||||||
RUN apk add -U jq zabbix-agent2=6.0.5-r0 sudo && \
|
RUN apk add -U zabbix-agent2=6.0.5-r0 sudo
|
||||||
chmod a+x /run.sh
|
|
||||||
|
|
||||||
CMD [ "/run.sh" ]
|
|
||||||
|
@ -3,10 +3,6 @@ FROM $BUILD_FROM
|
|||||||
|
|
||||||
ENV LANG C.UTF-8
|
ENV LANG C.UTF-8
|
||||||
|
|
||||||
# Copy scripts for add-on
|
COPY rootfs /
|
||||||
COPY run.sh /
|
|
||||||
|
|
||||||
RUN apk add -U jq zabbix-agent2=6.0.5-r0 sudo && \
|
RUN apk add -U zabbix-agent2=6.0.5-r0 sudo
|
||||||
chmod a+x /run.sh
|
|
||||||
|
|
||||||
CMD [ "/run.sh" ]
|
|
||||||
|
8
rootfs/etc/services.d/zabbix-agent2/finish
Executable file
8
rootfs/etc/services.d/zabbix-agent2/finish
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/execlineb -S0
|
||||||
|
# ==============================================================================
|
||||||
|
# Take down the S6 supervision tree when zabbix-agent2 fails
|
||||||
|
# ==============================================================================
|
||||||
|
if { s6-test ${1} -ne 0 }
|
||||||
|
if { s6-test ${1} -ne 256 }
|
||||||
|
|
||||||
|
s6-svscanctl -t /var/run/s6/services
|
38
rootfs/etc/services.d/zabbix-agent2/run
Executable file
38
rootfs/etc/services.d/zabbix-agent2/run
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
#!/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}"
|
22
run.sh
22
run.sh
@ -1,22 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -e
|
|
||||||
|
|
||||||
CONFIG_PATH=/data/options.json
|
|
||||||
CUSTOM_CFG_PATH=/share/zabbix-agent2
|
|
||||||
|
|
||||||
SERVER=$(jq --raw-output ".server" $CONFIG_PATH)
|
|
||||||
HOSTNAME=$(jq --raw-output ".hostname" $CONFIG_PATH)
|
|
||||||
|
|
||||||
if [ ! -d "$CUSTOM_CFG_PATH" ] ; then
|
|
||||||
mkdir -p "$CUSTOM_CFG_PATH"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "
|
|
||||||
Server=$SERVER
|
|
||||||
ServerActive=$SERVER
|
|
||||||
Hostname=$HOSTNAME
|
|
||||||
LogType=console
|
|
||||||
Include=${CUSTOM_CFG_PATH}/*.conf
|
|
||||||
" > /etc/zabbix/zabbix_agent2.conf
|
|
||||||
|
|
||||||
sudo -u zabbix zabbix_agent2 -f
|
|
Loading…
Reference in New Issue
Block a user