#!/bin/sh

HOME=/home/www/pyuki
ORG1=$HOME/htdocs/release/pyukiwiki*devel
ORG2=$HOME/htdocs/release/pyukiwiki*devel-utf8
TMP=$HOME/tmp
TMP1=$HOME/tmp/PyukiWiki-Devel
TMP2=$HOME/tmp/PyukiWiki-Devel-UTF8
TEMP=$HOME/temp
TEMP1=$HOME/temp/PyukiWiki-Devel
TEMP2=$HOME/temp/PyukiWiki-Devel-UTF8
CVS=$HOME/CVS
CVS1=$HOME/CVS/PyukiWiki-Devel
CVS2=$HOME/CVS/PyukiWiki-Devel-UTF8
CP="$HOME/cp -Ru"

if [ -d $TMP1 ]; then
  if [ -d $TMP2 ]; then
echo Exist temp
mkdir $TEMP >/dev/null 2>/dev/null
mkdir $TEMP1 >/dev/null 2>/dev/null
mkdir $TEMP2 >/dev/null 2>/dev/null
	$CP $ORG1/*  $TEMP1
    $CP $ORG1/.ht*  $TEMP1
    $CP $ORG1/*/.ht*  $TEMP1
    $CP $ORG2/*  $TEMP2
    $CP $ORG2/.ht*  $TEMP2
    $CP $ORG2/*/.ht*  $TEMP2

    cd $TEMP
    for prc in `find .`
      do
      if [ -f $prc ]; then
#		if [ -f ../temp/$prc ]; then
#		  if [ -f ../tmp/$prc ]; then
            cmp $prc ../tmp/$prc >/dev/null 2>/dev/null
            if [ $? == 0 ]; then
              #echo delete $prc $?
              rm $prc
	  	    fi
#		  else
#		    echo ../tmp/$prc not found
#		  fi
#	    else
#	      echo ../temp/$prc not found
#        fi
      fi
    done

mkdir $TMP >/dev/null 2>/dev/null
mkdir $TMP1 >/dev/null 2>/dev/null
mkdir $TMP2 >/dev/null 2>/dev/null
	$CP $ORG1/*  $TMP1
    $CP $ORG1/.ht*  $TMP1
    $CP $ORG1/*/.ht*  $TMP1
    $CP $ORG2/*  $TMP2
    $CP $ORG2/.ht*  $TMP2
    $CP $ORG2/*/.ht*  $TMP2

	$CP $TEMP1/* $CVS1
	$CP $TEMP1/.ht*  $CVS1
	$CP $TEMP1/*/.ht*  $CVS1
	$CP $TEMP2/* $CVS2
	$CP $TEMP2/.ht*  $CVS2
	$CP $TEMP2/*/.ht*  $CVS2

  fi
else
echo Not exist temp
rm -rf $TMP1
rm -rf $TMP2
mkdir $TMP >/dev/null 2>/dev/null
mkdir $TMP1 >/dev/null 2>/dev/null
mkdir $TMP2 >/dev/null 2>/dev/null
rm -rf $TEMP1
rm -rf $TEMP2
mkdir $TEMP >/dev/null 2>/dev/null
mkdir $TEMP1 >/dev/null 2>/dev/null
mkdir $TEMP2 >/dev/null 2>/dev/null
	$CP $ORG1/*  $TEMP1
    $CP $ORG1/.ht*  $TEMP1
    $CP $ORG1/*/.ht*  $TEMP1
    $CP $ORG2/*  $TEMP2
    $CP $ORG2/.ht*  $TEMP2
    $CP $ORG2/*/.ht*  $TEMP2
	$CP $ORG1/*  $TMP1
    $CP $ORG1/.ht*  $TMP1
    $CP $ORG1/*/.ht*  $TMP1
    $CP $ORG2/*  $TMP2
    $CP $ORG2/.ht*  $TMP2
    $CP $ORG2/*/.ht*  $TMP2

	mkdir $TMP1 >/dev/null 2>/dev/null
	mkdir $TMP2 >/dev/null 2>/dev/null
	$CP $TMP1/* $CVS1
	$CP $TMP1/.ht*  $CVS1
	$CP $TMP1/*/.ht*  $CVS1
	$CP $TMP2/* $CVS2
	$CP $TMP2/.ht*  $CVS2
	$CP $TMP2/*/.ht*  $CVS2
fi

