#!/bin/sh
#
# Copyright (c) 1999 Software Engineering Research Laboratory,
# Department of Computer Science, University of Colorado at Boulder.
# All rights reserved.
# 
# This software was developed by the Software Engineering Research
# Laboratory of the University of Colorado at Boulder.  Redistribution
# and use in source and binary forms are permitted provided that:
# 
#    1. The above copyright notice and these paragraphs are duplicated 
#       in all such forms and that any documentation, and other 
#       materials related to such distribution and use acknowledge 
#       that the software was developed by the Software Engineering 
#       Research Laboratory of the University of Colorado at Boulder.
#    2. The redistribution and use of this software are solely for 
#       non-commercial purposes.
# 
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#

#
# Script to remove a repository.
#
# $Author: carzanig $
# $Revision: 1.1 $
# $Date: 2002/05/02 14:45:18 $
# $Locker:  $
# $Source: /local/home/carzanig/src/nucm/RCS/removerepository,v $
#

#
# Check number of arguments.
#
if [ $# -ne 1 ]
    then
	echo "Usage: $0 <repository directory>"
	exit 1
fi
REPOSITORY=$1

#
# Check for possible existing directory.
#
if [ ! -d $REPOSITORY ]
    then
	echo "$0: repository $REPOSITORY does not exist"
	exit 1
fi

#
# Check for signature.
#
if [ ! -r $REPOSITORY/ndb_signature ]
    then
	echo "$0: no signature $REPOSITORY/ndb_signature, are you sure this is a repository"
	exit 1
fi
signature="NUCM REPOSITORY: $REPOSITORY/ndb_signature"
recorded=`cat $REPOSITORY/ndb_signature`
if [ "$signature" != "$recorded" ]
    then
	echo "$0: signature $REPOSITORY/ndb_signature invalid, are you sure this is a repository"
	exit 1
fi

#
# Remove the repository.
#
rm -rf $REPOSITORY/ndb_entrypoints
rm -rf $REPOSITORY/ndb_artifacts
rm -rf $REPOSITORY/ndb_signature
rm -f $REPOSITORY/ndb_log
rmdir $REPOSITORY
