aboutsummaryrefslogtreecommitdiffstats
path: root/net/openldap21-server/pkg-install
blob: 34ee897a19965c9cdc1d7b91d1b024ba23636bed (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
#
# $FreeBSD$
#

CHOWN=/usr/sbin/chown
ECHO_CMD=echo
GREP=/usr/bin/grep
PKG_INFO=/usr/sbin/pkg_info
PW=/usr/sbin/pw

FTPUSERS=/etc/ftpusers

case $2 in
PRE-INSTALL)
  if [ -z "`${PKG_INFO} -I '%%PKGNAME_CLIENT%%' 2> /dev/null`" ]; then
    ${ECHO_CMD} "===>  %%PKGNAME%% requires %%PKGNAME_CLIENT%%."
    ${ECHO_CMD}
    ${ECHO_CMD} "      Please install %%PKGNAME_CLIENT%% manually."
    exit 1
  fi
  if ! ${PW} usershow -n ldap >/dev/null 2>&1; then
    ${ECHO_CMD}
    if ! ${PW} groupshow -n ldap >/dev/null 2>&1; then
      if ! ${PW} groupadd -n ldap -g 389; then
        ${ECHO_CMD} "*** Failed to add a group ldap with id 389."
        ${ECHO_CMD}
        ${ECHO_CMD} "Please add the ldap user manually with"
        ${ECHO_CMD} "  ${PW} useradd -n ldap -g ldap -c 'OpenLDAP server' \\"
        ${ECHO_CMD} "  -d /nonexistent -s /sbin/nologin -h -"        
        ${ECHO_CMD} "and retry installing this package."
        exit 1
      fi
      ${ECHO_CMD} "===>  Group 'ldap' created."
    fi
    if ! ${PW} useradd -n ldap -u 389 -g ldap -c 'OpenLDAP Server' \
        -d /nonexistent -s /sbin/nologin -h -; then
      ${ECHO_CMD} "*** Failed to add an user ldap with id 389."
      ${ECHO_CMD}
      ${ECHO_CMD} "Please add the ldap user manually with"
      ${ECHO_CMD} "  ${PW} useradd -n ldap -g ldap -c 'OpenLDAP server' \\"
      ${ECHO_CMD} "  -d /nonexistent -s /sbin/nologin -h -"        
      ${ECHO_CMD} "and retry installing this package."
      exit 1
    fi
    ${GREP} -qs '^ldap$' ${FTPUSERS} || ${ECHO_CMD} ldap >> ${FTPUSERS}
    ${ECHO_CMD} "===>  Account 'ldap' created."
  fi
  ;;
esac