post_install() {
	# create group and user
	getent group www-data &>/dev/null || groupadd -g 82 www-data >/dev/null
	if ! getent group darkhttpd &>/dev/null; then
		groupadd -r darkhttpd >/dev/null
	fi
	if ! getent passwd darkhttpd &>/dev/null; then
		useradd -r -c "darkhttpd user" -d /var/www/localhost/htdocs -g darkhttpd -s /bin/nologin darkhttpd >/dev/null
		usermod -aG www-data darkhttpd
	fi

	# create initial directory
	mkdir -p /var/www/localhost/htdocs
}

post_upgrade() {
	post_install
}

post_remove() {
	# delete group and user
	if getent passwd darkhttpd &>/dev/null; then
		userdel darkhttpd >/dev/null
	fi
	if getent group darkhttpd &>/dev/null; then
		groupdel darkhttpd >/dev/null
	fi
}