#!/bin/sh
# --------------------------------------------------------------------------
# Copyright 1993 by Forschungszentrum Informatik (FZI)
#
# You can use and distribute this software under the terms of the license
# version 1 you should have received along with this software.
# If not or if you want additional information, write to
# Forschungszentrum Informatik, "STONE", Haid-und-Neu-Strasse 10-14,
# D-76131 Karlsruhe, Germany.
# --------------------------------------------------------------------------
# 'obst-cpcnt - 10.03.93 - Oliver Spatscheck'
#
# obst-cpcnt
#
# Copies the containers from $1 into $2.
# ('cp' denies copying a file onto itself.)
#
# Installs an empty a subdirectory 'process' in $2.

[ $# != 2 ] &&  \
   { echo >&2 "*** usage: obst-cpcnt source_dir destination_dir"; exit 1;}

from=$1
  to=$2

# check $from and create/check $to 
[ -d $from ] || { echo >&2 "$from is not a valid directory"; exit 1;}
[ -f $to ]   || [ -d $to ] || mkdir $to
[ -d $to ]   || { echo >&2 "can not create $to directory"; exit 1;}

# clear cnts & copy
rm -f $to/[0-9]*
cp -p $from/[0-9]* $to

# create & clear process directory
[ -d $to/process ] || mkdir $to/process
rm -f $to/process/* 

# clear & copy the version file (if available)
rm -f $to/version
[ -f $from/version ] && cp -p $from/version "$to"

chmod u+w  $to/[0-9]*
chmod u+wx $to/process
touch $to/[0-9]*
