post_install() {
	echo
	echo -n ">>> Creating yacy system user and group... "
	getent group yacy &>/dev/null || groupadd -r yacy
	getent passwd yacy &>/dev/null || /usr/sbin/useradd --comment 'YaCy P2P Searchengine' --system -g yacy --home '/usr/share/yacy/' -s /bin/false yacy
	mkdir -p /var/lib/yacy
	chown -R yacy:yacy /var/lib/yacy /opt/yacy
	rm -f /usr/share/yacy/DATA
	ln -s /var/lib/yacy /usr/share/yacy/DATA
	echo "done"
	echo
}

post_upgrade() {
	chown -R yacy:yacy /var/lib/yacy /opt/yacy
	systemctl --system daemon-reload
}

pre_remove() {
	echo
	echo -n ">>> Removing yacy system user and group... "
	getent passwd yacy &>/dev/null &&
		/usr/sbin/userdel yacy &>/dev/null
	getent group yacy &>/dev/null &&
		groupdel yacy &>/dev/null
	rm -f /usr/share/yacy/DATA
	echo "done"
	echo
}

post_remove() {
	echo
	echo "-> All configfiles and the cache are in /var/lib/yacy/"
	echo "-> You may use this for another installation."
	echo "-> If you don't need it, you should delete it, because"
	echo "-> it may have grown very large"
}
