On Fri, May 08, 2009 at 03:08:15PM -0700, Russ Allbery wrote:
> Stig Sandbeck Mathisen <s...@debian.org> writes:
> 
> >  * Moving adduser from Depends: to Pre-Depends
> 
> This requires debian-devel discussion and approval.

Red Tape Surprise. :)  Probably not without reasons.

> Why is puppet calling adduser in preinst anyway?  Usually this can be done in
> postinst.

From my tiny bit of testing, it seems to be working fine from postinst. I've
updated my patch to do the following:

* Moving adduser call from preinst to postinst

* adding "--quiet" to adduser, and removing redirection of output to /dev/null

* Running adduser only if the "puppet" account is not present

* Running deluser and delgroup only if the binaries are present on the system

-- 
Stig Sandbeck Mathisen <s...@debian.org>
  Computers have feelings too!
 debian/puppet.postinst |    5 +++++
 debian/puppet.postrm   |   13 +++++++++++--
 debian/puppet.preinst  |   25 -------------------------
 3 files changed, 16 insertions(+), 27 deletions(-)

diff --git a/debian/puppet.postinst b/debian/puppet.postinst
index ac765ba..e91a3ae 100644
--- a/debian/puppet.postinst
+++ b/debian/puppet.postinst
@@ -1,6 +1,11 @@
 #!/bin/sh -e
 
 if [ "$1" = "configure" ]; then
+	if ! getent passwd puppet > /dev/null; then
+		adduser --quiet --system --group --home /var/lib/puppet  \
+			--gecos "Puppet configuration management daemon" \
+			puppet
+	fi
 	if [ -d /etc/puppet/ssl ] && [ ! -e /var/lib/puppet/ssl ] && grep -q 'ssldir=/var/lib/puppet/ssl' /etc/puppet/puppet.conf; then
 		mv /etc/puppet/ssl /var/lib/puppet/ssl
 	fi
diff --git a/debian/puppet.postrm b/debian/puppet.postrm
index b1156cf..86fb28b 100644
--- a/debian/puppet.postrm
+++ b/debian/puppet.postrm
@@ -3,8 +3,17 @@
 case "$1" in
     purge)
 	rm -rf /var/lib/puppet
-	deluser --system puppet
-	delgroup --system puppet
+	if [ -x "$(command -v deluser)" ]; then
+	    deluser --system puppet
+	else
+	    echo >&2 'Not removing system user "puppet" ("deluser" is not found)'
+	fi
+	
+	if [ -x "$(command -v delgroup)" ]; then
+	    delgroup --system puppet
+	else
+	    echo >&2 'Not removing system group "puppet" ("delgroup" is not found)'
+	fi
 	rm -f /etc/puppet/puppetd.conf
 	;;
     remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
diff --git a/debian/puppet.preinst b/debian/puppet.preinst
deleted file mode 100644
index 43ddc49..0000000
--- a/debian/puppet.preinst
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/sh -e
-
-case "$1" in
-    install|upgrade)
-	adduser --system \
-	    --group \
-	    --home /var/lib/puppet \
-	    --gecos "Puppet configuration management daemon" \
-	    puppet > /dev/null
-    ;;
-
-    abort-upgrade)
-    ;;
-
-    *)
-        echo "preinst called with unknown argument \`$1'" >&2
-        exit 1
-    ;;
-esac
-
-#DEBHELPER#
-
-exit 0
-
-

Attachment: signature.asc
Description: Digital signature

Reply via email to