From fe42a2f7f828e4f2db8c75af22052498add37e7b Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 21 Apr 2019 23:05:20 -0400 Subject: [PATCH] prometheus/prometheus: new APKBUILD --- prometheus/prometheus/APKBUILD | 54 ++++++++++++++++++++ prometheus/prometheus/prometheus.confd | 2 + prometheus/prometheus/prometheus.initd | 15 ++++++ prometheus/prometheus/prometheus.pre-install | 4 ++ 4 files changed, 75 insertions(+) create mode 100644 prometheus/prometheus/APKBUILD create mode 100644 prometheus/prometheus/prometheus.confd create mode 100644 prometheus/prometheus/prometheus.initd create mode 100644 prometheus/prometheus/prometheus.pre-install diff --git a/prometheus/prometheus/APKBUILD b/prometheus/prometheus/APKBUILD new file mode 100644 index 0000000..f987d5a --- /dev/null +++ b/prometheus/prometheus/APKBUILD @@ -0,0 +1,54 @@ +# Maintainer: Drew DeVault +pkgname=prometheus +pkgver=2.9.1 +pkgrel=0 +pkgdesc="The Prometheus monitoring system and time series database" +url="https://github.com/prometheus/prometheus" +arch="all" +license="Apache-2.0" +install="prometheus.pre-install" +makedepends="go" +source=" + $pkgname-$pkgver.tar.gz::https://github.com/prometheus/prometheus/archive/v$pkgver.tar.gz + prometheus.confd + prometheus.initd +" +subpackages="$pkgname-openrc" +builddir="$srcdir/$pkgname-$pkgver" + +build() { + cd "$builddir" + go build \ + -gcflags "all=-trimpath=$PWD" \ + -asmflags "all=-trimpath=$PWD" \ + -ldflags "-extldflags $LDFLAGS" \ + ./cmd/prometheus + go build \ + -gcflags "all=-trimpath=$PWD" \ + -asmflags "all=-trimpath=$PWD" \ + -ldflags "-extldflags $LDFLAGS" \ + ./cmd/promtool +} + +check() { + cd "$builddir" + go test ./... +} + +package() { + cd "$builddir" + install -Dm755 prometheus "$pkgdir"/usr/bin/prometheus + install -Dm755 promtool "$pkgdir"/usr/bin/promtool + + install -Dm640 -t "$pkgdir"/etc/prometheus \ + documentation/examples/prometheus.yml + + install -Dm644 "$srcdir"/prometheus.confd \ + "$pkgdir"/etc/conf.d/prometheus + install -Dm755 "$srcdir"/prometheus.initd \ + "$pkgdir"/etc/init.d/prometheus +} + +sha512sums="d9ae1078ab5b242020f00f5dfc154a75c3e1473be8f1fbecdf8f2589d55a09f8418cbf9aa189a9b2e61b4b5fca875735a26200496c02bb17793bbccbdc9f69cd prometheus-2.9.1.tar.gz +82f90ef730935b9dfc67877098ab0dcada0da941e273b241826b1e9bd2474202f2df5dd976dbed016652219cf0cfd1d77b8df72367ed1ac15c6f0cc38800cac5 prometheus.confd +f70555c76e634b7bf594e7b5f8a17e8a3a549b55835ce51f34f357e317c009d14cd4212bb9eaaddc77a1a9f03a33ab94571e3f9252f8ffcb002560e672a3cc9d prometheus.initd" diff --git a/prometheus/prometheus/prometheus.confd b/prometheus/prometheus/prometheus.confd new file mode 100644 index 0000000..193f4ad --- /dev/null +++ b/prometheus/prometheus/prometheus.confd @@ -0,0 +1,2 @@ +config_file=/etc/prometheus/prometheus.yml +storage_path=/var/lib/prometheus/data diff --git a/prometheus/prometheus/prometheus.initd b/prometheus/prometheus/prometheus.initd new file mode 100644 index 0000000..0fbbdae --- /dev/null +++ b/prometheus/prometheus/prometheus.initd @@ -0,0 +1,15 @@ +#!/sbin/openrc-run +name="prometheus" +description="prometheus monitoring system & time series database" +supervisor=supervise-daemon +command=/usr/bin/prometheus +command_args="--config.file=$config_file \ + --storage.tsdb.path=$storage_path" +command_background=true +command_user="prometheus:prometheus" +pidfile="/run/${RC_SVCNAME}.pid" + +start_pre() { + checkpath -f "$config_file" -m 740 -o prometheus:prometheus + checkpath -d "$storage_path" -m 755 -o prometheus:prometheus +} diff --git a/prometheus/prometheus/prometheus.pre-install b/prometheus/prometheus/prometheus.pre-install new file mode 100644 index 0000000..379f50a --- /dev/null +++ b/prometheus/prometheus/prometheus.pre-install @@ -0,0 +1,4 @@ +#!/bin/sh +grep '^prometheus' /etc/group >/dev/null || addgroup -S prometheus 2>/dev/null +grep '^prometheus' /etc/passwd >/dev/null || adduser -SDh/var/lib/prometheus \ + -s/sbin/nologin -Gprometheus -gprometheus prometheus prometheus 2>/dev/null -- 2.45.2