summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFederico Ceratto <federico.ceratto@gmail.com>2016-04-13 20:38:09 +0000
committerFederico Ceratto <federico.ceratto@gmail.com>2016-04-13 20:46:00 +0000
commita354d9cf8e9ecf6c8689dd7319a16f3bb6ed8da1 (patch)
treef0eba39597636f3b45b138a936ee20e6342b8f4d
parentAdd docs, install and config file (diff)
downloadnetdata-a354d9cf8e9ecf6c8689dd7319a16f3bb6ed8da1.tar.xz
netdata-a354d9cf8e9ecf6c8689dd7319a16f3bb6ed8da1.zip
Update rules, add postint.in and logrotate file
-rw-r--r--debian/netdata.logrotate15
-rw-r--r--debian/netdata.postinst.in42
-rwxr-xr-xdebian/rules100
3 files changed, 142 insertions, 15 deletions
diff --git a/debian/netdata.logrotate b/debian/netdata.logrotate
new file mode 100644
index 000000000..707eba3f4
--- /dev/null
+++ b/debian/netdata.logrotate
@@ -0,0 +1,15 @@
+/var/log/netdata/*log {
+ compress
+ create 0640 netdata adm
+ daily
+ delaycompress
+ missingok
+ notifempty
+ rotate 14
+ sharedscripts
+ postrotate
+ if service netdata status > /dev/null ; then \
+ service netdata restart > /dev/null; \
+ fi;
+}
+
diff --git a/debian/netdata.postinst.in b/debian/netdata.postinst.in
new file mode 100644
index 000000000..36a03c0b1
--- /dev/null
+++ b/debian/netdata.postinst.in
@@ -0,0 +1,42 @@
+#! /bin/sh
+
+set -e
+
+case "$1" in
+ configure)
+ if [ -z "$2" ]; then
+ if ! getent group netdata >/dev/null; then
+ addgroup --quiet --system netdata
+ fi
+
+ if ! getent passwd netdata >/dev/null; then
+ adduser --quiet --system --ingroup netdata --home /var/lib/netdata --no-create-home netdata
+ fi
+
+ if ! dpkg-statoverride --list /var/lib/netdata >/dev/null 2>&1; then
+ dpkg-statoverride --update --add root netdata 0755 /var/lib/netdata
+ fi
+
+ if ! dpkg-statoverride --list /var/lib/netdata/www >/dev/null 2>&1; then
+ dpkg-statoverride --update --add root netdata 0755 /var/lib/netdata/www
+ fi
+
+ if ! dpkg-statoverride --list /var/cache/netdata >/dev/null 2>&1; then
+ dpkg-statoverride --update --add netdata netdata 0755 /var/cache/netdata
+ fi
+
+ fi
+
+ chown -R root:netdata /usr/share/netdata/*
+ chown -R root:netdata /usr/lib/@DEB_HOST_MULTIARCH@/netdata/plugins.d
+ setcap cap_dac_read_search,cap_sys_ptrace+ep /usr/lib/@DEB_HOST_MULTIARCH@/netdata/plugins.d/apps.plugin
+ chown netdata:adm /var/log/netdata
+ chmod 02750 /var/log/netdata
+
+#PERMS#
+ ;;
+esac
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/rules b/debian/rules
index 45164c126..dcc92dbbb 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,23 +1,93 @@
#!/usr/bin/make -f
+
+# Find the arch we are building for, as this determines
+# the location of plugins in /usr/lib
+DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
+TOP = $(CURDIR)/debian/netdata
+
export DH_VERBOSE = 1
-# see FEATURE AREAS in dpkg-buildflags(1)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
-# package maintainers to append CFLAGS
export DEB_CFLAGS_MAINT_APPEND = -Wall -O3
-# package maintainers to append LDFLAGS
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
-
%:
- dh $@
-
-override_dh_auto_build:
- ./autogen.sh
- ./configure \
- --prefix="${NETDATA_PREFIX}/usr" \
- --sysconfdir="${NETDATA_PREFIX}/etc" \
- --localstatedir="${NETDATA_PREFIX}/var" \
- --with-zlib --with-math --with-user=netdata \
- CFLAGS="${CFLAGS}"
- dh_auto_build
+ # For jessie and beyond
+ #
+ dh $@ --with autoreconf,systemd
+
+ # For wheezy or other non-systemd distributions use the following. You
+ # should also see contrib/README.md which gives details of updates to
+ # make to debian/control.
+ #
+ #dh $@ --with autoreconf
+
+override_dh_auto_configure:
+ dh_auto_configure -- --with-math --with-webdir=/var/lib/netdata/www
+
+debian/%.postinst: debian/%.postinst.in
+ sed 's/@DEB_HOST_MULTIARCH@/$(DEB_HOST_MULTIARCH)/g' $< > $@
+
+override_dh_install: debian/netdata.postinst
+ dh_install
+
+ # Remove unneeded .keep files
+ #
+ find "$(TOP)" -name .keep -exec rm '{}' ';'
+
+ # Move files that local user shouldn't be editing to /usr/share/netdata
+ #
+ mkdir -p "$(TOP)/usr/share/netdata"
+ for D in $$(find "$(TOP)/var/lib/netdata/www/" -maxdepth 1 -type d -printf '%f '); do \
+ echo Relocating $$D; \
+ mv "$(TOP)/var/lib/netdata/www/$$D" "$(TOP)/usr/share/netdata/$$D"; \
+ ln -s "/usr/share/netdata/$$D" "$(TOP)/var/lib/netdata/www/$$D"; \
+ done
+
+ # Update postinst to set correct group for www files on installation.
+ # Should probably be dpkg-statoverride really, but that gets *really*
+ # messy. We also set all web files in /var as conffiles so an upgrade
+ # doesn't splat them.
+ #
+ for D in $$(find "$(TOP)/var/lib/netdata/www/" -maxdepth 1 -type f -printf '%f '); do \
+ echo Updating postinst for $$D; \
+ sed -i "s/^#PERMS#/chgrp netdata \/var\/lib\/netdata\/www\/$$D\n#PERMS#/g" \
+ $(CURDIR)/debian/netdata.postinst; \
+ echo "/var/lib/netdata/www/$$D" >> $(CURDIR)/debian/netdata.conffiles; \
+ done
+ sed -i "/^#PERMS#/d" $(CURDIR)/debian/netdata.postinst
+
+override_dh_installdocs:
+ dh_installdocs
+
+ # Docs should not be under /usr/lib
+ #
+ mv $(TOP)/usr/lib/$(DEB_HOST_MULTIARCH)/netdata/plugins.d/README.md \
+ $(TOP)/usr/share/doc/netdata/README.plugins.md
+ mv $(TOP)/usr/lib/$(DEB_HOST_MULTIARCH)/netdata/charts.d/README.md \
+ $(TOP)/usr/share/doc/netdata/README.charts.md
+
+ # This doc is currently empty, so no point installing it.
+ #
+ rm $(TOP)/usr/lib/$(DEB_HOST_MULTIARCH)/netdata/node.d/README.md
+
+override_dh_fixperms:
+ dh_fixperms
+
+ # apps.plugin should only be runnable by the netdata user. It will be
+ # given extra capabilities in the postinst script.
+ #
+ chmod 0754 $(TOP)/usr/lib/$(DEB_HOST_MULTIARCH)/netdata/plugins.d/apps.plugin
+
+override_dh_installlogrotate:
+ dh_installlogrotate
+
+override_dh_clean:
+ dh_clean
+
+ # Tidy up copied/generated files
+ rm -f $(CURDIR)/debian/netdata.postinst
+ rm -f $(CURDIR)/debian/netdata.conffiles
+
+override_dh_installchangelogs:
+ dh_installchangelogs ChangeLog