#!/bin/sh

cd /etc/adsm || exit 1

INCLEXCL=`mktemp -t`
[ -e "$INCLEXCL" ] || exit 1
chmod 0644 "$INCLEXCL"

cat <<EOF > "$INCLEXCL"
* automatically generated by /usr/lib/tivoli/merge-inclexcl
* please do:
*    /etc/init.d/tivoli-tsm restart
* after changing any included file to regenerate this file
* and make changes active

EOF

for i in `run-parts --list /etc/adsm/inclexcl.d` ; do
	echo "*** $i" >> "$INCLEXCL"
	cat "$i" >> "$INCLEXCL"
	echo "" >> "$INCLEXCL"
done

[ -e /etc/adsm/merged-inclexcl ] && cmp --silent /etc/adsm/merged-inclexcl "$INCLEXCL" || cp "$INCLEXCL" /etc/adsm/merged-inclexcl
rm "$INCLEXCL"

exit 0
