[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: packaging help



On Tue, Apr 24, 2012 at 8:16 AM, Whit Armstrong
<armstrong.whit@gmail.com> wrote:
> Thanks, Daniel.
>
> I would be looking for 60000-64999, assuming my package eventually
> made it into debian, I suppose it would need to have a 'globally
> allocated' uid.  The idea is simply not to give users executing an R
> script on the machine root access.
>
> Regarding, reSIProcate, it's cdbs based?  Would the postinst script be
> the same format if I use dh?  Based on Lucas Nussbaum's tutorial
> (http://www.debian.org/doc/manuals/packaging-tutorial/packaging-tutorial.en.pdf)
> I thought that dh would be the way to go for new packages.

I've used the postinst script from the puppet package for creating a
user. Here is my "version" of it:

---{start}---
#!/bin/sh

set -e

if [ "$1" = "configure" ]; then

  # Create the "mailregx" user
  if ! getent passwd mailregx > /dev/null; then
    adduser --quiet --system --group --home /var/run/milter-regex  \
      --no-create-home                                 \
      --gecos "milter-regex daemon user" \
      mailregx
  fi

  # Create the "mailregx" group, if it is missing, and set the
  # primary group of the "mailregx" user to this group.
  if ! getent group mailregx > /dev/null; then
      addgroup --quiet --system mailregx
      usermod -g mailregx mailregx
  fi
fi

#DEBHELPER#
---{end}---

The "#DEBHELPER#" chunk is a callback or an include. It allows dh to
insert code into the script.

After my package is built, the postinst looks like:

---{start}---
#!/bin/sh

set -e

if [ "$1" = "configure" ]; then

  # Create the "mailregx" user
  if ! getent passwd mailregx > /dev/null; then
    adduser --quiet --system --group --home /var/run/milter-regex  \
      --no-create-home                                 \
      --gecos "milter-regex daemon user" \
      mailregx
  fi

  # Create the "mailregx" group, if it is missing, and set the
  # primary group of the "mailregx" user to this group.
  if ! getent group mailregx > /dev/null; then
      addgroup --quiet --system mailregx
      usermod -g mailregx mailregx
  fi
fi

# Automatically added by dh_installinit
if [ -x "/etc/init.d/milter-regex" ]; then
	update-rc.d milter-regex defaults >/dev/null
	invoke-rc.d milter-regex start || exit $?
fi
# End automatically added section
---{end}---

You can see the things that dh can put into the various post/pre
scripts in /usr/share/debhelper/autoscripts.

HTH,

-mz


Reply to: