summaryrefslogtreecommitdiffstats
path: root/contrib/debian/netdata.preinst
blob: a5dc9107e6cdddce4bb896883aaba4e710b21a5b (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
#!/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
  install)
    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
    # Netdata must be able to read /etc/pve/qemu-server/* and /etc/pve/lxc/*
    # for reading VMs/containers names, CPU and memory limits on Proxmox.
    if [ -d "/etc/pve" ] && getent group "www-data" > /dev/null 2>&1; then
      usermod -a -G www-data netdata
    fi
    ;;
esac

#DEBHELPER#