#!/bin/sh

DB_USER="postgres"

if [ -f "/tmp/MailStation.upgrade" ]; then
	exit 0
fi

case "$SYNOPKG_PKG_STATUS" in
	UNINSTALL)
		# we need to drop db manually, because framework can't handle upgrade
		# it will drop db in upgrade
		/usr/bin/psql -U $DB_USER -c "drop database roundcubemail;"
		kill `cat /var/services/homes/*/.Maildir/fetchmail.pid`
		;;
	UPGRADE)
		;;
esac

exit 0
