aboutsummaryrefslogtreecommitdiffstats
path: root/mail/dkimproxy/files/pkg-install.in
blob: 999ccc8fff428fe6620030d4afb6acdfa79a00ab (plain) (blame)
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
#! /bin/sh
#
# $FreeBSD$

PATH=/bin:/usr/bin:/usr/sbin

case $2 in

PRE-INSTALL)
  echo "---> Starting install script:"

  if [ -z "%%USER%%" -o -z "%%GROUP%%" -o \
       -z "%%UID%%" -o -z "%%GID%%" ]; then
    echo "ERROR: A required pragma was empty"
    exit 1
  fi

  # Create group if required
  if pw group show "%%GROUP%%" >/dev/null 2>&1; then
    echo "---> Using existing group \"%%GROUP%%\""
  else
    echo "---> Adding group \"%%GROUP%%\" (%%GID%%)"
    /usr/sbin/pw groupadd %%GROUP%% -g %%GID%% || exit 1
  fi

  # Create user if required
  if pw user show "%%USER%%" >/dev/null 2>&1; then
    echo "---> Using existing user \"%%USER%%\""
  else
    echo "---> Adding user \"%%USER%%\" (%%UID%%)"
    pw useradd "%%USER%%" -u "%%UID%%" -g "%%GROUP%%" -h - \
      -d "/nonexistent" -s "/sbin/nologin" -c "DKIM Proxy Owner" || exit 1
  fi
  ;;

esac