#!/bin/ksh
#
# killvs:  ksh script front-end to the jukebox destroy volume set 
#          functionality of arcRead.
#
# Usage:
#
# killvs [-a acrcFile] -v volset_name
#
# -a acrcFile:     specify acrc file.  Optional if ACRC_FILE env. var is set.
# -v volset_name:  Name of the volume set to destroy.  Mandatory.
#
# JKH 9/95

#------------------------------------------------------------------------------
# A Usage function
#------------------------------------------------------------------------------

Usage()
{
    echo "Usage:"
    echo ""
    echo "killvs [-a acrcFile] [-s jbstatFile] -v vsname"
    echo ""
    echo "-a acrcFile:   specify acrc file.  Optional if ACRC_FILE environment"
    echo "               variable is set."
    echo "-s jbstatFile: specify jukebox status file.  Optional if the"
    echo "               JBSTAT_FILE environment variable is set."
    echo "-v vsname:     Name of the volume set to destroy."
    echo ""
}

#------------------------------------------------------------------------------
# main
#------------------------------------------------------------------------------

# Parse command line arguments

if [ $# -lt 2 ]
then
    Usage
    exit 2
fi

set -- `getopt a:s:v: $*`
if [ $? != 0 ]
then
    Usage
    exit 2
fi

acset=0
vsnameset=0
jbstatset=0

for i in $*
do
    case $i in
    -a)  ACRCFILE=$2; acset=1; shift 2;;
    -v)  VSNAME=$2; vsnameset=1; shift 2;;
    -s)  JBSTATFILE=$2; jbstatset=1; shift 2;;
    --)  shift; break;;
    esac
done

if [ $vsnameset -eq 0 ]
then
    Usage
    exit 2
fi

# Now invoke arcWrite.

if [ $acset -eq 0 ]
then
    if [ $jbstatset -eq 0 ]
    then 
        ./arcWrite -k -v $VSNAME
    else
        ./arcWrite -k -s $JBSTATFILE -v $VSNAME
    fi
else
    if [ $jbstatset -eq 0 ]
    then 
        ./arcWrite -a $ACRCFILE -k -v $VSNAME
    else
        ./arcWrite -a $ACRCFILE -s $JBSTATFILE -k -v $VSNAME
    fi
fi
