#!/bin/sh

user=${USER:-`id -un`}
cvshost="juw27.nfra.nl"
if [ -d /export/home/jive_cvs/JCCS ]; then
	cvshost=`hostname`.nfra.nl
fi

newroot=":ext:jive_cc@${cvshost}:"

# generate sedscript
sedscript="/tmp/sedscript-${user}"
tmpsed="/tmp/tmpsed-${user}"
cat > ${sedscript} << EOF
/jive_cvs/{
	s/^.\{0,\}:\([^:]\{1,\}\)$/${newroot}\1/
}
EOF

for f in `find . -name Root`; do
	rm -f ${tmpsed}
	sed -f ${sedscript} ${f} > ${tmpsed}
	dif=`diff ${f} ${tmpsed}`
	# if there are differences.. backup + replace
	if [ -n "${dif}" ]; then
		echo ${f}
		mv ${f} ${f}.1
		mv ${tmpsed} ${f}
	fi
done

rm -f ${sedscript}
