summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]debian/netdata.postinst.in72
-rwxr-xr-x[-rw-r--r--]debian/netdata.postrm62
2 files changed, 82 insertions, 52 deletions
diff --git a/debian/netdata.postinst.in b/debian/netdata.postinst.in
index e52dbf62..157cde36 100644..100755
--- a/debian/netdata.postinst.in
+++ b/debian/netdata.postinst.in
@@ -1,33 +1,51 @@
-#! /bin/sh
+#!/bin/sh
set -e
-case "$1" in
- configure)
- if [ -z "$2" ]; then
- if ! getent group netdata >/dev/null; then
- groupadd --system netdata
- fi
-
- if ! getent passwd netdata >/dev/null; then
- useradd --system --groups netdata --home-dir /var/lib/netdata --no-create-home netdata
- mkdir -p /var/lib/netdata
- fi
-
- for dir_name in /var/cache/netdata /var/lib/netdata; do
- if ! dpkg-statoverride --list "$dir_name" >/dev/null 2>&1; then
- dpkg-statoverride --update --add netdata netdata 0755 "$dir_name"
- fi
-
- done
- fi
-
- 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 || \
- chmod 4754 /usr/lib/@DEB_HOST_MULTIARCH@/netdata/plugins.d/apps.plugin
- chown netdata:adm /var/log/netdata
- chmod 02750 /var/log/netdata
- ;;
+case "${1}" in
+ configure)
+ # creating group
+ if ! getent group netdata > /dev/null 2>&1
+ then
+ groupadd --system netdata
+ fi
+
+ # creating user
+ if ! getent passwd netdata > /dev/null 2>&1
+ then
+ useradd --system -g netdata --home-dir /var/lib/netdata --no-create-home netdata
+ mkdir -p /var/lib/netdata
+ fi
+
+ # creating directory overrides
+ for DIRECTORY in /var/cache/netdata /var/lib/netdata
+ do
+ mkdir -p "${DIRECTORY}"
+
+ if ! dpkg-statoverride --list "${DIRECTORY}" > /dev/null 2>&1
+ then
+ dpkg-statoverride --update --add netdata netdata 0755 "${DIRECTORY}"
+ fi
+ done
+
+ # handling plugin capabilities (or setuid as fallback)
+ 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 || \
+ chmod 4754 /usr/lib/@DEB_HOST_MULTIARCH@/netdata/plugins.d/apps.plugin
+
+ # handling log owner and permissions
+ chown netdata:adm /var/log/netdata
+ chmod 2750 /var/log/netdata
+ ;;
+
+ abort-upgrade|abort-remove|abort-deconfigure)
+
+ ;;
+
+ *)
+ echo "postinst called with unknown argument \`${1}'" >&2
+ exit 1
+ ;;
esac
#DEBHELPER#
diff --git a/debian/netdata.postrm b/debian/netdata.postrm
index 2a57c3cb..1ac2941a 100644..100755
--- a/debian/netdata.postrm
+++ b/debian/netdata.postrm
@@ -2,31 +2,43 @@
set -e
-case "$1" in
- remove)
- ;;
-
- purge)
- for dir_name in /var/cache/netdata /var/lib/netdata; do
- if dpkg-statoverride --list | grep -qw "$dir_name"; then
- dpkg-statoverride --remove "$dir_name"
- fi
- done
-
- rm -rf /var/cache/netdata /var/log/netdata
-
- if getent passwd netdata >/dev/null; then
- userdel netdata || echo "Unable to remove netdata user"
- fi
-
- if getent group netdata >/dev/null; then
- groupdel netdata || echo "Unable to remove netdata group"
- fi
-
- ;;
-
- *)
- ;;
+case "${1}" in
+ remove)
+ # removing directory overrides
+ for DIRECTORY in /var/cache/netdata /var/lib/netdata
+ do
+ if dpkg-statoverride --list | grep -qw "${DIRECTORY}"
+ then
+ dpkg-statoverride --remove "${DIRECTORY}"
+ fi
+ done
+
+ # removing user
+ if getent passwd netdata > /dev/null 2>&1
+ then
+ userdel netdata || echo "Unable to remove netdata user"
+ fi
+
+ # removing group
+ if getent group netdata > /dev/null 2>&1
+ then
+ groupdel netdata || echo "Unable to remove netdata group"
+ fi
+ ;;
+
+ purge)
+ # removing directories
+ rm -rf /var/cache/netdata /var/lib/netdata /var/log/netdata
+ ;;
+
+ upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+
+ ;;
+
+ *)
+ echo "postrm called with unknown argument \`${1}'" >&2
+ exit 1
+ ;;
esac
#DEBHELPER#