M prometheus/alertmanager/APKBUILD => prometheus/alertmanager/APKBUILD +22 -9
@@ 1,24 1,34 @@
# Maintainer: Drew DeVault <sir@cmpwn.com>
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"
A prometheus/alertmanager/alertmanager.confd => prometheus/alertmanager/alertmanager.confd +2 -0
@@ 0,0 1,2 @@
+config_file=/etc/alertmanager/alertmanager.yml
+storage_path=/var/lib/alertmanager/data
M prometheus/alertmanager/alertmanager.initd => prometheus/alertmanager/alertmanager.initd +11 -17
@@ 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
}
A prometheus/alertmanager/alertmanager.pre-install => prometheus/alertmanager/alertmanager.pre-install +4 -0
@@ 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