Subject: [PATCH v2] testing/speedtest_exporter: new aport

From: Marvin Preuss <[email-masked]>
Date: Wed, 29 Sep 2021 13:59:32 +0200

---
 ...0001-Fix-log.Infof-format-test-error.patch | 34 +++++++++++++++
 testing/speedtest_exporter/APKBUILD           | 43 +++++++++++++++++++
 .../speedtest_exporter.confd                  |  3 ++
 .../speedtest_exporter.initd                  | 14 ++++++
 .../speedtest_exporter.pre-install            |  6 +++
 5 files changed, 100 insertions(+)
 create mode 100644 testing/speedtest_exporter/0001-Fix-log.Infof-format-test-error.patch
 create mode 100644 testing/speedtest_exporter/APKBUILD
 create mode 100644 testing/speedtest_exporter/speedtest_exporter.confd
 create mode 100644 testing/speedtest_exporter/speedtest_exporter.initd
 create mode 100644 testing/speedtest_exporter/speedtest_exporter.pre-install

diff --git a/testing/speedtest_exporter/0001-Fix-log.Infof-format-test-error.patch b/testing/speedtest_exporter/0001-Fix-log.Infof-format-test-error.patch
new file mode 100644
index 0000000000..506960048b
--- /dev/null
+++ b/testing/speedtest_exporter/0001-Fix-log.Infof-format-test-error.patch
@@ -0,0 +1,34 @@
+From 3354a01f768acc7efe8bef29d40c6756e39b9cff Mon Sep 17 00:00:00 2001
+From: Marvin Preuss <[email-masked]>
+Date: Wed, 29 Sep 2021 12:12:02 +0200
+Subject: [PATCH] Fix: log.Infof format test error
+
+Signed-off-by: Marvin Preuss <[email-masked]>
+---
+ speedtest/client.go | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/speedtest/client.go b/speedtest/client.go
+index 1a0ef92..3dd181a 100644
+--- a/speedtest/client.go
++++ b/speedtest/client.go
+@@ -74,7 +74,7 @@ func NewClient(configURL string, serversURL string) (*Client, error) {
+ 	closestServers := stClient.GetClosestServers(allServers)
+ 	// log.Infof("Closest Servers: %s", closestServers)
+ 	testServer := stClient.GetFastestServer(closestServers)
+-	log.Infof("Test server: %s", testServer)
++	log.Infof("Test server: %v", testServer)
+ 
+ 	return &Client{
+ 		Server:          testServer,
+@@ -101,6 +101,6 @@ func (client *Client) NetworkMetrics() map[string]float64 {
+ 	result["download"] = downloadMbps
+ 	result["upload"] = uploadMbps
+ 	result["ping"] = ping
+-	log.Infof("Speedtest results: %s", result)
++	log.Infof("Speedtest results: %v", result)
+ 	return result
+ }
+-- 
+2.33.0
+
diff --git a/testing/speedtest_exporter/APKBUILD b/testing/speedtest_exporter/APKBUILD
new file mode 100644
index 0000000000..a484c0615a
--- /dev/null
+++ b/testing/speedtest_exporter/APKBUILD
@@ -0,0 +1,43 @@
+# Contributor: Marvin Preuss <[email-masked]>
+# Maintainer: Marvin Preuss <[email-masked]>
+pkgname=speedtest_exporter
+pkgver=0.3.1
+pkgrel=0
+pkgdesc="Prometheus exporter for Speedtest metrics"
+url="https://github.com/nlamirault/speedtest_exporter"
+arch="all"
+license="Apache-2.0"
+makedepends="bash go make"
+checkdepends="glide"
+install="$pkgname.pre-install"
+pkgusers="speedtest-exporter"
+pkggroups="speedtest-exporter"
+source="
+	$pkgname-$pkgver.tar.gz::https://github.com/nlamirault/speedtest_exporter/archive/v$pkgver.tar.gz
+	$pkgname.initd
+	$pkgname.confd
+	0001-Fix-log.Infof-format-test-error.patch
+	"
+
+build() {
+	make build
+}
+
+check() {
+	make test
+}
+
+package() {
+	install -Dm755 speedtest_exporter "$pkgdir"/usr/bin/speedtest_exporter
+
+	install -Dm755 "$srcdir"/$pkgname.initd \
+		"$pkgdir"/etc/init.d/$pkgname
+	install -Dm644 "$srcdir"/$pkgname.confd \
+		"$pkgdir"/etc/conf.d/$pkgname
+}
+sha512sums="
+cb6073ca622e8df2b8436a2e30af2c9c7c99be6d950d4383de014c000e279a1ea0394bed3097754f24923859bbc2d5ebf20787eb90417c15aad35a0b88b64161  speedtest_exporter-0.3.1.tar.gz
+29fa32f35accbc8f26864258c957e1dbaf03e54b68c2361ba2c664fca65de8cfeac971ed96e48b0d556611f7af041b1f4711a36e189a3e746fc2a22cecece2fb  speedtest_exporter.initd
+5110af642337757b6dd7abc3d9051f2f46256300cf6d8d29e94b5a3acc4fc7920e0d498f568e1831ce4821c8550d8752875a3077df5cc03b40b2282742e924df  speedtest_exporter.confd
+fb38b8ac3b033e89c01180a171c108695e63ce2ca697b8e4fd199a7d4efd328890451ecfcda570361ea19573d4690235982245ca2493e9907d3d04944e208b81  0001-Fix-log.Infof-format-test-error.patch
+"
diff --git a/testing/speedtest_exporter/speedtest_exporter.confd b/testing/speedtest_exporter/speedtest_exporter.confd
new file mode 100644
index 0000000000..9f98a72b02
--- /dev/null
+++ b/testing/speedtest_exporter/speedtest_exporter.confd
@@ -0,0 +1,3 @@
+# Configuration for /etc/init.d/speedtest_exporter
+
+speedtest_exporter_opts="-web.listen-address 0.0.0.0:9112"
diff --git a/testing/speedtest_exporter/speedtest_exporter.initd b/testing/speedtest_exporter/speedtest_exporter.initd
new file mode 100644
index 0000000000..b51977a183
--- /dev/null
+++ b/testing/speedtest_exporter/speedtest_exporter.initd
@@ -0,0 +1,14 @@
+#!/sbin/openrc-run
+supervisor=supervise-daemon
+
+name=speedtest_exporter
+description="Prometheus exporter for Speedtest metrics"
+
+command=/usr/bin/speedtest_exporter
+command_args="$speedtest_exporter_opts"
+command_user="speedtest-exporter:speedtest-exporter"
+
+depend() {
+	need net
+	after firewall
+}
diff --git a/testing/speedtest_exporter/speedtest_exporter.pre-install b/testing/speedtest_exporter/speedtest_exporter.pre-install
new file mode 100644
index 0000000000..4acf0e53ba
--- /dev/null
+++ b/testing/speedtest_exporter/speedtest_exporter.pre-install
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+addgroup -S speedtest-exporter 2>/dev/null
+adduser -H -S -D -s /sbin/nologin -G speedtest-exporter -g speedtest-exporter speedtest-exporter 2>/dev/null
+
+exit 0
-- 
2.33.0