diff options
Diffstat (limited to 'app-metrics/fritzbox_smarthome_exporter/files')
3 files changed, 98 insertions, 0 deletions
diff --git a/app-metrics/fritzbox_smarthome_exporter/files/fritzbox_smarthome_exporter.confd b/app-metrics/fritzbox_smarthome_exporter/files/fritzbox_smarthome_exporter.confd new file mode 100644 index 000000000000..7e70595ec3ce --- /dev/null +++ b/app-metrics/fritzbox_smarthome_exporter/files/fritzbox_smarthome_exporter.confd @@ -0,0 +1,35 @@ +# /etc/conf.d/fritzbox_smarthome_exporter + +# PID file +#EXPORTER_PIDFILE="/run/${RC_SVCNAME}.pid" + +# The termination timeout (start-stop-daemon parameter "retry") ensures +# that the service will be terminated within a given time (60 + 5 seconds +# per default) when you are stopping the service. +#EXPORTER_TERMTIMEOUT="TERM/60/KILL/5" + +# User to run exporter as +#EXPORTER_USER="fritzbox_smarthome_exporter" + +# User group to run exporter as +#EXPORTER_GROUP="fritzbox_smarthome_exporter" + +# You can use this configuration option to pass additional options to the +# start-stop-daemon, see start-stop-daemon(8) for more details. +# Per default we wait 1000ms after we have started the service to ensure +# that the daemon is really up and running. +#EXPORTER_SSDARGS="--wait 1000" + +# Exporter flags +# See `fritzbox_smarthome_exporter --help` for more details. +# For username and password use dedicated variables below. +EXPORTER_FLAGS="-url=\"https://fritz.box\"" +EXPORTER_FLAGS="${EXPORTER_FLAGS} -cert=/path/to/your/FRITZ!box/certificate.pem" + +# FRITZ!Box user +# Restricted user account for the exporter to use to connect to your FRITZ!Box. +FRITZBOX_USERNAME="smarthome_exporter" + +# FRITZ!Box user password +# Password for FRITZBOX_USERNAME (see above). +FRITZBOX_PASSWORD="secret_smarthome_exporter_user_password" diff --git a/app-metrics/fritzbox_smarthome_exporter/files/fritzbox_smarthome_exporter.initd b/app-metrics/fritzbox_smarthome_exporter/files/fritzbox_smarthome_exporter.initd new file mode 100644 index 000000000000..4e5c45954bd4 --- /dev/null +++ b/app-metrics/fritzbox_smarthome_exporter/files/fritzbox_smarthome_exporter.initd @@ -0,0 +1,58 @@ +#!/sbin/openrc-run +# Copyright 2021 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +description="Prometheus exporter for FRITZ!Box Smart Home" + +EXPORTER_FLAGS=${EXPORTER_FLAGS:-""} +EXPORTER_USER=${EXPORTER_USER:-"fritzbox_smarthome_exporter"} +EXPORTER_GROUP=${EXPORTER_GROUP:-"fritzbox_smarthome_exporter"} +EXPORTER_PIDFILE=${EXPORTER_PIDFILE:-"/run/${RC_SVCNAME}.pid"} +EXPORTER_SSDARGS=${EXPORTER_SSDARGS:-"--wait 1000"} +EXPORTER_TERMTIMEOUT=${EXPORTER_TERMTIMEOUT:-"TERM/60/KILL/5"} + +command="/usr/bin/fritzbox_smarthome_exporter" +command_args="${EXPORTER_FLAGS}" +command_background="true" +start_stop_daemon_args="${EXPORTER_SSDARGS}" +start_stop_daemon_args="${start_stop_daemon_args} --user ${EXPORTER_USER}" +start_stop_daemon_args="${start_stop_daemon_args} --group ${EXPORTER_GROUP}" + +start_stop_daemon_args="${start_stop_daemon_args} --stdout /var/log/fritzbox_smarthome_exporter/${RC_SVCNAME}.log" +start_stop_daemon_args="${start_stop_daemon_args} --stderr /var/log/fritzbox_smarthome_exporter/${RC_SVCNAME}.log" + +getconfig() { + local key="$1" + local value_default="$2" + local value= + + if service_started; then + value="$(service_get_value "${key}")" + fi + + if [ -z "${value}" ]; then + # Value not explicitly set + echo "${value_default}" + else + echo "${value}" + fi +} + +pidfile="$(getconfig pidfile ${EXPORTER_PIDFILE})" +retry="$(getconfig retry ${EXPORTER_TERMTIMEOUT})" + +depend() { + after net + use dns +} + +start_pre() { + if [ -n "${FRITZBOX_USERNAME}" ] && [ -n "${FRITZBOX_PASSWORD}" ] ; then + export USERNAME="${FRITZBOX_USERNAME}" + export PASSWORD="${FRITZBOX_PASSWORD}" + fi +} + +start_post() { + service_set_value retry "${EXPORTER_TERMTIMEOUT}" +} diff --git a/app-metrics/fritzbox_smarthome_exporter/files/fritzbox_smarthome_exporter.logrotate b/app-metrics/fritzbox_smarthome_exporter/files/fritzbox_smarthome_exporter.logrotate new file mode 100644 index 000000000000..8d5ee32096c9 --- /dev/null +++ b/app-metrics/fritzbox_smarthome_exporter/files/fritzbox_smarthome_exporter.logrotate @@ -0,0 +1,5 @@ +/var/log/fritzbox_smarthome_exporter/*.log { + missingok + notifempty + size 30k +} |