#!/bin/sh
#script to substitude example.com by local domain name
#
DOMAIN=`/bin/dnsdomainname`
if [ "x$DOMAIN" = "x" ]; then
   exit 1
fi
DOMAINUP=`echo $DOMAIN|tr '[[:lower:]]' '[[:upper:]]'`
LDAPBASE="dc=`echo $DOMAIN|sed -e "s/\./,dc=/g"`"

FILES="-=FILELIST=-"

echo "I'm going to substitute EXAMPLE.COM by your domainname ($DOMAINUP)
in the following configuration files:
"
echo "$FILES"|xargs|sed -e "s/\s/\n/g"|sed -e"s/^/ -/g"
read -e -t 10 -p '
Do you really want to proceed [yes/NO]?'
if [ "x$REPLY" = "xyes" ]; then
    for file in $FILES; do
	if [ -f $file ] ; then
	/usr/bin/subst "s,example\.com,$DOMAIN,
	s,EXAMPLE\.COM,$DOMAINUP,
	s/dc=example\,dc=com/$LDAPBASE/" $file
	fi
    done
    echo "Done."
else
    echo "Good choice!
Suppose you wish to edit these files by yourself."
fi
