post_install() {
	if ! getent group mpd &>/dev/null; then
		groupadd -r -g 45 mpd >/dev/null
	fi
	if ! getent passwd mpd &>/dev/null; then
		useradd -r -u 45 -g mpd -d /var/lib/mpd -s /bin/nologin -G audio mpd >/dev/null
	fi
	mpd_shell=$(getent passwd mpd | cut -d: -f7)
	if [ "$mpd_shell" != '/bin/nologin' ]; then
		chsh -s /bin/nologin mpd &>/dev/null
	fi

	install -d -m750 /var/log/mpd
	chown mpd:mpd /var/log/mpd

	install -d -m750 /var/lib/mpd
	chown mpd:mpd /var/lib/mpd
}

post_upgrade() {
	post_install
}

post_remove() {
	if getent passwd mpd &>/dev/null; then
		userdel mpd >/dev/null
	fi
	if getent group mpd &>/dev/null; then
		groupdel mpd >/dev/null
	fi
}
