commit ac70f1831673d1b64c2aeaebde4c0d6a04a840e5
Author: Jeroen Dekkers <jeroen@dekkers.ch>
Date:   Fri Jul 6 17:14:38 2012 +0200

    Fix postinst and postrm

diff --git a/debian/yate.postinst b/debian/yate.postinst
index bab0699..93fcdbe 100644
--- a/debian/yate.postinst
+++ b/debian/yate.postinst
@@ -2,33 +2,29 @@
 
 set -e
 
-if [ "$1" = "configure" ]; then
-	if [ "$2" = "" ];then
-		. /etc/default/yate
-		echo "Creating/updating yate user account and group..."
-		addgroup --system $YATE_GROUP || {
-		  # addgroup failed. Why?
-				if ! getent group $YATE_GROUP >/dev/null ; then
-					echo "Could not create system group $YATE_GROUP." >&2
-					exit 1
-				fi
-		  # well, the group is there, so just ignore the error
-		}
-		adduser --system --ingroup $YATE_GROUP --home /var/lib/yate \
-		    --gecos "YATE daemon" --shell /bin/sh \
-		    --disabled-password $YATE_USER || {
-		  # adduser failed. Why?
-				if getent passwd $YATE_USER >/dev/null ; then
-					echo "Non-system user $YATE_USER found. I will not overwrite a non-system" >&2
-					echo "user.  Remove the user and reinstall yate." >&2
-					exit 1
-				fi
-		  # unknown adduser error, simply exit
-				exit 1
-		}
-		mkdir -p /var/lib/yate
-		chown -R $YATE_USER.$YATE_GROUP /var/lib/yate
+case "$1" in
+    configure)
+	if ! getent group yate > /dev/null ; then
+	    echo 'Adding system-groupr for yate' 1>&2
+	    addgroup --system yate
 	fi
-fi
+
+	if ! getent passwd yate > /dev/null ; then
+	    adduser --system --ingroup yate --home /var/lib/yate \
+		--gecos "YATE daemon" --shell /bin/sh \
+		--disabled-password yate
+	fi
+
+	mkdir -p /var/lib/yate
+	chown -R yate:yate /var/lib/yate
+	;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+        ;;
+
+    *)
+	echo "postinst called with unknown argument \`$1'" >&2
+	exit 0
+esac
 
 #DEBHELPER#
diff --git a/debian/yate.postrm b/debian/yate.postrm
index d6b8e8c..7ac8508 100644
--- a/debian/yate.postrm
+++ b/debian/yate.postrm
@@ -2,13 +2,19 @@
 
 set -e
 
-if [ "$1" = "remove" ]; then
-	if [ "$2" = "purge" ];then
-		. /etc/default/yate
-		deluser --quiet --system $YATE_USER
-		delgroup --quiet $YATE_GROUP
-		rmdir --ignore-fail-on-non-empty /var/lib/yate
-	fi
-fi
+case "$1" in
+    purge)
+	deluser --quiet --system yate || true
+	delgroup --quiet yate || true
+	rm -rf /var/lib/yate
+	;;
+
+    remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+	;;
+
+    *)
+	echo "postrm called with unknown argument \`$1'" >&2
+        exit 0
+esac
 
 #DEBHELPER#
