chown_netdata() {
	chown -R netdata:netdata /var/lib/netdata
	chown -R netdata:netdata /var/log/netdata
	chown -R netdata:netdata /var/cache/netdata
	chown -R netdata:netdata /usr/share/netdata/web
	chown -R netdata:netdata /etc/netdata
}

post_install() {
	getent group netdata > /dev/null || groupadd -g 134 netdata 1>/dev/null
	getent passwd netdata > /dev/null || useradd -u 134 -d /var/cache/netdata -g netdata -s /bin/nologin netdata 1>/dev/null

	chown_netdata

	echo
	echo "After the daemon has been started for the first time,"
	echo "download the default config file from"
	echo "http://127.0.0.1:19999/netdata.conf"
	echo
	echo "Copy it to /etc/netdata/ and modify it."
	echo
}

post_upgrade() {
	chown_netdata
}
