Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Git config from ldap (/etc/profile.d/gitconfig.sh)
# Set git user/email based on ldap values
test -x /usr/bin/git || return
test -x /usr/bin/ldapsearch || return
git config --global user.name > /dev/null || {
name=$(ldapsearch -x -LLL "(uid=$USER)" cn | sed -ne 's/^cn: //p')
test -n "$name" && git config --global user.name "$name"
}
git config --global user.email > /dev/null || {
email=$(ldapsearch -x -LLL "(uid=$USER)" mail| sed -ne 's/^mail: //p')
test -n "$email" && git config --global user.email "$email"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.