From fede35e870eccc8d92161f8f8c530cb077d33ed6 Mon Sep 17 00:00:00 2001 From: Marvin Preuss Date: Wed, 20 Oct 2021 14:33:06 +0200 Subject: [PATCH] build: adds apk, deb, rpm packages with init scripts --- .goreleaser.yml | 27 +++++++++++++++++++++++++++ init/openrc/iperf3exporter.init | 16 ++++++++++++++++ init/systemd/iperf3exporter.service | 14 ++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 init/openrc/iperf3exporter.init create mode 100644 init/systemd/iperf3exporter.service diff --git a/.goreleaser.yml b/.goreleaser.yml index 9634f13..1b25d40 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -58,3 +58,30 @@ dockers: - ghcr.io/xsteadfastx/iperf3exporter:latest - ghcr.io/xsteadfastx/iperf3exporter:{{ .Tag }} - ghcr.io/xsteadfastx/iperf3exporter:v{{ .Major}} + +nfpms: + - formats: + - apk + - deb + - rpm + replacements: + 386: i386 + homepage: https://go.xsfx.dev/iperf3exporter + maintainer: Marvin Preuss + dependencies: + - iperf3 + bindir: /usr/local/bin + contents: + - src: init/openrc/iperf3exporter.init + dst: /etc/init.d/iperf3exporter + packager: apk + file_info: + mode: 0755 + owner: root + group: root + - src: init/systemd/iperf3exporter.service + dst: /etc/systemd/system/iperf3exporter.service + packager: deb + - src: init/systemd/iperf3exporter.service + dst: /etc/systemd/system/iperf3exporter.service + packager: rpm diff --git a/init/openrc/iperf3exporter.init b/init/openrc/iperf3exporter.init new file mode 100644 index 0000000..236c109 --- /dev/null +++ b/init/openrc/iperf3exporter.init @@ -0,0 +1,16 @@ +#!/sbin/openrc-run + +supervisor=supervise-daemon + +name="$RC_SVCNAME" +description="A iperf3 speedtest exporter for prometheus" +command="/usr/local/bin/iperf3exporter" +command_args="--listen=0.0.0.0:9119" +command_user="nobody" +pidfile="/run/$RC_SVCNAME.pid" +command_background="yes" + +depend() { + need net + use dns +} diff --git a/init/systemd/iperf3exporter.service b/init/systemd/iperf3exporter.service new file mode 100644 index 0000000..3d855c3 --- /dev/null +++ b/init/systemd/iperf3exporter.service @@ -0,0 +1,14 @@ +[Unit] +Description=A iperf3 speedtest exporter for prometheus +After=network-online.target nss-lookup.target +Wants=network-online.target nss-lookup.target + +[Service] +Type=simple +User=nobody +Restart=always +RestartSec=1 +ExecStart=/usr/local/bin/iperf3exporter + +[Install] +WantedBy=multi-user.target