ltcp/aufgabe3.5/ldap-tools/ldap-add-ldif

24 lines
379 B
Bash
Executable File

#!/bin/sh
# check for root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
# check for arguments
if [[ $# -gt 1 ]]; then
echo "USAGE: $0 [filename]" 1>&2
exit 1
fi
SECRET="`cat /etc/ldap.secret`"
if [[ $# -lt 1 ]]
then
ldapadd -D cn=admin,dc=zotac,dc=lctp -w "$SECRET"
else
ldapadd -D cn=admin,dc=zotac,dc=lctp -w "$SECRET" -f "$1"
fi