preinst is in gearman-job-server 1.0.6-3.
This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.
The actual contents of the file can be viewed below.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | #!/bin/sh
set -e
GROUP="gearman"
USER="gearman"
DATADIR="/var/lib/gearman"
# shamelessly copied from debian mysql-server package...
#
# Now we have to ensure the following state: (100, 101 are examples)
# /etc/passwd: gearman:x:100:101:Gearman Job Server:/var/lib/gearman:/bin/false
# /etc/group:  gearman:x:101:
# 
# Sadly there could any state be present on the system so we have to
# modify everything carefully i.e. not doing a chown before creating
# the user etc...
# creating gearman group if he isn't already there
if ! getent group $GROUP >/dev/null ; then
        # Adding system group
        addgroup --system $GROUP >/dev/null
fi
# creating gearman user if he isn't already there
if ! getent passwd $USER >/dev/null ; then
        # Adding system user
        adduser \
          --system \
          --disabled-login \
          --ingroup $GROUP \
          --home $DATADIR \
          --gecos "Gearman Job Server" \
          --shell /bin/false \
          $USER  >/dev/null
else
        if ! test -d $DATADIR ; then
                mkdir -p $DATADIR
                chown $USER $DATADIR
        fi
        # Take care of folks who installed when we set homedir to /nonexistent
        if getent passwd $USER | grep nonexistent >/dev/null ; then
                usermod -d $DATADIR $USER
        fi
fi
# Automatically added by dh_installinit
if [ "$1" = install ] || [ "$1" = upgrade ]; then
	if [ -e "/etc/init.d/gearman-job-server" ] && [ -L "/etc/init.d/gearman-job-server" ] \
	   && [ $(readlink -f "/etc/init.d/gearman-job-server") = /lib/init/upstart-job ]
	then
		rm -f "/etc/init.d/gearman-job-server"
	fi
fi
# End automatically added section
 |