- #!/bin/bash
- # Script to auto install/configure OpenLDAP on Ubuntu 10.04
- #
- # Author: TorrentialStorm
- if [ "$(id -ru)" != "0" ]; then
- echo "This script must be run as root."
- exit
- fi
- apt-get install slapd
- rm -rf /var/lib/ldap/* /etc/slapd.d
- dpkg-reconfigure slapd
- TMPFILE=$(tempfile)
- DOMAIN=
- while [ -z "$DOMAIN" ]; do
- whiptail --nocancel --inputbox "Domain Name:" 10 50 "example.org" 2> "${TMPFILE}"
- DOMAIN=$(cat ${TMPFILE})
- TOPDOM=$(echo "${DOMAIN}" | cut -d. -f1)
- DOM=${DOMAIN}
- DOMAIN=$(echo "${DOMAIN}" | sed 's/\./,dc=/g')
- done
- PASSWORD=
- while [ -z "$PASSWORD" ]; do
- whiptail --nocancel --passwordbox "Admin Password:" 10 50 2> "${TMPFILE}"
- PASSWORD=$(cat ${TMPFILE})
- done
- ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/cosine.ldif
- ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/nis.ldif
- ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/inetorgperson.ldif
- ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/misc.ldif
- ldapadd -Y EXTERNAL -H ldapi:/// <<EOF
- # Load hdb backend module
- dn: cn=module{0},cn=config
- objectClass: olcModuleList
- cn: module
- olcModulepath: /usr/lib/ldap
- olcModuleload: {0}back_hdb
- # Create the hdb database and place the files under /var/lib/ldap
- dn: olcDatabase={1}hdb,cn=config
- objectClass: olcDatabaseConfig
- objectClass: olcHdbConfig
- olcDatabase: {1}hdb
- olcDbDirectory: /var/lib/ldap
- olcSuffix: dc=${DOMAIN}
- olcRootDN: cn=admin,dc=${DOMAIN}
- olcRootPW: ${PASSWORD}
- olcDbConfig: {0}set_cachesize 0 2097152 0
- olcDbConfig: {1}set_lk_max_objects 1500
- olcDbConfig: {2}set_lk_max_locks 1500
- olcDbConfig: {3}set_lk_max_lockers 1500
- olcLastMod: TRUE
- olcDbCheckpoint: 512 30
- olcDbIndex: uid pres,eq
- olcDbIndex: cn,sn,mail pres,eq,approx,sub
- olcDbIndex: objectClass eq
- EOF
- ldapadd -Y EXTERNAL -H ldapi:/// <<EOF
- dn: dc=$DOMAIN
- objectClass: dcObject
- objectclass: organization
- o: $DOM
- dc: $TOPDOM
- description: LDAP root
- dn: ou=People, dc=$DOMAIN
- ou: People
- objectclass: organizationalUnit
- dn: ou=Group, dc=$DOMAIN
- ou: Group
- objectclass: organizationalUnit
- EOF
- ldapmodify -Y EXTERNAL -H ldapi:/// <<EOF
- dn: olcDatabase={1}hdb,cn=config
- add: olcAccess
- olcAccess: {0}to attrs=userPassword,shadowLastChange by dn="cn=admin,dc=$DOMAIN" write by anonymous auth by self write by * none
- olcAccess: {1}to dn.subtree="" by * read
- olcAccess: {2}to * by dn="cn=admin,dc=$DOMAIN" write by * read
- EOF
- rm ${TMPFILE}
Script to auto config openldap on lucid
Posted by Anonymous on Sun 2nd May 2010 19:19
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.