#!/bin/sh

set -e

# Template processing in Template.pm: /var/lib/bugzilla3/data/template/var/lib/bugzilla3/template has to be a sym-link otherwise something gone worse and checksetup_nondebian.pl will fail.
f="$BUGZILLA_DATADIR/data/template$BUGZILLA_DATADIR/template"
if test -d "$f"; then
	# WORKARROUND AS LONG THE REAL PROBLEM IS NOT FIXED
	for d in `find "$f" -maxdepth 1 -type d`; do
		if test -d "$d/default"; then
			mv -v "$d" "$BUGZILLA_DATADIR/data/template"
		fi
	done
	rm -rvf "$BUGZILLA_DATADIR/data/template/var"
elif test -s "$f"; then
	# We also remove the sym-link.
	rm -rvf "$BUGZILLA_DATADIR/data/template/var"
fi

exit 0
