#!/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

if SourceIfNotEmpty /etc/sysconfig/i18n; then
	if [ -n "$LANGUAGE" ]; then
		LISTLANG="`echo $LANGUAGE |tr ':' ' '`"
	else
		if [ -n "$LANG" ]; then
			LISTLANG="$LANG"
		else
			LISTLANG=en
		fi
	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
fi

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_/`locale |grep ^LANG= |cut -d= -f2-`/" "$f"
done

:
