ldap-admin/lib/common.sh

54 lines
908 B
Bash

#!/bin/bash
LDAP_SHELL=${LDAP_SHELL:-0}
function push() {
if [ $LDAP_SHELL -ne 1 ]; then
cat $@
else
cat $@ >> $LDIF_BASE
fi
}
function pop() {
if [ $LDAP_SHELL -eq 1 ]; then
:
fi
}
function discard() {
: > $LDIF_BASE
}
function basic-attr-op() {
tag-begin "$1 attribute $3 on DN $2 (value $4)"
push <<EOF
dn: $2
changetype: modify
$1: $3
$3: $4
EOF
tag-end
}
function maxgid() {
ldapsearch -x -ZZ -b 'ou=Group,dc=hackerspace,dc=pl' | grep gidNumber | cut -d' ' -f2 | sort -n | tail -n1
}
function maxuid() {
ldapsearch -x -ZZ -b 'ou=People,dc=hackerspace,dc=pl' | grep uidNumber | cut -d' ' -f2 | sort -n | tail -n1
}
function show-usage() {
$BIN_DIR/help `basename $0`
}
function tag-begin() {
push <<<"$TAG_PREFIX`printf "%*c" $((4 * $TAG_DEPTH )) " "; date`: $@"
((TAG_DEPTH+=1))
}
function tag-end() {
((TAG_DEPTH-=1))
}