From 7fa147cba36f014832cebf9e1aee7e03786d4ddf Mon Sep 17 00:00:00 2001 From: Emmanuel Vadot Date: Fri, 15 Nov 2024 08:24:48 +0100 Subject: [PATCH] net-mgmt/mqtt2prometheus: Update to 0.1.7 While here add a rc.d script. --- net-mgmt/mqtt2prometheus/Makefile | 4 +- net-mgmt/mqtt2prometheus/distinfo | 6 +- .../mqtt2prometheus/files/mqtt2prometheus | 80 +++++++++++++++++++ 3 files changed, 85 insertions(+), 5 deletions(-) create mode 100755 net-mgmt/mqtt2prometheus/files/mqtt2prometheus diff --git a/net-mgmt/mqtt2prometheus/Makefile b/net-mgmt/mqtt2prometheus/Makefile index cabd88dcea86..1c10b8c0a6c5 100644 --- a/net-mgmt/mqtt2prometheus/Makefile +++ b/net-mgmt/mqtt2prometheus/Makefile @@ -1,7 +1,6 @@ PORTNAME= mqtt2prometheus DISTVERSIONPREFIX= v -DISTVERSION= 0.1.6 -PORTREVISION= 22 +DISTVERSION= 0.1.7 CATEGORIES= net-mgmt MAINTAINER= manu@FreeBSD.org @@ -55,5 +54,6 @@ post-extract: post-install: ${MKDIR} ${STAGEDIR}${PREFIX}/etc/mqtt2prometheus/ ${INSTALL_DATA} ${WRKSRC}/config.yaml.dist ${STAGEDIR}${PREFIX}/etc/mqtt2prometheus/ + ${INSTALL_SCRIPT} ${FILESDIR}/${PORTNAME} ${STAGEDIR}${PREFIX}/etc/rc.d .include diff --git a/net-mgmt/mqtt2prometheus/distinfo b/net-mgmt/mqtt2prometheus/distinfo index d2086341d835..5ef24a4272b8 100644 --- a/net-mgmt/mqtt2prometheus/distinfo +++ b/net-mgmt/mqtt2prometheus/distinfo @@ -1,6 +1,6 @@ -TIMESTAMP = 1679877009 -SHA256 (hikhvar-mqtt2prometheus-v0.1.6_GH0.tar.gz) = 61b046469b76411641d4fcb4d56ac29b4e86b4374111da60b988de91267df848 -SIZE (hikhvar-mqtt2prometheus-v0.1.6_GH0.tar.gz) = 59608 +TIMESTAMP = 1731654699 +SHA256 (hikhvar-mqtt2prometheus-v0.1.7_GH0.tar.gz) = 77e59fc04a522bcf08d8380a75021f5cda008067e50435dbe24b4c85155c20fc +SIZE (hikhvar-mqtt2prometheus-v0.1.7_GH0.tar.gz) = 69807 SHA256 (beorn7-perks-v1.0.1_GH0.tar.gz) = 98db84bb0224a26094e6adba91b7ee7a1a7ace28cb648d818f8e779e6a19f825 SIZE (beorn7-perks-v1.0.1_GH0.tar.gz) = 10867 SHA256 (eclipse-paho.mqtt.golang-v1.3.5_GH0.tar.gz) = 9cfb8872e5f6347ec5e669791f28339a9f404f65ec7ad6bee341ce5b399065b9 diff --git a/net-mgmt/mqtt2prometheus/files/mqtt2prometheus b/net-mgmt/mqtt2prometheus/files/mqtt2prometheus new file mode 100755 index 000000000000..919239b8908a --- /dev/null +++ b/net-mgmt/mqtt2prometheus/files/mqtt2prometheus @@ -0,0 +1,80 @@ +#!/bin/sh + +# PROVIDE: mqtt2prometheus +# REQUIRE: DAEMON +# KEYWORD: shutdown + +# This script supports running multiple instances of mqtt2prometheus. +# To run additional instances link this script to something like +# % ln -s mqtt2prometheus mqtt2prometheus_foo +# and define additional mqtt2prometheus_foo_* variables in one of +# /etc/rc.conf, /etc/rc.conf.local or /etc/rc.conf.d/mqtt2prometheus_foo + +. /etc/rc.subr + +name="${file}" + +case "$0" in +/etc/rc*) + name="$_file" + ;; +*/service) + ;; +*) + name="$0" + ;; +esac + +name="${name:-mqtt2prometheus}" ; +name="${name##*/}" +rcvar=${name}_enable + +load_rc_config $name + +eval ": \${${name}_enable:=\"NO\"}" +eval ": \${${name}_user:=\"nobody\"}" +eval ": \${${name}_group:=\"nobody\"}" +eval ": \${${name}_config:=\"/usr/local/etc/mqtt2prometheus.yaml\"}" +eval ": \${${name}_pidfile:=\"/var/run/mqtt2prometheus.pid\"}" +eval ": \${${name}_listen_address:=\"0.0.0.0\"}" +eval ": \${${name}_listen_port:=\"9641\"}" +eval ": \${${name}_loglevel:=\"info\"}" +eval ": \${${name}_logformat:=\"console\"}" +eval ": \${${name}_logfile:=\"/var/log/mqtt2prometheus.log\"}" + +pidfile="$(eval echo \${${name}_pidfile})" +required_files="$(eval echo \${${name}_config})" +m2p_user="$(eval echo \${${name}_user})" +m2p_group="$(eval echo \${${name}_group})" +m2p_config="$(eval echo \${${name}_config})" +m2p_listen_address="$(eval echo \${${name}_listen_address})" +m2p_listen_port="$(eval echo \${${name}_listen_port})" +m2p_loglevel="$(eval echo \${${name}_loglevel})" +m2p_logformat="$(eval echo \${${name}_logformat})" +m2p_logfile="$(eval echo \${${name}_logfile})" + +procname="/usr/local/bin/mqtt2prometheus" +command="/usr/sbin/daemon" +command_args="-p ${pidfile} -t ${name} -o ${m2p_logfile} \ + /usr/bin/env ${mqtt2prometheus_env} ${procname} \ + -config ${m2p_config} \ + -listen-address ${m2p_listen_address} \ + -listen-port ${m2p_listen_port} \ + --log-level ${m2p_loglevel} \ + --log-format ${m2p_logformat} \ + ${mqtt2prometheus_args}" + +start_precmd="mqtt2prometheus_start_precmd" + +mqtt2prometheus_start_precmd() +{ + if [ ! -e "${pidfile}" ]; then + install -m 0600 -o ${m2p_user} -g ${m2p_group} /dev/null "${pidfile}" + fi + + if [ ! -e "${mqtt2prometheus_logfile}" ]; then + install -m 0600 -o ${m2p_user} -g ${m2p_group} /dev/null "${m2p_logfile}" + fi +} + +run_rc_command "$1"