#!/bin/sh

set -e

case "${1}" in
	remove)
		_USERNAME="openerp"
		_GROUPNAME="openerp"

		if [ -x /usr/sbin/deluser ]
		then
			deluser --quiet --system ${_USERNAME}
		fi

		if [ -x /usr/sbin/delgroup ]
		then
			delgroup --quiet --system --only-if-empty ${_GROUPNAME} || true
		fi

		rm -f /usr/lib/openerp-server/addons/__init__.pyc
		rmdir --ignore-fail-on-non-empty /usr/lib/openerp-server/addons || true
		rmdir --ignore-fail-on-non-empty /usr/lib/openerp-server || true
		;;

	purge)
		rm -rf /var/lib/openerp-server
		;;

	upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)

		;;

	*)
		echo "postrm called with unknown argument \`${1}'" >&2
		exit 1
		;;
esac

#DEBHELPER#

exit 0
