netdata.postinst 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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|recnfigure)
  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. if ! dpkg-statoverride --list /var/lib/netdata > /dev/null 2>&1; then
  29. dpkg-statoverride --update --add netdata netdata 0755 /var/lib/netdata
  30. fi
  31. if ! dpkg-statoverride --list /var/lib/netdata/www > /dev/null 2>&1; then
  32. dpkg-statoverride --update --add root netdata 0755 /var/lib/netdata/www
  33. fi
  34. if ! dpkg-statoverride --list /var/cache/netdata > /dev/null 2>&1; then
  35. dpkg-statoverride --update --add netdata netdata 0755 /var/cache/netdata
  36. fi
  37. if ! dpkg-statoverride --list /var/run/netdata > /dev/null 2>&1; then
  38. dpkg-statoverride --update --add netdata netdata 0755 /var/run/netdata
  39. fi
  40. if ! dpkg-statoverride --list /var/log/netdata > /dev/null 2>&1; then
  41. dpkg-statoverride --update --add netdata adm 02750 /var/log/netdata
  42. fi
  43. dpkg-statoverride --force --update --add root netdata 0775 /var/lib/netdata/registry > /dev/null 2>&1
  44. chown -R root:netdata /usr/libexec/netdata/plugins.d
  45. setcap cap_dac_read_search,cap_sys_ptrace+ep /usr/libexec/netdata/plugins.d/apps.plugin
  46. setcap cap_dac_read_search+ep /usr/libexec/netdata/plugins.d/slabinfo.plugin
  47. if capsh --supports=cap_perfmon 2>/dev/null; then
  48. setcap cap_perfmon+ep /usr/libexec/netdata/plugins.d/perf.plugin
  49. else
  50. setcap cap_sys_admin+ep /usr/libexec/netdata/plugins.d/perf.plugin
  51. fi
  52. if [ -f "/usr/libexec/netdata/plugins.d/go.d.plugin" ]; then
  53. setcap cap_net_admin+epi /usr/libexec/netdata/plugins.d/go.d.plugin
  54. fi
  55. chmod 4750 /usr/libexec/netdata/plugins.d/cgroup-network
  56. chmod 4750 /usr/libexec/netdata/plugins.d/nfacct.plugin
  57. # Workaround if system does not have ebpf.plugin
  58. chmod -f 4750 /usr/libexec/netdata/plugins.d/ebpf.plugin || true
  59. # Workaround for other plugins not installed directly by this package
  60. chmod -f 4750 /usr/libexec/netdata/plugins.d/freeipmi.plugin || true
  61. chmod -f 4750 /usr/libexec/netdata/plugins.d/ioping || true
  62. ;;
  63. esac
  64. #DEBHELPER#
  65. exit 0