File: sysuser-helper

package info (click to toggle)
dh-sysuser 1.6.0
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 124 kB
  • sloc: perl: 437; sh: 42; makefile: 5
file content (42 lines) | stat: -rwxr-xr-x 1,800 bytes parent folder | download
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
#!/bin/sh
set -eu
exec >/dev/null # only errors should pass.
command="${1}" ; shift

case "${command}" in
    postinst)
        if ! getent passwd "$CONF_USERNAME" ; then
           if [ "${CONF_HOME}" != '/nonexistent' ] ; then
               #what if home already exists? UID will unlikely match..
               # If the user already has another home directory, we use `usermod
               # --move-home'. Unfortunately, a new home is required to be
               # non-existent (and different from previous), so this
               # condition is required.
               #if [ ! -d "$CONF_HOME" ] ; then
                #    usermod --move-home --home "$CONF_HOME" "$CONF_USERNAME"
               #fi
               adduser --system --group --comment "Created by dh-sysuser for ${CONF_PACKAGE}" --home "${CONF_HOME}" "${CONF_USERNAME}"
           else
               adduser --system --group --comment "Created by dh-sysuser for ${CONF_PACKAGE}" "${CONF_USERNAME}"
           fi
        fi
        ;;
    prerm)
	#no-op, to avoid transition 1.3.5 --> 1.4; to be removed when nothing is build with dh-sysuser < 1.4
	#1.4 moves purge logic from prerm to postrm, but packages builded with dh-sysuser < 1.4 will still call
	#syuser-helper in prerm and not in postrm
	;;
    postrm)
        # keep purge logic in case in future a debconf question is added
        case ${1:-} in
            purge|abort-install)
#		if [ "${CONF_HOME}" != '/nonexistent' ] ; then
#			rmdir --ignore-fail-on-non-empty "${CONF_HOME}"
#		fi
#                if ! [ -d "${CONF_HOME}" ] ; then
#                   if ! userdel --force "${CONF_USERNAME}" ; then
#                      echo >&2 "warning: failed to remove ${CONF_USERNAME}. Proceeding anyway."
#                   fi
#                fi
        esac
esac