From 3312d4945db7d629dae2e73784158d74eb96c9a6 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 21 Apr 2019 23:23:56 -0400 Subject: [PATCH] Normalize alertmanager package --- prometheus/alertmanager/APKBUILD | 31 +++++++++++++------ prometheus/alertmanager/alertmanager.confd | 2 ++ prometheus/alertmanager/alertmanager.initd | 28 +++++++---------- .../alertmanager/alertmanager.pre-install | 4 +++ 4 files changed, 39 insertions(+), 26 deletions(-) create mode 100644 prometheus/alertmanager/alertmanager.confd create mode 100644 prometheus/alertmanager/alertmanager.pre-install diff --git a/prometheus/alertmanager/APKBUILD b/prometheus/alertmanager/APKBUILD index 84ef49c..716b428 100644 --- a/prometheus/alertmanager/APKBUILD +++ b/prometheus/alertmanager/APKBUILD @@ -1,24 +1,34 @@ # Maintainer: Drew DeVault pkgname=alertmanager pkgver=0.16.2 -pkgrel=0 +pkgrel=1 pkgdesc="Prometheus Alertmanager" url="https://github.com/prometheus/alertmanager" arch="all" license="Apache-2.0" +install="$pkgname.pre-install" makedepends="go bzr" source=" $pkgname-$pkgver.tar.gz::https://github.com/prometheus/alertmanager/archive/v$pkgver.tar.gz + alertmanager.confd alertmanager.initd " subpackages="$pkgname-openrc" builddir="$srcdir/$pkgname-$pkgver" -options="!check" # broken time tests upstream +options="!check" # timing-dependent upstream failures build() { cd "$builddir" - go build -o alertmanager cmd/alertmanager/main.go - go build -o amtool cmd/amtool/main.go + go build \ + -gcflags "all=-trimpath=$PWD" \ + -asmflags "all=-trimpath=$PWD" \ + -ldflags "-extldflags $LDFLAGS" \ + ./cmd/alertmanager + go build \ + -gcflags "all=-trimpath=$PWD" \ + -asmflags "all=-trimpath=$PWD" \ + -ldflags "-extldflags $LDFLAGS" \ + ./cmd/amtool } check() { @@ -31,13 +41,16 @@ package() { install -Dm755 alertmanager "$pkgdir"/usr/bin/alertmanager install -Dm755 amtool "$pkgdir"/usr/bin/amtool - install -Dm755 examples/ha/alertmanager.yml \ - "$pkgdir"/etc/alertmanager/alertmanager.yml - install -d -m755 -o 211 -g 211 "$pkgdir"/var/lib/alertmanager - install -Dm755 "$srcdir"/alertmanager.initd \ "$pkgdir"/etc/init.d/alertmanager + install -Dm644 "$srcdir"/alertmanager.confd \ + "$pkgdir"/etc/conf.d/alertmanager + install -dm644 "$pkgdir"/var/lib/alertmanager/data + + install -Dm644 examples/ha/alertmanager.yml \ + "$pkgdir"/etc/alertmanager/alertmanager.yml } sha512sums="94012739c5c9691ff34bb521e220e00de13ef866451ffaaa8d45f85c228c6b515a84550a819b351db36e3da7c17a0fa397b5b1c6a4cbc3451442f5064a0184a3 alertmanager-0.16.2.tar.gz -40c5fd04ce4d501bbd33b16abab77d47fee98cb035f9786ae231f052edbc8c6e2a3c09505269ab2c7ff6c44f3a3c129f54df7c8abe92033750666097b77668fe alertmanager.initd" +58f59d1972af10659a5d44f3e005b28928082bac733d27b10238196f68f361cd472782a83b60522c850de7fe9cf502f688956e6e1a2bb64c8aead10dc1529266 alertmanager.confd +e8164d4d897017dc1364497c657a2efc859105882a0222a18e63a73b3a034575e5ed3f138f8015d8d3cdd0bc209c7118241c2a2d55a5a2fde5bff77cfbe95a7f alertmanager.initd" diff --git a/prometheus/alertmanager/alertmanager.confd b/prometheus/alertmanager/alertmanager.confd new file mode 100644 index 0000000..c5d3a18 --- /dev/null +++ b/prometheus/alertmanager/alertmanager.confd @@ -0,0 +1,2 @@ +config_file=/etc/alertmanager/alertmanager.yml +storage_path=/var/lib/alertmanager/data diff --git a/prometheus/alertmanager/alertmanager.initd b/prometheus/alertmanager/alertmanager.initd index b9c6de3..031e882 100644 --- a/prometheus/alertmanager/alertmanager.initd +++ b/prometheus/alertmanager/alertmanager.initd @@ -1,21 +1,15 @@ #!/sbin/openrc-run name="alertmanager" -description="prometheus alertmanager" +description="alert manager for the prometheus monitoring system" +supervisor=supervise-daemon +command=/usr/bin/alertmanager +command_args="--config.file=$config_file \ + --storage.path=$storage_path" +command_background=true +command_user="prometheus:prometheus" +pidfile="/run/${RC_SVCNAME}.pid" -depend() { - need net -} - -start() { - ebegin "Starting $name" - start-stop-daemon -C --background --make-pidfile --pidfile /run/$name.pid \ - --exec /usr/bin/alertmanager -- \ - --config.file=/etc/alertmanager/alertmanager.yml - eend $? -} - -stop() { - ebegin "Stopping $name" - start-stop-daemon --stop --exec /usr/bin/alertmanager --pidfile /run/$name.pid - eend $? +start_pre() { + checkpath -f "$config_file" -m 740 -o prometheus:prometheus + checkpath -d "$storage_path" -m 755 -o prometheus:prometheus } diff --git a/prometheus/alertmanager/alertmanager.pre-install b/prometheus/alertmanager/alertmanager.pre-install new file mode 100644 index 0000000..379f50a --- /dev/null +++ b/prometheus/alertmanager/alertmanager.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