fix
This commit is contained in:
15
telegraf/rootfs/etc/services.d/telegraf/finish
Executable file
15
telegraf/rootfs/etc/services.d/telegraf/finish
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bashio
|
||||
# ==============================================================================
|
||||
# Take down the S6 supervision tree when telegraf fails
|
||||
# s6-overlay docs: https://github.com/just-containers/s6-overlay
|
||||
# ==============================================================================
|
||||
|
||||
declare APP_EXIT_CODE=${1}
|
||||
|
||||
if [[ "${APP_EXIT_CODE}" -ne 0 ]] && [[ "${APP_EXIT_CODE}" -ne 256 ]]; then
|
||||
bashio::log.warning "Halt add-on with exit code ${APP_EXIT_CODE}"
|
||||
echo "${APP_EXIT_CODE}" > /run/s6-linux-init-container-results/exitcode
|
||||
exec /run/s6/basedir/bin/halt
|
||||
fi
|
||||
|
||||
bashio::log.info "Service restart after closing"
|
||||
27
telegraf/rootfs/etc/services.d/telegraf/run
Executable file
27
telegraf/rootfs/etc/services.d/telegraf/run
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Add-on: telegraf
|
||||
# Runs telegraf
|
||||
# ==============================================================================
|
||||
declare log_level
|
||||
bashio::log.info 'Starting telegraf...'
|
||||
bashio::require.unprotected
|
||||
|
||||
CONFIGURATION=$(bashio::config 'configuration.location')
|
||||
bashio::log.info "Using configuration file ${CONFIGURATION}"
|
||||
rm /etc/telegraf/telegraf.conf
|
||||
cp "${CONFIGURATION}" /etc/telegraf/telegraf.conf
|
||||
|
||||
if [ "${1:0:1}" = '-' ]; then
|
||||
set -- telegraf "$@"
|
||||
fi
|
||||
|
||||
if [ $EUID -ne 0 ]; then
|
||||
exec "$@"
|
||||
else
|
||||
# Allow telegraf to send ICMP packets and bind to privliged ports
|
||||
setcap cap_net_raw,cap_net_bind_service+ep /usr/bin/telegraf || echo "Failed to set additional capabilities on /usr/bin/telegraf"
|
||||
|
||||
exec setpriv --reuid root --init-groups "$@"
|
||||
fi
|
||||
Reference in New Issue
Block a user