Skip to content

Instantly share code, notes, and snippets.

@dstrelau
Last active December 21, 2015 14:49
Show Gist options
  • Save dstrelau/6322572 to your computer and use it in GitHub Desktop.
Save dstrelau/6322572 to your computer and use it in GitHub Desktop.
collectd deb via fpm
description "start/stop/control collectd"
# http://collectd.org/
# Upstart is the replacement init system used in Debian, Ubuntu,
# and in Fedora. Refer to http://upstart.ubuntu.com/cookbook/
#
# Normally this file will live as `/etc/init/collectd.conf`
usage "initctl <start|stop> collectd"
author "Dave Cottlehuber <dch@jsonified.com>"
version "1.1"
# There are a number of alternative start sequences however
# most of those do not work on all Ubuntu flavours and releases.
start on started networking and filesystem
stop on runlevel [!2345]
# collectd itself will run with reduced privileges, but not
# all plugins will. Test and edit as required.
# An alternative configuration is as a user script in ~/.init/ however
# these cannot be started at boot time by the system without
# arcane trickery. Also a root user will not see these tasks/jobs
# by default. set*id is a reasonable and secure compromise.
#setuid nobody
#setgid nobody
# Other parameters such as the path to the configuration file
# will have been compiled into the binary. These are trivially
# added as environment variables below, and then into both
# `pre-start` command check before collectd runs, and subsequent
# `exec` command parameters below. Remember that upstart runs all
# shell commands via `sh -e`.
env DAEMON=/usr/sbin/collectd
# Tell upstart to watch for forking when tracking the pid for us.
expect fork
# prevent thrashing - 10 restarts in 5 seconds
respawn
respawn limit 10 5
# Make a log available in /var/log/upstart/collectd.log
console log
# The daemon will not start if the configuration is invalid.
pre-start exec $DAEMON -t
# Let's Fork!
exec $DAEMON
NAME=collectd
VERSION=5.4.0
IDENTIFIER=tc1
TAR=collectd-$(VERSION).tar.gz
DIR=collectd-$(VERSION)
FAKEROOT=$(PWD)/fakeroot
all: clean dependencies build install package
clean:
rm -rf $(DIR) $(FAKEROOT)
rm -f collectd*.deb
$(TAR):
wget http://collectd.org/files/$(TAR)
$(DIR): $(TAR)
tar xvzf $(TAR)
dependencies:
apt-get install -y \
ruby1.9.1-dev \
build-essential \
libcap-dev \
libcurl3-gnutls-dev \
libdbi-dev \
libesmtp-dev \
libmemcached-dev \
libmnl-dev \
libmysqlclient-dev \
liboping-dev \
libpcap-dev \
libperl5.14 \
libpq-dev \
libpython3.2 \
librabbitmq-dev \
librabbitmq-dev \
librrd-dev \
libsensors4-dev \
libvarnishapi-dev \
libxml2-dev \
libyajl-dev
gem install fpm --no-ri --no-rdoc
build: $(DIR)
cd $(DIR) && ./configure --prefix=/usr --sysconfdir=/etc/collectd
$(FAKEROOT):
mkdir -p $(FAKEROOT)
install: $(FAKEROOT)
# something with buildperl is screwed up and requires sudo
cd $(DIR) && DESTDIR=$(FAKEROOT) make install
mkdir -p $(FAKEROOT)/etc/init
cp collectd.conf $(FAKEROOT)/etc/init
package:
fpm -s dir \
-t deb \
-d libc6 \
-d libcap2 \
-d libcurl3-gnutls \
-d libdbi1 \
-d libesmtp6 \
-d libgcrypt11 \
-d libglib2.0-0 \
-d libmemcached6 \
-d libmysqlclient18 \
-d liboping0 \
-d libpcap0.8 \
-d libperl5.14 \
-d libpq5 \
-d libpython2.7 \
-d librabbitmq0 \
-d librrd4 \
-d libsensors4 \
-d libvarnishapi1 \
-d libxml2 \
-d libyajl1 \
-d perl \
--config-files /etc/collectd.conf \
--config-files /etc/init/collectd.conf \
-n $(NAME) \
-v $(VERSION)-$(IDENTIFIER) \
-a native \
-C $(FAKEROOT) \
usr etc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment