From 325ca00bce61d0aef8d1bb8fb641145d987c0422 Mon Sep 17 00:00:00 2001 From: Christoph Petrausch Date: Mon, 22 Feb 2021 19:22:43 +0100 Subject: [PATCH] Add debian packages --- .goreleaser.yml | 25 +++++++++++++++++++++++++ systemd/mqtt2prometheus.service | 8 +++++++- systemd/postinstall.sh | 6 ++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100755 systemd/postinstall.sh diff --git a/.goreleaser.yml b/.goreleaser.yml index 7f7899b..646f414 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -64,6 +64,31 @@ changelog: exclude: - '^docs:' - '^test:' + - '^ci:' + +nfpms: + - id: default + vendor: Christoph Petrausch + homepage: https://github.com/hikhvar/mqtt2prometheus + description: This exporter translates from MQTT topics to prometheus metrics. + license: MIT License + formats: + - deb + - rpm + - apk + conflicts: + - prometheus-mqtt-exporter + scripts: + postinstall: systemd/postinstall.sh + contents: + # Simple config file + - src: config.yaml.dist + dst: /etc/mqtt2prometheus/config.yaml + type: config + - src: ./systemd/mqtt2prometheus.service + dst: /etc/systemd/system/mqtt2prometheus.service + type: config + dockers: diff --git a/systemd/mqtt2prometheus.service b/systemd/mqtt2prometheus.service index e9c8394..ec669ae 100644 --- a/systemd/mqtt2prometheus.service +++ b/systemd/mqtt2prometheus.service @@ -1,9 +1,15 @@ [Unit] Description=Simple translator from mqtt messages to prometheus. Analog to pushgateway +Documentation=https://github.com/hikhvar/mqtt2prometheus Before=prometheus.service [Service] -ExecStart=/opt/mqtt2prometheus/mqtt2prometheus -config /etc/mqtt2prometheus/config.yaml -port 8002 +Restart=always +User=mqtt2prometheus +EnvironmentFile=/etc/default/prometheus-mqtt-exporter +ExecStart=/opt/mqtt2prometheus/mqtt2prometheus -config /etc/mqtt2prometheus/config.yaml $ARGS +TimeoutStopSec=20s + [Install] WantedBy=multi-user.target diff --git a/systemd/postinstall.sh b/systemd/postinstall.sh new file mode 100755 index 0000000..636b27e --- /dev/null +++ b/systemd/postinstall.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +user=mqtt2prometheus +if ! getent passwd "${user}" > /dev/null; then + useradd --system --home-dir /var/lib/${user} --no-create-home || true +fi \ No newline at end of file