#!/bin/sh # Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # # Originally written by me for the mdk distro # On the old header you can find my old email # # Last update 20050401 - Christian Zoffoli # VERSION="0.3" openssl="/usr/bin/openssl" opensslopts="" ldapconfdir="/etc/openldap/ssl" pemfile="${ldapconfdir}/ldap.pem" randfile="${ldapconfdir}/ldap.rand" cfgfile="${ldapconfdir}/ldap.cfg" function fixperms { chown root:ldap ${ldapconfdir} -R find ${ldapconfdir} -type f -exec chmod 640 \{\} \; chmod 750 ${ldapconfdir} } if [ ! -x ${openssl} ]; then exit 0 fi if [ ! -d ${ldapconfdir} ]; then mkdir -p ${ldapconfdir} fi fixperms if [ -f ${pemfile} ]; then echo "${pemfile} already exist, dying" exit 0 fi dd if=/dev/urandom of=$randfile count=1 2>/dev/null echo "" echo "______________________________________________________________________${T_ME}" echo "" echo "Creating self-signed certificate -- Version ${VERSION}" echo "" echo "______________________________________________________________________${T_ME}" echo "" COMMONNAME=`hostname` if [ ! -n "$COMMONNAME" ]; then COMMONNAME="www.openldap.org" fi if [ -f ${cfgfile} ]; then echo "${cfgfile} found, would you like to use it ? (y/n)" read answer case "$answer" in y|Y) opensslopts="-batch" ;; n|N) cat >${cfgfile} <&2 exit 1 else echo -e "\nCertificate creation done!" fi if [ -f ${randfile} ]; then rm -f ${randfile} fi if [ -f ${pemfile} ]; then fixperms fi