summaryrefslogtreecommitdiffstats
path: root/contrib/debian/netdata.postinst
blob: 12b1d97b74fb8b71eebb63318b402bef2902aa5b (plain)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/sh

set -e

dpkg-maintscript-helper dir_to_symlink \
  /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 -- "$@"
dpkg-maintscript-helper dir_to_symlink \
  /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 -- "$@"
dpkg-maintscript-helper dir_to_symlink \
  /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 -- "$@"

case "$1" in
  configure|recnfigure)
    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

    for item in docker nginx varnish haproxy adm nsd proxy squid ceph nobody I2C; do
      if getent group $item > /dev/null 2>&1; then
        usermod -a -G $item netdata
      fi
    done

    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/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/log/netdata > /dev/null 2>&1; then
      dpkg-statoverride --update --add netdata adm 02750 /var/log/netdata
    fi

    dpkg-statoverride --force --update --add root netdata 0775 /var/lib/netdata/registry > /dev/null 2>&1

    chown -R root:netdata /usr/libexec/netdata/plugins.d
    setcap cap_dac_read_search,cap_sys_ptrace+ep /usr/libexec/netdata/plugins.d/apps.plugin
    setcap cap_dac_read_search+ep /usr/libexec/netdata/plugins.d/slabinfo.plugin

    if capsh --supports=cap_perfmon 2>/dev/null; then
        setcap cap_perfmon+ep /usr/libexec/netdata/plugins.d/perf.plugin
    else
        setcap cap_sys_admin+ep /usr/libexec/netdata/plugins.d/perf.plugin
    fi

    chmod 4750 /usr/libexec/netdata/plugins.d/cgroup-network
    chmod 4750 /usr/libexec/netdata/plugins.d/nfacct.plugin

    # Workaround if system does not have ebpf.plugin
    chmod -f 4750 /usr/libexec/netdata/plugins.d/ebpf.plugin || true

    # Workaround for other plugins not installed directly by this package
    chmod -f 4750 /usr/libexec/netdata/plugins.d/freeipmi.plugin || true
    chmod -f 4750 /usr/libexec/netdata/plugins.d/ioping || true

    ;;
esac

#DEBHELPER#

exit 0