Re: test if user exists in postinst
On Mon, Apr 09, 2001 at 10:29:44PM +0200, Radovan Garabik wrote:
> I am cleaning up my packages, and one improvement
> I want to add is that network daemon runs under its
> own UID, not nobody (as it was until now).
>
> What is the best way of testing (and adding) a new username
> in postinst?
>
> I am using something like this:
> if ! grep -q '^xtelld:' /etc/passwd; then
> adduser --quiet --system --no-create-home --disabled-password --home /tmp --gecos "xtell daemon" xtelld
> fi
>
> the test for already existing user is not ideal, since
> users can be stored somewhere else (ldap, nis,...)
Try testing the exit code of 'id -u <user>'. That should work anywhere. Or,
rewrite your maintainer script in perl and use getpwnam().
--
- mdz
Reply to: