aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlo Landmeter <clandmeter@gmail.com>2016-11-14 17:46:46 +0100
committerCarlo Landmeter <clandmeter@gmail.com>2016-11-14 17:48:48 +0100
commit5449e11d98d303ae5669b3f686aa4ff546b1d1dd (patch)
tree38ce7eba4ab58e23a79291d00656a276ab96a79e
parentdeab96c6016be38ab793c6ad0c4f8227d0984235 (diff)
downloadaports-5449e11d98d303ae5669b3f686aa4ff546b1d1dd.tar.gz
aports-5449e11d98d303ae5669b3f686aa4ff546b1d1dd.tar.bz2
aports-5449e11d98d303ae5669b3f686aa4ff546b1d1dd.tar.xz
main/collectd: various changes/fixes
run as collectd user (do not run as root) split libs utils and disk (add eudev support) add plugins lvm lua mqtt
-rw-r--r--main/collectd/APKBUILD53
-rw-r--r--main/collectd/collectd.initd27
-rw-r--r--main/collectd/collectd.pre-install10
3 files changed, 58 insertions, 32 deletions
diff --git a/main/collectd/APKBUILD b/main/collectd/APKBUILD
index f2ba9e0933..64be36d7b8 100644
--- a/main/collectd/APKBUILD
+++ b/main/collectd/APKBUILD
@@ -2,7 +2,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=collectd
pkgver=5.6.1
-pkgrel=0
+pkgrel=1
pkgdesc="The system statistics collection daemon"
url="http://collectd.org"
arch="all"
@@ -11,20 +11,24 @@ depends=""
makedepends="curl-dev net-snmp-dev postgresql-dev perl-dev python2-dev
libgcrypt-dev mariadb-dev zlib-dev libressl-dev iptables-dev
rrdtool-dev yajl-dev libvirt-dev lm_sensors-dev libxml2-dev
- hiredis-dev
+ hiredis-dev eudev-dev mosquitto-dev lua-dev lvm2-dev
autoconf automake libtool"
install=""
-subpackages="$pkgname-dev $pkgname-doc $pkgname-perl $pkgname-snmp
- $pkgname-curl:_curl
+subpackages="$pkgname-dev $pkgname-doc $pkgname-libs
+ $pkgname-perl $pkgname-snmp $pkgname-curl:_curl $pkgname-utils
$pkgname-write_http $pkgname-nginx $pkgname-apache $pkgname-postgresql
- $pkgname-mysql $pkgname-network $pkgname-rrdtool $pkgname-sensors
+ $pkgname-network $pkgname-mysql $pkgname-rrdtool $pkgname-sensors
$pkgname-python:_python $pkgname-iptables:_ipt $pkgname-bind
$pkgname-ascent $pkgname-virt $pkgname-redis $pkgname-write_redis
- $pkgname-log_logstash $pkgname-ceph"
-
+ $pkgname-log_logstash $pkgname-ceph $pkgname-disk $pkgname-lvm
+ $pkgname-lua $pkgname-mqtt"
+install="$pkgname.pre-install"
+pkgusers="collectd"
+pkggroups="collectd"
source="http://collectd.org/files/collectd-$pkgver.tar.bz2
collectd.initd
- gnu_source.patch"
+ gnu_source.patch
+ collectd.pre-install"
builddir="$srcdir"/$pkgname-$pkgver
@@ -51,15 +55,17 @@ build() {
--with-perl-bindings=INSTALLDIRS=vendor \
|| return 1
make || return 1
- # disable network plugin by default since its in a subpackage
+ # disable plugins by default since its in a subpackage
sed -i -e 's/^LoadPlugin network/#LoadPlugin network/' \
- src/collectd.conf
+ src/collectd.conf || return 1
+ sed -i -e 's/^LoadPlugin rrdtool/#LoadPlugin rrdtool/' \
+ src/collectd.conf || return 1
}
package() {
cd "$builddir"
make DESTDIR="$pkgdir" install || return 1
-
+ chown root:collectd "$pkgdir"/etc/collectd/collectd.conf || return 1
find "$pkgdir" \( -name perllocal.pod -o -name .packlist \) -delete
install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
}
@@ -74,6 +80,12 @@ perl() {
mv "$pkgdir"/usr/share/perl* "$subpkgdir"/usr/share/
}
+utils() {
+ pkgdesc="$pkgname utilities"
+ mkdir -p "$subpkgdir"/usr/bin
+ mv "$pkgdir"/usr/bin/* "$subpkgdir"/usr/bin/
+}
+
_plugin() {
local mod=$1
local desc=${2:-$mod}
@@ -101,14 +113,21 @@ redis() { _plugin redis; }
write_redis() { _plugin write_redis; }
log_logstash() { _plugin log_logstash; }
ceph() { _plugin ceph; }
+disk() { _plugin disk; }
+lvm() { _plugin lvm; }
+lua() { _plugin lua; }
+mqtt() { _plugin mqtt; }
virt() { _plugin virt; provides="$pkgname-libvirt"; }
md5sums="979f43b6439d7df93f0b40c73d779223 collectd-5.6.1.tar.bz2
-8015a61e7cda7abdf60e63eeff2923d2 collectd.initd
-3bba7683187b5fc736727a3b8f9c26b2 gnu_source.patch"
+aaeba3fe4314d34495a703caee7769c6 collectd.initd
+3bba7683187b5fc736727a3b8f9c26b2 gnu_source.patch
+ef03f7544d942ab5bb565d784a70edff collectd.pre-install"
sha256sums="c30ff644f91407b4dc2d99787b99cc45ec00e538bd1cc269429d3c5e8a4aee2c collectd-5.6.1.tar.bz2
-7d7b20cb0c804d56d4e7ffe60b975b82c194898160674be2de49d1489589f6a3 collectd.initd
-071770da2e443194574c8d7e5dc1c8170f18aa846ef7edfafa8128d96d531a8d gnu_source.patch"
+4719176c613926900252b4e8a53c74a7927908824490badbbdec605442df8b0b collectd.initd
+071770da2e443194574c8d7e5dc1c8170f18aa846ef7edfafa8128d96d531a8d gnu_source.patch
+125fb811a1d9328a8c3f4e75193ceb00b4d66c7d2ff2562e9e8c7d8d449559d0 collectd.pre-install"
sha512sums="da25f1a9cbaf47533f5a4d2f5f78b966317d4f21865c5a714954ad9d7d02b4798a3e0471ce52199dc80e01dc2808376cb10a7e19c402aafc984bf595f09951a6 collectd-5.6.1.tar.bz2
-296b9f58df7b0da5b2fbf8c6e77cbd08c6673da28e98e67a34cb52dffc26c45d54a95f0bc51a16729d1844752636419fae98a4d3fd744b736568dfc23fab4296 collectd.initd
-519fa563d319928e35e0235dd2bc38e7e53dbaae93ede1c93622dab2d00e1ac3baa93200f9e3e62cb81c1c9d808171b4648db864191d57a703ac7874b9c5fb95 gnu_source.patch"
+a286c2164af196154d017658d6e5aa3cc4f76dadf90b68c3021418979d9f0377776bb990d737ae5c916c04475725365aea8b78e3bc5e2f3679d5a99f8b9af13e collectd.initd
+519fa563d319928e35e0235dd2bc38e7e53dbaae93ede1c93622dab2d00e1ac3baa93200f9e3e62cb81c1c9d808171b4648db864191d57a703ac7874b9c5fb95 gnu_source.patch
+cb0efcd3b9bd5620b7d812d5f038ebd60253f1ce9006da0a1b4b56666202a4254e80ab6a84d675b6cb099ecda1897de17b51a9e3f0d83e8b0455343f5f6d24d7 collectd.pre-install"
diff --git a/main/collectd/collectd.initd b/main/collectd/collectd.initd
index 9cacf2e066..4ff1e6442c 100644
--- a/main/collectd/collectd.initd
+++ b/main/collectd/collectd.initd
@@ -1,20 +1,17 @@
#!/sbin/openrc-run
-DAEMON=/usr/sbin/collectd
+COLLECTD_USER=${COLLECTD_USER:-"collectd"}
+COLLECTD_GROUP=${COLLECTD_GROUP:-"collectd"}
+COLLECTD_ARGS=${COLLECTD_ARGS:-""}
+COLLECTD_PIDFILE=${COLLECTD_PIDFILE:-"/run/collectd/collectd.pid"}
-depend() {
- need net
-}
-
-start() {
- ebegin "Starting collectd"
- start-stop-daemon --start --exec $DAEMON -- $collectd_options
- eend $?
-}
+command=/usr/sbin/collectd
+pidfile="$COLLECTD_PIDFILE"
+command_args="${COLLECTD_ARGS} -P $pidfile"
+start_stop_daemon_args="--user ${COLLECTD_USER}:${COLLECTD_GROUP}"
+retry=${COLLECTD_TERMTIMEOUT:-"TERM/25/KILL/5"}
-stop () {
- ebegin "Stopping collectd"
- start-stop-daemon --stop --exec $DAEMON
- eend $?
+start_pre() {
+ checkpath --directory --owner "$COLLECTD_USER":"$COLLECTD_GROUP" \
+ --mode 0770 "$(dirname $pidfile)" /var/lib/collectd
}
-
diff --git a/main/collectd/collectd.pre-install b/main/collectd/collectd.pre-install
new file mode 100644
index 0000000000..dc57f065e2
--- /dev/null
+++ b/main/collectd/collectd.pre-install
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+adduser -S -D -h /var/lib/collectd -s /sbin/nologin -g collectd collectd 2>/dev/null
+addgroup -S collectd 2>/dev/null
+addgroup -S readproc 2>/dev/null
+addgroup collectd collectd 2>/dev/null
+addgroup collectd readproc 2>/dev/null
+
+exit 0
+