#!sh
#
# Install RCS
#

REMOVE=x
if [ -d /usr/new ]
then
	for p in ci co ident merge rcs rcsdiff rcsmerge rlog
	do
		if [ -f /usr/new/$p ]
		then
			REMOVE=$p
		fi
	done
fi

if [ -d /usr/new/lib ]
then
	for p in rdiff rdiff3 nosnoop snoop
	do
		if [ -f /usr/new/lib/$p ]
		then
			REMOVE=$p
		fi
	done
fi

if [ $REMOVE != x ]
then
	echo "All previous versions of the RCS commands should be moved from"
	echo "/usr/new & /usr/new/lib before installing this version of RCS"
	exit 1
fi

REMOVE=x
if [ -d /usr/contrib/bin ]
then
	for p in ci co ident merge rcs rcsdiff rcsmerge rlog
	do
		if [ -f /usr/contrib/bin/$p ]
		then
			REMOVE=$p
		fi
	done
fi

if [ -d /usr/contrib/lib ]
then
	for p in rdiff rdiff3 nosnoop snoop
	do
		if [ -f /usr/contrib/lib/$p ]
		then
			REMOVE=$p
		fi
	done
fi

if [ $REMOVE != x ]
then
	echo "All previous versions of the RCS commands should be moved from"
	echo "/usr/contrib/bin & /usr/contrib/lib before installing this"
	echo "version of RCS"
	exit 1
fi

DIRS='/usr/local/bin /usr/local/lib /usr/local/man/man1 /usr/local/man/man5'
PATH=.:/:/bin:/rom:/tmp:/etc:/usr:/usr/bin:/usr/etc:/usr/apps:/usr/util:/usr/local/bin:./bin:./.bin
PROJECT=`pwd`
export PATH PROJECT

for DEST in $DIRS
do
    if [ ! -d $DEST ]
    then
	echo "$DEST: No such directory"
	exit 1 
    fi
done

for DEST in $DIRS
do
    cd $PROJECT/$DEST
    for FILE in *
    do
	if [ ! -d $FILE ]
	then
	    echo Installing $FILE in $DEST
	    if [ -x $FILE ]
	    then
	        rm -f $DEST/$FILE
		cp $FILE $DEST && echo $FILE installed as $DEST/$FILE
	    else
		rm -f $DEST/$FILE
		cp $FILE $DEST && echo $FILE installed as $DEST/$FILE
	    fi
	fi
    done
done


