File: netdata-core.postinst

package info (click to toggle)
netdata 1.37.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 59,364 kB
  • sloc: ansic: 302,654; javascript: 77,865; python: 27,094; sh: 18,726; cpp: 2,916; makefile: 2,547; pascal: 171; xml: 10
file content (56 lines) | stat: -rwxr-xr-x 1,230 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh

set -e

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

		# in some plugins netdata must be able to read logfiles
		usermod -G adm netdata

		# 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/netdata/plugins.d
		setcap cap_dac_read_search,cap_sys_ptrace+ep /usr/lib/netdata/plugins.d/apps.plugin || \
			chmod 4754 /usr/lib/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#

exit 0