#! /bin/sh

# BLURB gpl
# 
#                            Coda File System
#                               Release 6
# 
#           Copyright (c) 1987-2003 Carnegie Mellon University
#                   Additional copyrights listed below
# 
# This  code  is  distributed "AS IS" without warranty of any kind under
# the terms of the GNU General Public Licence Version 2, as shown in the
# file  LICENSE.  The  technical and financial  contributors to Coda are
# listed in the file CREDITS.
# 
#                         Additional copyrights
#                            none currently
# 
#*/

# Check that the imput parameters are correct
if [ $# != 1 ]
then
	echo "purgevol volumename"
	exit
fi

#
# Can only run these scripts from the SCM (Should this change?)
if [ `cat /vice/hostname` != `cat /vice/db/scm` ]
then
        echo "This must be run from the scm ("`cat /vice/db/scm`")"
        exit
fi

VOLNAME=$1
# Look up the volume in all volumes and find its server and number
# then go ahead and purge it
awk '
	$1 ~ /^'$VOLNAME'$/ { 
	print | "volutil -h "$3" purge "$2" " $1
	}
' /vice/vol/AllVolumes

#
# Delete the entry from the backup list.
VOLID=`awk '$1 ~ /^'$VOLNAME'$/ {print $2}' /vice/vol/AllVolumes`

awk ' $1 !~ /^'$VOLID'$/ { print } ' /vice/db/dumplist >/vice/db/dumplist.tmp
mv /vice/db/dumplist.tmp /vice/db/dumplist

#
# Update the VLDB
bldvldb.sh



