#!/bin/sh

cd /usr/share/doc/HTML >/dev/null 2>&1 || exit 0

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

# Source function library.
. /etc/init.d/functions

SourceIfNotEmpty /etc/sysconfig/i18n

if [ -n "$LANG" ]; then
	LISTLANG="$LANG en"
else
	LISTLANG=en
fi

for i in $LISTLANG; do
	if [ -r "index-$i.html" ]; then
		cp -p "index-$i.html" "index.html"
		break
	else
		lang=`echo "$i" |cut -b-2`
		if [ -r "index-$lang.html" ]; then
			cp -p "index-$lang.html" "index.html"
			break
		fi
	fi
done

for f in index*.html; do
	[ -w "$f" ] || continue
	subst "s/_RAND_/`head -c 32 /dev/urandom |md5sum |cut -d\  -f1`/" "$f"
	subst "s/_LOCALE_/$LANG/" "$f"
done

:
