Skip to content

Commit

Permalink
Fix our Debian/Ubuntu packages to actually package the SystemD Unit f…
Browse files Browse the repository at this point in the history
…iles we expect. (netdata#8468)

* update netdata.conf for debian build

* Fix Debian Ubuntu SystemD Unit packaging

* avoid duplicate netdata.conf files

violates single source of truth principle, use schema from netdata#8468 instead

* Fixed *DirectoryMode octets and bad ExecStart

* Fix dpkg-statoverride warnings

* Move the copy of debian/netdata.conf into the correct target (override_dh_install)

Co-authored-by: and0x000 <[email protected]>
  • Loading branch information
prologic and and0x000 authored Mar 30, 2020
1 parent 3568c34 commit d5d1865
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 73 deletions.
16 changes: 0 additions & 16 deletions contrib/debian/netdata.conf

This file was deleted.

74 changes: 36 additions & 38 deletions contrib/debian/netdata.postinst.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,59 @@
set -e

dpkg-maintscript-helper dir_to_symlink \
/var/lib/netdata/www/.well-known /usr/share/netdata/www/.well-known 1.18.1~ netdata -- "$@"
/var/lib/netdata/www/.well-known /usr/share/netdata/www/.well-known 1.18.1~ netdata -- "$@"
dpkg-maintscript-helper dir_to_symlink \
/var/lib/netdata/www/css /usr/share/netdata/www/css 1.18.1~ netdata -- "$@"
/var/lib/netdata/www/css /usr/share/netdata/www/css 1.18.1~ netdata -- "$@"
dpkg-maintscript-helper dir_to_symlink \
/var/lib/netdata/www/fonts /usr/share/netdata/www/fonts 1.18.1~ netdata -- "$@"
/var/lib/netdata/www/fonts /usr/share/netdata/www/fonts 1.18.1~ netdata -- "$@"
dpkg-maintscript-helper dir_to_symlink \
/var/lib/netdata/www/images /usr/share/netdata/www/images 1.18.1~ netdata -- "$@"
/var/lib/netdata/www/images /usr/share/netdata/www/images 1.18.1~ netdata -- "$@"
dpkg-maintscript-helper dir_to_symlink \
/var/lib/netdata/www/lib /usr/share/netdata/www/lib 1.18.1~ netdata -- "$@"
/var/lib/netdata/www/lib /usr/share/netdata/www/lib 1.18.1~ netdata -- "$@"
dpkg-maintscript-helper dir_to_symlink \
/var/lib/netdata/www/static /usr/share/netdata/www/static 1.18.1~ netdata -- "$@"
/var/lib/netdata/www/static /usr/share/netdata/www/static 1.18.1~ netdata -- "$@"

case "$1" in
configure)
if [ -z "$2" ]; then
if ! getent group netdata >/dev/null; then
addgroup --quiet --system netdata
fi
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 ! 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 netdata netdata 0755 /var/lib/netdata
fi
if ! dpkg-statoverride --list /var/lib/netdata > /dev/null 2>&1; then
dpkg-statoverride --update --add netdata 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/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
if ! dpkg-statoverride --list /var/cache/netdata > /dev/null 2>&1; then
dpkg-statoverride --update --add netdata netdata 0755 /var/cache/netdata
fi

if ! dpkg-statoverride --list /var/run/netdata >/dev/null 2>&1; then
dpkg-statoverride --update --add netdata netdata 0755 /var/run/netdata
fi
if ! dpkg-statoverride --list /var/run/netdata > /dev/null 2>&1; then
dpkg-statoverride --update --add netdata netdata 0755 /var/run/netdata
fi

if ! dpkg-statoverride --list /var/log/netdata >/dev/null 2>&1; then
dpkg-statoverride --update --add netdata adm 02750 /var/log/netdata
fi
if ! dpkg-statoverride --list /var/log/netdata > /dev/null 2>&1; then
dpkg-statoverride --update --add netdata adm 02750 /var/log/netdata
fi

fi
fi

dpkg-statoverride --update --add --force root netdata 0775 /var/lib/netdata/registry
chown -R root:netdata /usr/share/netdata
chown -R root:netdata /usr/libexec/netdata/plugins.d
chown -R root:netdata /var/lib/netdata/www
setcap cap_dac_read_search,cap_sys_ptrace+ep /usr/libexec/netdata/plugins.d/apps.plugin
dpkg-statoverride --force --update --add root netdata 0775 /var/lib/netdata/registry > /dev/null 2>&1

#PERMS#
;;
esac
chown -R root:netdata /usr/share/netdata
chown -R root:netdata /usr/libexec/netdata/plugins.d
chown -R root:netdata /var/lib/netdata/www
setcap cap_dac_read_search,cap_sys_ptrace+ep /usr/libexec/netdata/plugins.d/apps.plugin

#DEBHELPER#
;;
esac

exit 0
14 changes: 0 additions & 14 deletions contrib/debian/netdata.service

This file was deleted.

19 changes: 19 additions & 0 deletions contrib/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
TOP = $(CURDIR)/debian/netdata
TEMPTOP = $(CURDIR)/debian/tmp

BASE_CONFIG = system/netdata.conf

SYSTEMD_VERSION = $(shell /bin/sh -c "systemd --version 2>&1 | head -n 1 | cut -f 2 -d ' '")

ifeq ($(shell test $(SYSTEMD_VERSION) -ge 235 && echo "1"), 1)
SYSTEMD_UNIT = system/netdata.service.v235
else
SYSTEMD_UNIT = system/netdata.service
endif

%:
# For jessie and beyond
#
Expand All @@ -17,6 +27,13 @@ TEMPTOP = $(CURDIR)/debian/tmp
#
#dh $@ --with autoreconf

override_dh_installinit:
echo "SystemD Version: $(SYSTEMD_VERSION)"
echo "Using SystemD Unit: $(SYSTEMD_UNIT)"
cp -v $(SYSTEMD_UNIT) debian/netdata.service

dh_installinit

override_dh_auto_configure:
packaging/bundle-mosquitto.sh .
packaging/bundle-lws.sh .
Expand All @@ -28,6 +45,8 @@ debian/%.postinst: debian/%.postinst.in
sed 's/@DEB_HOST_MULTIARCH@/$(DEB_HOST_MULTIARCH)/g' $< > $@

override_dh_install: debian/netdata.postinst
cp -v $(BASE_CONFIG) debian/netdata.conf

dh_install

# Set the CUPS plugin install rule
Expand Down
3 changes: 3 additions & 0 deletions system/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ CLEANFILES = \
netdata-openrc \
netdata.logrotate \
netdata.service \
netdata.service.v235 \
netdata-init-d \
netdata-lsb \
netdata-freebsd \
Expand All @@ -28,6 +29,7 @@ nodist_noinst_DATA = \
netdata-openrc \
netdata.logrotate \
netdata.service \
netdata.service.v235 \
netdata-init-d \
netdata-lsb \
netdata-freebsd \
Expand All @@ -39,6 +41,7 @@ dist_noinst_DATA = \
netdata-openrc.in \
netdata.logrotate.in \
netdata.service.in \
netdata.service.v235.in \
netdata-init-d.in \
netdata-lsb.in \
netdata-freebsd.in \
Expand Down
10 changes: 5 additions & 5 deletions system/netdata.service.v235.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ CacheDirectory=netdata
StateDirectory=netdata
LogsDirectory=netdata
RuntimeDirectoryMode=0775
StateDirectoryMode=0750
CacheDirectoryMode=0750
LogsDirectoryMode=0750
PIDFile=netdata/netdata.pid
ExecStart=@sbindir_POST@/netdata -P $PIDFILE -D
StateDirectoryMode=0755
CacheDirectoryMode=0755
LogsDirectoryMode=2750
EnvironmentFile=-/etc/default/netdata
ExecStart=/usr/sbin/netdata -D $EXTRA_OPTS

# saving a big db on slow disks may need some time
TimeoutStopSec=60
Expand Down

0 comments on commit d5d1865

Please sign in to comment.