ldap-server/index.sh
2020-05-13 17:34:07 -04:00

37 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
set -e
org_name="Theta42"
domain="theta42.com"
password=$1
ldap_base="dc=theta42,dc=com"
echo "slapd slapd/internal/adminpw string $password" | debconf-set-selections
echo "slapd slapd/password1 string $password" | debconf-set-selections
echo "slapd slapd/password2 string $password" | debconf-set-selections
echo "slapd slapd/domain string $domain" | debconf-set-selections
echo "slapd slapd/backend string MDB" | debconf-set-selections
echo "slapd shared/organization string $org_name" | debconf-set-selections
echo "slapd slapd/purge_database boolean true" | debconf-set-selections
echo "slapd slapd/password_mismatchs string $password" | debconf-set-selections
echo "slapd slapd/no_configuration boolean false" | debconf-set-selections
echo "slapd slapd/allow_ldap_v2 string false" | debconf-set-selections
echo "slapd slapd/dump_database string when needed" | debconf-set-selections
echo "slapd slapd/move_old_database boolean true" | debconf-set-selections
echo "slapd slapd/invalid_config boolean true" | debconf-set-selections
apt install -y slapd ldap-utils
echo '' > /etc/ldap/ldap.conf
echo 'BASE $ldap_base' >> /etc/ldap/ldap.conf
echo 'URI ldap://localhost' >> /etc/ldap/ldap.conf
ldapadd -Y EXTERNAL -H ldapi:/// -f files/sshkey.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f files/sudo.ldif
ldapmodify -Q -Y EXTERNAL -H ldapi:/// -f files/add_index.ldif
ldapmodify -Q -Y EXTERNAL -H ldapi:/// -f files/logging.ldif
ldapadd -Q -Y EXTERNAL -H ldapi:/// -f files/memberof_config.ldif
ldapmodify -Q -Y EXTERNAL -H ldapi:/// -f files/refint1.ldif
ldapadd -Q -Y EXTERNAL -H ldapi:/// -f files/refint2.ldif