aboutsummaryrefslogtreecommitdiffstats
path: root/bin/ldap-krb5
blob: 368db8e414e79b185e1e8c95d46e2cf3a3f66be5 (plain)
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
#!/bin/sh

# Keep renewing/recreating kerberos tickets for ldap/hostname

if [ $(id -u) -ne 0 ]; then
    echo "Error: You are not root"
    exit 1
fi

. /etc/default/slapd
KSTART="k5start -b -f ${KRB5_KTNAME} -u ldap -i $(hostname --fqdn) -q -K 60"
case "${1}" in
  start)
    pgrep -U "${SLAPD_USER}" -G "${SLAPD_GROUP}" -fx "${KSTART}" >/dev/null \
        || sudo -u "${SLAPD_USER}" ${KSTART} \
        || exit 1
    ;;
  stop)
    pkill -U "${SLAPD_USER}" -G "${SLAPD_GROUP}" -fx "${KSTART}" >/dev/null \
    ;;
  *)
    echo "Usage: $0 {start|stop}" >&2
    exit 1
    ;;
esac