From 5fe654e7e87b73041c4021b3c4201e12dd03c7f1 Mon Sep 17 00:00:00 2001
From: HungryHobo <HungryHobo@mail.i2p>
Date: Sat, 13 Nov 2010 17:55:34 +0000
Subject: [PATCH] Abort if any command in the script exits with an error
 (lintian: maintainer-script-ignores-errors)

---
 debian/scripts/postinst | 2 ++
 debian/scripts/postrm   | 6 ++++--
 debian/scripts/prerm    | 2 ++
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/debian/scripts/postinst b/debian/scripts/postinst
index 24ed3e3de3..f6d7c034b5 100755
--- a/debian/scripts/postinst
+++ b/debian/scripts/postinst
@@ -1,4 +1,6 @@
 #!/bin/sh
+set -e
+
 SVCHOME=/var/lib/i2p
 I2P=/usr/share/i2p
 I2PUSER=i2psvc
diff --git a/debian/scripts/postrm b/debian/scripts/postrm
index 38a4170ab1..83f06ce781 100755
--- a/debian/scripts/postrm
+++ b/debian/scripts/postrm
@@ -1,12 +1,14 @@
 #!/bin/sh
+set -e
 
 # /etc/rc*.d/*i2p files	
 update-rc.d -f i2p remove
 
 I2PUSER=i2psvc
 # delete $I2PUSER if it exists (it will not if this is a purge after a remove)
-id $I2PUSER 2>/dev/null
-if [ $? -eq 0 ]; then
+# the "| cat" sets the exit code to zero so the script doesn't abort
+entry=`getent passwd | cut -d: -f1 | grep i2psvc | cat`
+if [ -n "$entry" ]; then
     exec userdel $I2PUSER
 fi
 
diff --git a/debian/scripts/prerm b/debian/scripts/prerm
index 18c1f79282..1777a4ecba 100755
--- a/debian/scripts/prerm
+++ b/debian/scripts/prerm
@@ -1,4 +1,6 @@
 #!/bin/sh
+set -e
+
 invoke-rc.d i2p stop
 
 # stuff in /tmp
-- 
GitLab