#!/bin/sh

CONFDIR=__MVC_RELOCATE____MVC_CATROOT__/config
TAGDIR=__MVC_RELOCATE____MVC_VENDROOT__/code/template_tag/__MVC_DEMOTYPE__

die() {
	echo $1
	exit 1
}

cd $CONFDIR || die "Cannot find $CONFDIR to change to.";

if [ "x`whoami`" = xroot ]
then
	ISROOT=1
else
	ISROOT=0
fi

if test -d $TAGDIR
then
	HASTAGDIR=1
else 
	mkdir -p __MVC_RELOCATE____MVC_VENDROOT__/code/template_tag/__MVC_DEMOTYPE__ \
		|| die "Cannot make $TAGDIR"
fi

for f in *.tag *.am
do
	if test -f __MVC_RELOCATE____MVC_VENDROOT__/usertag/$f
	then
		echo "$f appears to be in global usertag/ directory, skipping."
	else
		cp $f $TAGDIR || die "Cannot copy $f to $TAGDIR: $!"
	fi
done

for f in *.filter
do
	if test -f __MVC_RELOCATE____MVC_VENDROOT__/filter/$f
	then
		echo "$f appears to be in global filter/ directory, skipping."
	else
		cp $f $TAGDIR || die "Cannot copy $f to $TAGDIR: $!"
	fi
done
