]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - nixops/modules/gitolite/gitolite_ldap_groups.sh
Avoid using possibly non-existent file in activation script for peertube
[perso/Immae/Config/Nix.git] / nixops / modules / gitolite / gitolite_ldap_groups.sh
1 #!/usr/bin/env bash
2
3 uid_param="$1"
4 ldap_host="ldap.immae.eu"
5 ldap_binddn="cn=gitolite,ou=services,dc=immae,dc=eu"
6 ldap_bindpw="$LDAP_PASS"
7 ldap_searchbase="dc=immae,dc=eu"
8 ldap_scope="subtree"
9
10 ldap_options="-h ${ldap_host} -ZZ -x -D ${ldap_binddn} -w ${ldap_bindpw} -b ${ldap_searchbase} -s ${ldap_scope}"
11
12 ldap_filter="(&(memberOf=cn=groups,cn=gitolite,ou=services,dc=immae,dc=eu)(|(member=uid=${uid_param},ou=users,dc=immae,dc=eu)(member=uid=${uid_param},ou=group_users,dc=immae,dc=eu)))"
13 ldap_result=$(ldapsearch ${ldap_options} -LLL "${ldap_filter}" cn | grep 'cn:' | cut -d' ' -f2)
14
15 echo "$ldap_result"