netdata.postinst 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/bin/sh
  2. set -e
  3. dpkg-maintscript-helper dir_to_symlink \
  4. /var/lib/netdata/www/.well-known /usr/share/netdata/www/.well-known 1.18.1~ netdata -- "$@"
  5. dpkg-maintscript-helper dir_to_symlink \
  6. /var/lib/netdata/www/css /usr/share/netdata/www/css 1.18.1~ netdata -- "$@"
  7. dpkg-maintscript-helper dir_to_symlink \
  8. /var/lib/netdata/www/fonts /usr/share/netdata/www/fonts 1.18.1~ netdata -- "$@"
  9. dpkg-maintscript-helper dir_to_symlink \
  10. /var/lib/netdata/www/images /usr/share/netdata/www/images 1.18.1~ netdata -- "$@"
  11. dpkg-maintscript-helper dir_to_symlink \
  12. /var/lib/netdata/www/lib /usr/share/netdata/www/lib 1.18.1~ netdata -- "$@"
  13. dpkg-maintscript-helper dir_to_symlink \
  14. /var/lib/netdata/www/static /usr/share/netdata/www/static 1.18.1~ netdata -- "$@"
  15. case "$1" in
  16. configure|reconfigure)
  17. if ! getent group netdata > /dev/null; then
  18. addgroup --quiet --system netdata
  19. fi
  20. if ! getent passwd netdata > /dev/null; then
  21. adduser --quiet --system --ingroup netdata --home /var/lib/netdata --no-create-home netdata
  22. fi
  23. for item in docker nginx varnish haproxy adm nsd proxy squid ceph nobody I2C; do
  24. if getent group $item > /dev/null 2>&1; then
  25. usermod -a -G $item netdata
  26. fi
  27. done
  28. # Netdata must be able to read /etc/pve/qemu-server/* and /etc/pve/lxc/*
  29. # for reading VMs/containers names, CPU and memory limits on Proxmox.
  30. if [ -d "/etc/pve" ] && getent group "www-data" > /dev/null 2>&1; then
  31. usermod -a -G www-data netdata
  32. fi
  33. if ! dpkg-statoverride --list /var/lib/netdata > /dev/null 2>&1; then
  34. dpkg-statoverride --update --add netdata netdata 0755 /var/lib/netdata
  35. fi
  36. if ! dpkg-statoverride --list /var/lib/netdata/www > /dev/null 2>&1; then
  37. dpkg-statoverride --update --add root netdata 0755 /var/lib/netdata/www
  38. fi
  39. if ! dpkg-statoverride --list /var/cache/netdata > /dev/null 2>&1; then
  40. dpkg-statoverride --update --add netdata netdata 0755 /var/cache/netdata
  41. fi
  42. if ! dpkg-statoverride --list /var/run/netdata > /dev/null 2>&1; then
  43. dpkg-statoverride --update --add netdata netdata 0755 /var/run/netdata
  44. fi
  45. if ! dpkg-statoverride --list /var/log/netdata > /dev/null 2>&1; then
  46. dpkg-statoverride --update --add netdata adm 02750 /var/log/netdata
  47. fi
  48. dpkg-statoverride --force --update --add root netdata 0775 /var/lib/netdata/registry > /dev/null 2>&1
  49. chown -R root:netdata /usr/libexec/netdata/plugins.d
  50. setcap cap_dac_read_search,cap_sys_ptrace+ep /usr/libexec/netdata/plugins.d/apps.plugin
  51. setcap cap_dac_read_search+ep /usr/libexec/netdata/plugins.d/slabinfo.plugin
  52. if capsh --supports=cap_perfmon 2>/dev/null; then
  53. setcap cap_perfmon+ep /usr/libexec/netdata/plugins.d/perf.plugin
  54. else
  55. setcap cap_sys_admin+ep /usr/libexec/netdata/plugins.d/perf.plugin
  56. fi
  57. if [ -f "/usr/libexec/netdata/plugins.d/go.d.plugin" ]; then
  58. setcap "cap_net_admin+epi cap_net_raw=eip" /usr/libexec/netdata/plugins.d/go.d.plugin
  59. fi
  60. chmod 4750 /usr/libexec/netdata/plugins.d/cgroup-network
  61. chmod 4750 /usr/libexec/netdata/plugins.d/nfacct.plugin
  62. # Workaround if system does not have ebpf.plugin
  63. chmod -f 4750 /usr/libexec/netdata/plugins.d/ebpf.plugin || true
  64. # Workaround for other plugins not installed directly by this package
  65. chmod -f 4750 /usr/libexec/netdata/plugins.d/freeipmi.plugin || true
  66. chmod -f 4750 /usr/libexec/netdata/plugins.d/ioping || true
  67. ;;
  68. esac
  69. #DEBHELPER#
  70. exit 0